Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WINDUPRULE-708 Quarkus Release 1.11 - Jackson #523

Merged
merged 3 commits into from
Feb 3, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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("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/jackson\$"))
.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/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<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 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")
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0"?>
<ruleset xmlns="http://windup.jboss.org/schema/jboss-ruleset" id="quarkus1-11-resteasy-jackson"
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 Jackson
</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-resteasy-jackson-00000">
<when>
<graph-query discriminator="WindupJavaConfigurationModel" as="discard">
<property type="BOOLEAN" name="sourceMode">true</property>
</graph-query>
<project>
<artifact groupId="io.quarkus" artifactId="quarkus-resteasy-jackson"/>
</project>
</when>
<perform>
<iteration over="default">
<hint title="The Jackson ObjectMapper ignores unknown properties" effort="1" category-id="potential">
<message>
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.
</message>
<link title="Quarkus - Writing JSON REST Services" href="https://quarkus.io/guides/rest-json#jackson" />
<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 rules-reviewed/quarkus/quarkus1-10/tests/data/pom.xml
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-resteasy-jackson</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 not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0"?>
<ruletest id="quarkus1-11-resteasy-jackson-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/test.jar</testDataPath>
<sourceMode>false</sourceMode>
<rulePath>../quarkus1-11-resteasy-jackson.windup.groovy</rulePath>
<ruleset>
<rules>
<rule id="quarkus1-11-resteasy-jackson-compiled-test">
PhilipCattanach marked this conversation as resolved.
Show resolved Hide resolved
<when>
<not>
<iterable-filter size="1">
<hint-exists message="The default `ObjectMapper` obtained via CDI and consumed by the Quarkus extensions*"/>
</iterable-filter>
</not>
</when>
<perform>
<fail message="[quarkus1-11-resteasy-jackson-compiled] The Jackson ObjectMapper hint was not found!" />
</perform>
</rule>
</rules>
</ruleset>
</ruletest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0"?>
<ruletest id="quarkus1-11-resteasy-jackson-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/</testDataPath>
<rulePath>../quarkus1-11-resteasy-jackson.windup.xml</rulePath>
<ruleset>
<rules>
<rule id="quarkus1-11-resteasy-jackson-test">
PhilipCattanach marked this conversation as resolved.
Show resolved Hide resolved
<when>
<not>
<iterable-filter size="1">
<hint-exists message="The default `ObjectMapper` obtained via CDI and consumed by the Quarkus extensions*"/>
</iterable-filter>
</not>
</when>
<perform>
<fail message="[quarkus1-11-resteasy-jackson] The Jackson `ObjectMapper` hint was not found!" />
</perform>
</rule>
</rules>
</ruleset>
</ruletest>