Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
timtebeek authored Feb 5, 2024
2 parents 2065265 + 24822d3 commit 6743def
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,7 @@

import lombok.EqualsAndHashCode;
import lombok.Value;
import org.openrewrite.ExecutionContext;
import org.openrewrite.Option;
import org.openrewrite.Recipe;
import org.openrewrite.SourceFile;
import org.openrewrite.Tree;
import org.openrewrite.TreeVisitor;
import org.openrewrite.*;
import org.openrewrite.internal.StringUtils;
import org.openrewrite.internal.lang.Nullable;
import org.openrewrite.properties.AddProperty;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import java.util.List;

@Value
@EqualsAndHashCode(callSuper = true)
@EqualsAndHashCode(callSuper = false)
public class ChangeQuarkusPropertyKey extends Recipe {

@Option(displayName = "Old property key",
Expand All @@ -38,12 +38,6 @@ public class ChangeQuarkusPropertyKey extends Recipe {
example = "quarkus.hibernate-search-orm.indexing.plan.synchronization.strategy")
String newPropertyKey;

@Option(displayName = "Except",
description = "Regex. If any of these property keys exist as direct children of `oldPropertyKey`, then they will not be moved to `newPropertyKey`.",
required = false)
@Nullable
List<String> except;

@Option(displayName = "Profile",
description = "The profile where the property is defined. If not specified, the property will be changed on all profiles. Defaults to `true`.",
required = false,
Expand Down Expand Up @@ -97,7 +91,7 @@ public String getDescription() {
public TreeVisitor<?, ExecutionContext> getVisitor() {
return Preconditions.check(
new FindQuarkusProperties(oldPropertyKey, profile, changeAllProfiles).getVisitor(),
new ChangeQuarkusPropertyKeyVisitor(oldPropertyKey, newPropertyKey, except, profile, changeAllProfiles, pathExpressions)
new ChangeQuarkusPropertyKeyVisitor(oldPropertyKey, newPropertyKey, profile, changeAllProfiles, pathExpressions)
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ class ChangeQuarkusPropertyKeyVisitor extends TreeVisitor<Tree, ExecutionContext

final String newPropertyKey;

@Nullable
final List<String> except;

@Nullable
final String profile;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import java.util.List;

@Value
@EqualsAndHashCode(callSuper = true)
@EqualsAndHashCode(callSuper = false)
public class ChangeQuarkusPropertyValue extends Recipe {

@Option(displayName = "Property key",
Expand All @@ -34,12 +34,14 @@ public class ChangeQuarkusPropertyValue extends Recipe {
String propertyKey;

@Option(displayName = "New value",
description = "The new value to be used for key specified by `propertyKey`.")
description = "The new value to be used for key specified by `propertyKey`.",
example = "read-sync")
String newValue;

@Option(displayName = "Old value",
required = false,
description = "Only change the property value if it matches the configured `oldValue`.")
description = "Only change the property value if it matches the configured `oldValue`.",
example = "read-sync")
@Nullable
String oldValue;

Expand Down
12 changes: 4 additions & 8 deletions src/main/java/org/openrewrite/quarkus/DeleteQuarkusProperty.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,15 @@

import lombok.EqualsAndHashCode;
import lombok.Value;
import org.openrewrite.ExecutionContext;
import org.openrewrite.Option;
import org.openrewrite.Preconditions;
import org.openrewrite.Recipe;
import org.openrewrite.TreeVisitor;
import org.openrewrite.Validated;
import org.openrewrite.*;
import org.openrewrite.internal.StringUtils;
import org.openrewrite.internal.lang.Nullable;
import org.openrewrite.quarkus.search.FindQuarkusProperties;

import java.util.List;

@Value
@EqualsAndHashCode(callSuper = true)
@EqualsAndHashCode(callSuper = false)
public class DeleteQuarkusProperty extends Recipe {

@Option(displayName = "Property key",
Expand All @@ -40,7 +35,8 @@ public class DeleteQuarkusProperty extends Recipe {

@Option(displayName = "Old value",
required = false,
description = "Only delete the property value if it matches the configured `oldValue`.")
description = "Only delete the property value if it matches the configured `oldValue`.",
example = "read-sync")
@Nullable
String oldValue;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* This recipe is used to find Quarkus profiles.
*/
@Value
@EqualsAndHashCode(callSuper = true)
@EqualsAndHashCode(callSuper = false)
public class FindQuarkusProfiles extends Recipe {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import java.util.regex.Pattern;

@Value
@EqualsAndHashCode(callSuper = true)
@EqualsAndHashCode(callSuper = false)
public class FindQuarkusProperties extends Recipe {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void noChangesIfKeyNotFound() {
spec -> spec.recipe(new ChangeQuarkusPropertyKey(
"quarkus\\.foo",
"quarkus\\.bar",
null, null, null, null)),
null, null, null)),
properties(sourceProperties, spec -> spec.path("src/main/resources/application.properties"))
);
}
Expand All @@ -66,7 +66,7 @@ void changeKeyOnDefaultProfileOnly() {
spec -> spec.recipe(new ChangeQuarkusPropertyKey(
"quarkus\\.hibernate-search-orm(\\..*)?\\.automatic-indexing\\.synchronization\\.strategy",
"quarkus.hibernate-search-orm$1.indexing.plan.synchronization.strategy",
null, null, false, null)),
null, false, null)),
properties(sourceProperties, after, spec -> spec.path("src/main/resources/application.properties"))
);
}
Expand All @@ -90,7 +90,7 @@ void changeKeyOnlyOnSpecificProfile() {
spec -> spec.recipe(new ChangeQuarkusPropertyKey(
"quarkus\\.hibernate-search-orm(\\..*)?\\.automatic-indexing\\.synchronization\\.strategy",
"quarkus.hibernate-search-orm$1.indexing.plan.synchronization.strategy",
null, "prod", false, null)),
"prod", false, null)),
properties(sourceProperties, after, spec -> spec.path("src/main/resources/application.properties"))
);
}
Expand All @@ -112,7 +112,7 @@ void changeKeyOnAllProfiles() {
spec -> spec.recipe(new ChangeQuarkusPropertyKey(
"quarkus\\.hibernate-search-orm(\\..*)?\\.automatic-indexing\\.synchronization\\.strategy",
"quarkus.hibernate-search-orm$1.indexing.plan.synchronization.strategy",
null, null, true, null)),
null, true, null)),
properties(sourceProperties, after, spec -> spec.path("src/main/resources/application.properties"))
);
}
Expand Down Expand Up @@ -159,7 +159,7 @@ void noChangesIfKeyNotFound() {
spec -> spec.recipe(new ChangeQuarkusPropertyKey(
"quarkus\\.foo",
"quarkus\\.bar",
null, null, null, null)),
null, null, null)),
yaml(sourceYaml, spec -> spec.path("src/main/resources/application.yaml"))
);
}
Expand Down Expand Up @@ -205,7 +205,7 @@ void changeKeyOnDefaultProfileOnly() {
spec -> spec.recipe(new ChangeQuarkusPropertyKey(
"quarkus\\.hibernate-search-orm(\\..*)?\\.automatic-indexing\\.synchronization\\.strategy",
"quarkus.hibernate-search-orm$1.indexing.plan.synchronization.strategy",
null, null, false, null)),
null, false, null)),
yaml(sourceYaml, after, spec -> spec.path("src/main/resources/application.yaml"))
);
}
Expand Down Expand Up @@ -260,7 +260,7 @@ void changeKeyOnlyOnSpecificProfile() {
spec -> spec.recipe(new ChangeQuarkusPropertyKey(
"quarkus\\.hibernate-search-orm(\\..*)?\\.automatic-indexing\\.synchronization\\.strategy",
"quarkus.hibernate-search-orm$1.indexing.plan.synchronization.strategy",
null, "prod", false, null)),
"prod", false, null)),
yaml(sourceYaml, after, spec -> spec.path("src/main/resources/application.yaml"))
);
}
Expand Down Expand Up @@ -310,7 +310,7 @@ void changeKeyOnAllProfiles() {
spec -> spec.recipe(new ChangeQuarkusPropertyKey(
"quarkus\\.hibernate-search-orm(\\..*)?\\.automatic-indexing\\.synchronization\\.strategy",
"quarkus.hibernate-search-orm$1.indexing.plan.synchronization.strategy",
null, null, true, null)),
null, true, null)),
yaml(sourceYaml, after, spec -> spec.path("src/main/resources/application.yaml"))
);
}
Expand Down

0 comments on commit 6743def

Please sign in to comment.