From d58c0733820f0f68d7a08eb238dceaa8d96f4e38 Mon Sep 17 00:00:00 2001 From: Marco Rizzi Date: Thu, 4 Feb 2021 19:50:52 +0100 Subject: [PATCH] WINDUPRULE-710 Divived Groovy rule in two different rules (#7) * WINDUPRULE-708 Quarkus Release 1.11 - Jackson (#523) * WINDUPRULE-708 Quarkus Release 1.11 - Jackson * WINDUPRULE-708 - rename tests to be consistent with rules * WINDUPRULE-708 changed to quarkus1 target so new quarkus1 folder under rules-reviewed Co-authored-by: Phil Cattanach * WINDUPRULE-710 Divived Groovy rule in two different rules Co-authored-by: PhilipCattanach <31246010+PhilipCattanach@users.noreply.github.com> Co-authored-by: Phil Cattanach --- ...rnate-elasticsearch-compiled.windup.groovy | 48 +++++-- ...search-compiled-properties.windup.test.xml | 6 +- ...ate-elasticsearch-compiled.windup.test.xml | 2 +- ...quarkus1-11-resteasy-jackson.windup.groovy | 58 +++++++++ .../quarkus1-11-resteasy-jackson.windup.xml | 42 ++++++ .../quarkus1/quarkus1-10/tests/data/pom.xml | 123 ++++++++++++++++++ .../quarkus1/quarkus1-10/tests/data/test.jar | Bin 0 -> 462 bytes ...-resteasy-jackson-compiled.windup.test.xml | 25 ++++ ...arkus1-11-resteasy-jackson.windup.test.xml | 24 ++++ 9 files changed, 313 insertions(+), 15 deletions(-) create mode 100644 rules-reviewed/quarkus1/quarkus1-10/quarkus1-11-resteasy-jackson.windup.groovy create mode 100644 rules-reviewed/quarkus1/quarkus1-10/quarkus1-11-resteasy-jackson.windup.xml create mode 100644 rules-reviewed/quarkus1/quarkus1-10/tests/data/pom.xml create mode 100644 rules-reviewed/quarkus1/quarkus1-10/tests/data/test.jar create mode 100644 rules-reviewed/quarkus1/quarkus1-10/tests/quarkus1-11-resteasy-jackson-compiled.windup.test.xml create mode 100644 rules-reviewed/quarkus1/quarkus1-10/tests/quarkus1-11-resteasy-jackson.windup.test.xml diff --git a/rules-reviewed/quarkus/quarkus1-10/quarkus1-11-hibernate-elasticsearch-compiled.windup.groovy b/rules-reviewed/quarkus/quarkus1-10/quarkus1-11-hibernate-elasticsearch-compiled.windup.groovy index 34388b7c0..a6ca20d67 100644 --- a/rules-reviewed/quarkus/quarkus1-10/quarkus1-11-hibernate-elasticsearch-compiled.windup.groovy +++ b/rules-reviewed/quarkus/quarkus1-10/quarkus1-11-hibernate-elasticsearch-compiled.windup.groovy @@ -25,13 +25,10 @@ ruleSet("quarkus1-11-hibernate-elasticsearch-compiled-groovy") .addTargetTechnology(new TechnologyReference("quarkus", "[11,)")) .addRule() .when(SourceMode.isDisabled(), - Or.any( - Query.fromType(FileModel) - .withProperty(FileModel.IS_DIRECTORY, Boolean.TRUE) - .withProperty(FileModel.FILE_PATH, QueryPropertyComparisonType.REGEX, ".*/io/quarkus/hibernate/search/orm/elasticsearch\$"), - FileContent.matches("quarkus.hibernate-search-orm.elasticsearch.version").inFileNamed("application.properties") - ) -) + Query.fromType(FileModel) + .withProperty(FileModel.IS_DIRECTORY, Boolean.TRUE) + .withProperty(FileModel.FILE_PATH, QueryPropertyComparisonType.REGEX, ".*/io/quarkus/hibernate/search/orm/elasticsearch\$") + ) .perform(new AbstractIterationOperation() { void perform(GraphRewrite event, EvaluationContext context, FileModel payload) { //ensure that the dependency being searched for is present in the current application @@ -52,15 +49,44 @@ ruleSet("quarkus1-11-hibernate-elasticsearch-compiled-groovy") folderLocationModel.setLength(1) folderLocationModel.setSourceSnippit("Folder Match") ((Hint) Hint.titled("The default required status for Elasticsearch indexes is now yellow") - .withText("""The default required status for Elasticsearch indexes is now yellow. - If you have specific requirements and need to wait for indexes to be green on startup, - set quarkus.hibernate-search.elasticsearch.schema-management.required-status to green. + .withText("""The default required status for Elasticsearch indexes is now `yellow`. + If you have specific requirements and need to wait for indexes to be `green` on startup, + set `quarkus.hibernate-search.elasticsearch.schema-management.required-status` to `green`. Refer to the guide below for more details about how to return to the previous behaviour.""") .withIssueCategory(potentialIssueCategory) .with(Link.to("Quarkus - Hibernate Search Guide", "https://quarkus.io/guides/hibernate-search-orm-elasticsearch")) - .with(Link.to("Quarkus - Migraton Guide 1.11", "https://github.com/quarkusio/quarkus/wiki/Migration-Guide-1.11")) + .with(Link.to("Quarkus - Migration Guide 1.11", "https://github.com/quarkusio/quarkus/wiki/Migration-Guide-1.11")) .withEffort(1) ).performParameterized(event, context, folderLocationModel) } }) .withId("quarkus1-11-hibernate-elasticsearch-compiled-groovy-00000") + .addRule() + .when(SourceMode.isDisabled(), + FileContent.matches("quarkus.hibernate-search-orm.elasticsearch.version").inFileNamed("application.properties") + ) + .perform(new AbstractIterationOperation() { + void perform(GraphRewrite event, EvaluationContext context, FileLocationModel payload) { + // ensure that the application.properties being searched for is present + // in the current application rather than any application in the MTA project + final String sourceBasePath = payload.getFile().getFilePath().replace("application.properties", "") + final String dependencyJarName = sourceBasePath.substring(sourceBasePath.lastIndexOf("/") + 1) + WindupConfigurationModel windupConfigurationModel = WindupConfigurationService.getConfigurationModel(event.getGraphContext()) + boolean propertiesFileComesFromAnalyzedApplication = false + windupConfigurationModel.getInputPaths().each { + if (!propertiesFileComesFromAnalyzedApplication && it.filePath.endsWith(dependencyJarName)) propertiesFileComesFromAnalyzedApplication = true + } + if (!propertiesFileComesFromAnalyzedApplication) return + ((Hint) Hint.titled("The default required status for Elasticsearch indexes is now yellow") + .withText("""The default required status for Elasticsearch indexes is now `yellow`. + If you have specific requirements and need to wait for indexes to be `green` on startup, + set `quarkus.hibernate-search.elasticsearch.schema-management.required-status` to `green`. + Refer to the guide below for more details about how to return to the previous behaviour.""") + .withIssueCategory(potentialIssueCategory) + .with(Link.to("Quarkus - Hibernate Search Guide", "https://quarkus.io/guides/hibernate-search-orm-elasticsearch")) + .with(Link.to("Quarkus - Migration Guide 1.11", "https://github.com/quarkusio/quarkus/wiki/Migration-Guide-1.11")) + .withEffort(1) + ).performParameterized(event, context, payload) + } + }) + .withId("quarkus1-11-hibernate-elasticsearch-compiled-groovy-00010") diff --git a/rules-reviewed/quarkus/quarkus1-10/tests/quarkus1-11-hibernate-elasticsearch-compiled-properties.windup.test.xml b/rules-reviewed/quarkus/quarkus1-10/tests/quarkus1-11-hibernate-elasticsearch-compiled-properties.windup.test.xml index 3ac443723..7cdb37b18 100644 --- a/rules-reviewed/quarkus/quarkus1-10/tests/quarkus1-11-hibernate-elasticsearch-compiled-properties.windup.test.xml +++ b/rules-reviewed/quarkus/quarkus1-10/tests/quarkus1-11-hibernate-elasticsearch-compiled-properties.windup.test.xml @@ -4,15 +4,15 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://windup.jboss.org/schema/jboss-ruleset http://windup.jboss.org/schema/jboss-ruleset/windup-jboss-ruleset.xsd"> data/hibernate-elasticsearch/testProperties.jar - true + false ../quarkus1-11-hibernate-elasticsearch-compiled.windup.groovy - + - + diff --git a/rules-reviewed/quarkus/quarkus1-10/tests/quarkus1-11-hibernate-elasticsearch-compiled.windup.test.xml b/rules-reviewed/quarkus/quarkus1-10/tests/quarkus1-11-hibernate-elasticsearch-compiled.windup.test.xml index 2500f731c..f40dabcd6 100644 --- a/rules-reviewed/quarkus/quarkus1-10/tests/quarkus1-11-hibernate-elasticsearch-compiled.windup.test.xml +++ b/rules-reviewed/quarkus/quarkus1-10/tests/quarkus1-11-hibernate-elasticsearch-compiled.windup.test.xml @@ -12,7 +12,7 @@ - + diff --git a/rules-reviewed/quarkus1/quarkus1-10/quarkus1-11-resteasy-jackson.windup.groovy b/rules-reviewed/quarkus1/quarkus1-10/quarkus1-11-resteasy-jackson.windup.groovy new file mode 100644 index 000000000..3fc587a9c --- /dev/null +++ b/rules-reviewed/quarkus1/quarkus1-10/quarkus1-11-resteasy-jackson.windup.groovy @@ -0,0 +1,58 @@ +import org.jboss.windup.config.GraphRewrite +import org.jboss.windup.config.metadata.TechnologyReference +import org.jboss.windup.config.operation.iteration.AbstractIterationOperation +import org.jboss.windup.config.query.Query +import org.jboss.windup.config.query.QueryPropertyComparisonType +import org.jboss.windup.graph.model.FileLocationModel +import org.jboss.windup.graph.model.WindupConfigurationModel +import org.jboss.windup.graph.model.resource.FileModel +import org.jboss.windup.graph.service.GraphService +import org.jboss.windup.graph.service.WindupConfigurationService +import org.jboss.windup.reporting.category.IssueCategory +import org.jboss.windup.reporting.category.IssueCategoryRegistry +import org.jboss.windup.reporting.config.Hint +import org.jboss.windup.reporting.config.Link +import org.jboss.windup.rules.apps.java.condition.SourceMode +import org.ocpsoft.rewrite.context.EvaluationContext + +final IssueCategory potentialIssueCategory = new IssueCategoryRegistry().getByID(IssueCategoryRegistry.POTENTIAL) + +ruleSet("quarkus1-11-resteasy-jackson-groovy") + .addSourceTechnology(new TechnologyReference("quarkus1", "(,10]")) + .addTargetTechnology(new TechnologyReference("quarkus1", "[11,)")) + .addRule() + .when(SourceMode.isDisabled(), + Query.fromType(FileModel) + .withProperty(FileModel.IS_DIRECTORY, Boolean.TRUE) + .withProperty(FileModel.FILE_PATH, QueryPropertyComparisonType.REGEX, ".*/io/quarkus/jackson\$")) + .perform(new AbstractIterationOperation() { + void perform(GraphRewrite event, EvaluationContext context, FileModel payload) { + //ensure that the dependency being searched for is present in the current application + //rather than any application in the MTA project + final String sourceBasePath = payload.getFilePath().replace("/io/quarkus/jackson", "") + final String dependencyJarName = sourceBasePath.substring(sourceBasePath.lastIndexOf("/") + 1) + WindupConfigurationModel windupConfigurationModel = WindupConfigurationService.getConfigurationModel(event.getGraphContext()) + boolean packageComesFromAnalyzedApplication = false + windupConfigurationModel.getInputPaths().each { + if (!packageComesFromAnalyzedApplication && it.filePath.endsWith(dependencyJarName)) packageComesFromAnalyzedApplication = true + } + if (!packageComesFromAnalyzedApplication) return + final GraphService fileLocationService = new GraphService<>(event.getGraphContext(), FileLocationModel.class) + final FileLocationModel folderLocationModel = fileLocationService.create() + folderLocationModel.setFile(payload) + folderLocationModel.setColumnNumber(1) + folderLocationModel.setLineNumber(1) + folderLocationModel.setLength(1) + folderLocationModel.setSourceSnippit("Folder Match") + ((Hint) Hint.titled("The Jackson ObjectMapper ignores unknown properties") + .withText("""The default `ObjectMapper` obtained via CDI and consumed by the Quarkus extensions now ignores unknown properties + (by disabling the `DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES` feature). + Refer to the guide below for more details about how to return to the previous behaviour.""") + .withIssueCategory(potentialIssueCategory) + .with(Link.to("Quarkus - Writing JSON REST Services", "https://quarkus.io/guides/rest-json#jackson")) + .with(Link.to("Quarkus - Migraton Guide 1.11", "https://github.com/quarkusio/quarkus/wiki/Migration-Guide-1.11")) + .withEffort(1) + ).performParameterized(event, context, folderLocationModel) + } + }) + .withId("quarkus1-11-resteasy-jackson-groovy-00000") diff --git a/rules-reviewed/quarkus1/quarkus1-10/quarkus1-11-resteasy-jackson.windup.xml b/rules-reviewed/quarkus1/quarkus1-10/quarkus1-11-resteasy-jackson.windup.xml new file mode 100644 index 000000000..3a274e391 --- /dev/null +++ b/rules-reviewed/quarkus1/quarkus1-10/quarkus1-11-resteasy-jackson.windup.xml @@ -0,0 +1,42 @@ + + + + + This ruleset gives hints for upgrading to quarkus 1.11 for applications that use Jackson + + + + + + + + + + + + + + + true + + + + + + + + + + The default `ObjectMapper` obtained via CDI and consumed by the Quarkus extensions now ignores unknown properties + (by disabling the `DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES` feature). + Refer to the guide below for more details about how to return to the previous behaviour. + + + + + + + + + diff --git a/rules-reviewed/quarkus1/quarkus1-10/tests/data/pom.xml b/rules-reviewed/quarkus1/quarkus1-10/tests/data/pom.xml new file mode 100644 index 000000000..3266e0b55 --- /dev/null +++ b/rules-reviewed/quarkus1/quarkus1-10/tests/data/pom.xml @@ -0,0 +1,123 @@ + + + 4.0.0 + org.acme + rest-json-quickstart + 1.0-SNAPSHOT + + 1.10.0.Final + quarkus-bom + io.quarkus + 1.10.0.Final + 3.0.0-M5 + UTF-8 + 1.8 + 1.8 + + + + + + ${quarkus.platform.group-id} + ${quarkus.platform.artifact-id} + ${quarkus.platform.version} + pom + import + + + + + + + io.quarkus + quarkus-resteasy-jackson + + + io.quarkus + quarkus-junit5 + test + + + io.rest-assured + rest-assured + test + + + + + + maven-surefire-plugin + ${surefire-plugin.version} + + + org.jboss.logmanager.LogManager + ${maven.home} + + + + + io.quarkus + quarkus-maven-plugin + ${quarkus-plugin.version} + + + + build + + + + + + + + + native + + + native + + + + + + io.quarkus + quarkus-maven-plugin + ${quarkus-plugin.version} + + + + native-image + + + true + + + + + + org.apache.maven.plugins + maven-failsafe-plugin + ${surefire-plugin.version} + + + + integration-test + verify + + + + ${project.build.directory}/${project.build.finalName}-runner + org.jboss.logmanager.LogManager + ${maven.home} + + + + + + + + + + diff --git a/rules-reviewed/quarkus1/quarkus1-10/tests/data/test.jar b/rules-reviewed/quarkus1/quarkus1-10/tests/data/test.jar new file mode 100644 index 0000000000000000000000000000000000000000..d75414d9aad04d80ea3167a761ee1538b3f48a30 GIT binary patch literal 462 zcmWIWW@h1HVBlZ?0!0lF2?NXwEDV|X`u|QbFa+RK#0^vpR8&}+Sd?8_tdCovFsj0= z#N_Pa{5(7w + + data/test.jar + false + ../quarkus1-11-resteasy-jackson.windup.groovy + + + + + + + + + + + + + + + + + diff --git a/rules-reviewed/quarkus1/quarkus1-10/tests/quarkus1-11-resteasy-jackson.windup.test.xml b/rules-reviewed/quarkus1/quarkus1-10/tests/quarkus1-11-resteasy-jackson.windup.test.xml new file mode 100644 index 000000000..27706c0d6 --- /dev/null +++ b/rules-reviewed/quarkus1/quarkus1-10/tests/quarkus1-11-resteasy-jackson.windup.test.xml @@ -0,0 +1,24 @@ + + + data/ + ../quarkus1-11-resteasy-jackson.windup.xml + + + + + + + + + + + + + + + + +