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 new file mode 100644 index 000000000..a6ca20d67 --- /dev/null +++ b/rules-reviewed/quarkus/quarkus1-10/quarkus1-11-hibernate-elasticsearch-compiled.windup.groovy @@ -0,0 +1,92 @@ +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.jboss.windup.rules.files.condition.FileContent +import org.jboss.windup.rules.files.condition.FileContentMatches +import org.ocpsoft.rewrite.config.Or +import org.ocpsoft.rewrite.context.EvaluationContext + +final IssueCategory potentialIssueCategory = new IssueCategoryRegistry().getByID(IssueCategoryRegistry.POTENTIAL) + +ruleSet("quarkus1-11-hibernate-elasticsearch-compiled-groovy") + .addSourceTechnology(new TechnologyReference("quarkus", "(,10]")) + .addTargetTechnology(new TechnologyReference("quarkus", "[11,)")) + .addRule() + .when(SourceMode.isDisabled(), + 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 + //rather than any application in the MTA project + final String sourceBasePath = payload.getFilePath().replace("/io/quarkus/hibernate/search/orm/elasticsearch", "") + 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 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, 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/quarkus1-11-hibernate-elasticsearch.windup.xml b/rules-reviewed/quarkus/quarkus1-10/quarkus1-11-hibernate-elasticsearch.windup.xml new file mode 100644 index 000000000..eaf869c85 --- /dev/null +++ b/rules-reviewed/quarkus/quarkus1-10/quarkus1-11-hibernate-elasticsearch.windup.xml @@ -0,0 +1,43 @@ + + + + + This ruleset gives hints for upgrading to quarkus 1.11 for applications that use Hibernate ORM Elasticsearch + + + + + + + + + + + + + + + true + + + + + + + + + + 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 guides below for more details about how to return to the previous behaviour. + + + + + + + + + diff --git a/rules-reviewed/quarkus/quarkus1-10/tests/data/hibernate-elasticsearch/pom.xml b/rules-reviewed/quarkus/quarkus1-10/tests/data/hibernate-elasticsearch/pom.xml new file mode 100644 index 000000000..bddecbbcf --- /dev/null +++ b/rules-reviewed/quarkus/quarkus1-10/tests/data/hibernate-elasticsearch/pom.xml @@ -0,0 +1,123 @@ + + + 4.0.0 + org.acme + rest-json-quickstart + 1.0-SNAPSHOT + + 1.11.0.Final + quarkus-bom + io.quarkus + 1.11.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-hibernate-search-orm-elasticsearch + + + 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/quarkus/quarkus1-10/tests/data/hibernate-elasticsearch/test.jar b/rules-reviewed/quarkus/quarkus1-10/tests/data/hibernate-elasticsearch/test.jar new file mode 100644 index 000000000..060e6ac1f Binary files /dev/null and b/rules-reviewed/quarkus/quarkus1-10/tests/data/hibernate-elasticsearch/test.jar differ diff --git a/rules-reviewed/quarkus/quarkus1-10/tests/data/hibernate-elasticsearch/testProperties.jar b/rules-reviewed/quarkus/quarkus1-10/tests/data/hibernate-elasticsearch/testProperties.jar new file mode 100644 index 000000000..d6a28f9d0 Binary files /dev/null and b/rules-reviewed/quarkus/quarkus1-10/tests/data/hibernate-elasticsearch/testProperties.jar differ 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 new file mode 100644 index 000000000..7cdb37b18 --- /dev/null +++ b/rules-reviewed/quarkus/quarkus1-10/tests/quarkus1-11-hibernate-elasticsearch-compiled-properties.windup.test.xml @@ -0,0 +1,25 @@ + + + data/hibernate-elasticsearch/testProperties.jar + 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 new file mode 100644 index 000000000..f40dabcd6 --- /dev/null +++ b/rules-reviewed/quarkus/quarkus1-10/tests/quarkus1-11-hibernate-elasticsearch-compiled.windup.test.xml @@ -0,0 +1,25 @@ + + + data/hibernate-elasticsearch/test.jar + false + ../quarkus1-11-hibernate-elasticsearch-compiled.windup.groovy + + + + + + + + + + + + + + + + + diff --git a/rules-reviewed/quarkus/quarkus1-10/tests/quarkus1-11-hibernate-elasticsearch.windup.test.xml b/rules-reviewed/quarkus/quarkus1-10/tests/quarkus1-11-hibernate-elasticsearch.windup.test.xml new file mode 100644 index 000000000..dbdd4a270 --- /dev/null +++ b/rules-reviewed/quarkus/quarkus1-10/tests/quarkus1-11-hibernate-elasticsearch.windup.test.xml @@ -0,0 +1,24 @@ + + + data/hibernate-elasticsearch + ../quarkus1-11-hibernate-elasticsearch.windup.xml + + + + + + + + + + + + + + + + +