-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WINDUPRULE-710: rules for quarkus upgrade of hibernate-orm-elasticsea…
…rch (#524) * WINDUPRULE-710: rules for quarkus upgrade of hibernate-orm-elasticsearch * 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 <pcattana@pcattana.remote.csb> * WINDUPRULE-710 Divived Groovy rule in two different rules Co-authored-by: PhilipCattanach <31246010+PhilipCattanach@users.noreply.github.com> Co-authored-by: Phil Cattanach <pcattana@pcattana.remote.csb> * WINDUPRULE-710: fix wrongly removed tag in pom file Co-authored-by: Marco Rizzi <mrizzi@users.noreply.github.com> Co-authored-by: PhilipCattanach <31246010+PhilipCattanach@users.noreply.github.com> Co-authored-by: Phil Cattanach <pcattana@pcattana.remote.csb>
- Loading branch information
1 parent
b392c14
commit 74688d2
Showing
8 changed files
with
332 additions
and
0 deletions.
There are no files selected for viewing
92 changes: 92 additions & 0 deletions
92
...s-reviewed/quarkus/quarkus1-10/quarkus1-11-hibernate-elasticsearch-compiled.windup.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<FileModel>() { | ||
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<FileLocationModel> 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<FileLocationModel>() { | ||
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") |
43 changes: 43 additions & 0 deletions
43
rules-reviewed/quarkus/quarkus1-10/quarkus1-11-hibernate-elasticsearch.windup.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?xml version="1.0"?> | ||
<ruleset xmlns="http://windup.jboss.org/schema/jboss-ruleset" id="quarkus1-11-hibernate-elasticsearch" | ||
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"> | ||
<metadata> | ||
<description> | ||
This ruleset gives hints for upgrading to quarkus 1.11 for applications that use Hibernate ORM Elasticsearch | ||
</description> | ||
<dependencies> | ||
<addon id="org.jboss.windup.rules,windup-rules-javaee,3.0.0.Final" /> | ||
<addon id="org.jboss.windup.rules,windup-rules-java,3.0.0.Final" /> | ||
<addon id="org.jboss.windup.rules,windup-rules-xml,3.0.0.Final" /> | ||
</dependencies> | ||
<!-- The major version is implied by the target, the minor is reflected in the verionRange --> | ||
<sourceTechnology id="quarkus" versionRange="(,10]"/> | ||
<targetTechnology id="quarkus" versionRange="[11,)"/> | ||
</metadata> | ||
<rules> | ||
<rule id="quarkus1-11-hibernate-elasticsearch-00000"> | ||
<when> | ||
<graph-query discriminator="WindupJavaConfigurationModel" as="discard"> | ||
<property type="BOOLEAN" name="sourceMode">true</property> | ||
</graph-query> | ||
<project> | ||
<artifact groupId="io.quarkus" artifactId="quarkus-hibernate-search-orm-elasticsearch"/> | ||
</project> | ||
</when> | ||
<perform> | ||
<iteration over="default"> | ||
<hint title="The default required status for Elasticsearch indexes is now yellow" effort="1" category-id="potential"> | ||
<message> | ||
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. | ||
</message> | ||
<link title="Quarkus - Hibernate Search Guide" href="https://quarkus.io/guides/hibernate-search-orm-elasticsearch" /> | ||
<link title="Quarkus - Migraton Guide 1.11" href="https://github.com/quarkusio/quarkus/wiki/Migration-Guide-1.11" /> | ||
</hint> | ||
</iteration> | ||
</perform> | ||
</rule> | ||
</rules> | ||
</ruleset> |
123 changes: 123 additions & 0 deletions
123
rules-reviewed/quarkus/quarkus1-10/tests/data/hibernate-elasticsearch/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
<?xml version="1.0"?> | ||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" | ||
xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>org.acme</groupId> | ||
<artifactId>rest-json-quickstart</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<properties> | ||
<quarkus-plugin.version>1.11.0.Final</quarkus-plugin.version> | ||
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id> | ||
<quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id> | ||
<quarkus.platform.version>1.11.0.Final</quarkus.platform.version> | ||
<surefire-plugin.version>3.0.0-M5</surefire-plugin.version> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<maven.compiler.source>1.8</maven.compiler.source> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
</properties> | ||
|
||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>${quarkus.platform.group-id}</groupId> | ||
<artifactId>${quarkus.platform.artifact-id}</artifactId> | ||
<version>${quarkus.platform.version}</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-hibernate-search-orm-elasticsearch</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-junit5</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.rest-assured</groupId> | ||
<artifactId>rest-assured</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>${surefire-plugin.version}</version> | ||
<configuration> | ||
<systemPropertyVariables> | ||
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager> | ||
<maven.home>${maven.home}</maven.home> | ||
</systemPropertyVariables> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-maven-plugin</artifactId> | ||
<version>${quarkus-plugin.version}</version> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>build</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
<profiles> | ||
<profile> | ||
<id>native</id> | ||
<activation> | ||
<property> | ||
<name>native</name> | ||
</property> | ||
</activation> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-maven-plugin</artifactId> | ||
<version>${quarkus-plugin.version}</version> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>native-image</goal> | ||
</goals> | ||
<configuration> | ||
<enableHttpUrlHandler>true</enableHttpUrlHandler> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-failsafe-plugin</artifactId> | ||
<version>${surefire-plugin.version}</version> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>integration-test</goal> | ||
<goal>verify</goal> | ||
</goals> | ||
<configuration> | ||
<systemPropertyVariables> | ||
<native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path> | ||
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager> | ||
<maven.home>${maven.home}</maven.home> | ||
</systemPropertyVariables> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</profile> | ||
</profiles> | ||
</project> |
Binary file added
BIN
+960 Bytes
rules-reviewed/quarkus/quarkus1-10/tests/data/hibernate-elasticsearch/test.jar
Binary file not shown.
Binary file added
BIN
+991 Bytes
rules-reviewed/quarkus/quarkus1-10/tests/data/hibernate-elasticsearch/testProperties.jar
Binary file not shown.
25 changes: 25 additions & 0 deletions
25
...quarkus1-10/tests/quarkus1-11-hibernate-elasticsearch-compiled-properties.windup.test.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version="1.0"?> | ||
<ruletest id="quarkus1-11-hibernate-elasticsearch-compiled-properties-tests" | ||
xmlns="http://windup.jboss.org/schema/jboss-ruleset" | ||
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"> | ||
<testDataPath>data/hibernate-elasticsearch/testProperties.jar</testDataPath> | ||
<sourceMode>false</sourceMode> | ||
<rulePath>../quarkus1-11-hibernate-elasticsearch-compiled.windup.groovy</rulePath> | ||
<ruleset> | ||
<rules> | ||
<rule id="quarkus1-11-hibernate-elasticsearch-compiled-properties-groovy-00010-test"> | ||
<when> | ||
<not> | ||
<iterable-filter size="1"> | ||
<hint-exists message="The default required status for Elasticsearch indexes is now `yellow`"/> | ||
</iterable-filter> | ||
</not> | ||
</when> | ||
<perform> | ||
<fail message="[quarkus1-11-hibernate-elasticsearch-compiled] The Hibernate Elasticsearch hint was not found!" /> | ||
</perform> | ||
</rule> | ||
</rules> | ||
</ruleset> | ||
</ruletest> |
25 changes: 25 additions & 0 deletions
25
...ed/quarkus/quarkus1-10/tests/quarkus1-11-hibernate-elasticsearch-compiled.windup.test.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version="1.0"?> | ||
<ruletest id="quarkus1-11-hibernate-elasticsearch-compiled-tests" | ||
xmlns="http://windup.jboss.org/schema/jboss-ruleset" | ||
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"> | ||
<testDataPath>data/hibernate-elasticsearch/test.jar</testDataPath> | ||
<sourceMode>false</sourceMode> | ||
<rulePath>../quarkus1-11-hibernate-elasticsearch-compiled.windup.groovy</rulePath> | ||
<ruleset> | ||
<rules> | ||
<rule id="quarkus1-11-hibernate-elasticsearch-compiled-groovy-00000-test"> | ||
<when> | ||
<not> | ||
<iterable-filter size="1"> | ||
<hint-exists message="The default required status for Elasticsearch indexes is now `yellow`"/> | ||
</iterable-filter> | ||
</not> | ||
</when> | ||
<perform> | ||
<fail message="[quarkus1-11-hibernate-elasticsearch-compiled] The Hibernate Elasticsearch hint was not found!" /> | ||
</perform> | ||
</rule> | ||
</rules> | ||
</ruleset> | ||
</ruletest> |
24 changes: 24 additions & 0 deletions
24
rules-reviewed/quarkus/quarkus1-10/tests/quarkus1-11-hibernate-elasticsearch.windup.test.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0"?> | ||
<ruletest id="quarkus1-11-hibernate-elasticsearch-tests" | ||
xmlns="http://windup.jboss.org/schema/jboss-ruleset" | ||
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"> | ||
<testDataPath>data/hibernate-elasticsearch</testDataPath> | ||
<rulePath>../quarkus1-11-hibernate-elasticsearch.windup.xml</rulePath> | ||
<ruleset> | ||
<rules> | ||
<rule id="quarkus1-11-hibernate-elasticsearch-00000-test"> | ||
<when> | ||
<not> | ||
<iterable-filter size="1"> | ||
<hint-exists message="The default required status for Elasticsearch indexes is now yellow"/> | ||
</iterable-filter> | ||
</not> | ||
</when> | ||
<perform> | ||
<fail message="[quarkus1-11-hibernate-elasticsearch] The Hibernate Elasticsearch hint was not found!" /> | ||
</perform> | ||
</rule> | ||
</rules> | ||
</ruleset> | ||
</ruletest> |