Skip to content

Commit

Permalink
Merge pull request #28798 from gsmet/2.13.4-backports-1
Browse files Browse the repository at this point in the history
2.13 - Various Jakarta-related backports
  • Loading branch information
gsmet authored Oct 25, 2022
2 parents 861f530 + 62d380a commit a237230
Show file tree
Hide file tree
Showing 14 changed files with 150 additions and 80 deletions.
4 changes: 4 additions & 0 deletions bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4407,6 +4407,10 @@
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
</exclusion>
<exclusion>
<groupId>org.jboss</groupId>
<artifactId>jandex</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
Expand Down
1 change: 1 addition & 0 deletions build-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1279,6 +1279,7 @@
</activeStyles>
<activeRecipes>
<recipe>io.quarkus.build-parent</recipe>
<recipe>io.quarkus.jakarta-json-cleanup</recipe>
</activeRecipes>
</configuration>
</plugin>
Expand Down
1 change: 0 additions & 1 deletion extensions/infinispan-client/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@
<configuration>
<activeRecipes>
<recipe>io.quarkus.infinispan</recipe>
<recipe>io.quarkus.fix-infinispan-commons</recipe>
</activeRecipes>
</configuration>
</plugin>
Expand Down
5 changes: 5 additions & 0 deletions extensions/jdbc/jdbc-db2/deployment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.transformer</groupId>
<artifactId>org.eclipse.transformer</artifactId>
<version>0.5.0</version>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
package io.quarkus.jdbc.db2.deployment;

import java.nio.ByteBuffer;
import java.util.Collections;
import java.util.List;
import java.util.Map;

import org.eclipse.transformer.action.ActionContext;
import org.eclipse.transformer.action.ByteData;
import org.eclipse.transformer.action.impl.ActionContextImpl;
import org.eclipse.transformer.action.impl.ByteDataImpl;
import org.eclipse.transformer.action.impl.ClassActionImpl;
import org.eclipse.transformer.action.impl.SelectionRuleImpl;
import org.eclipse.transformer.action.impl.SignatureRuleImpl;
import org.eclipse.transformer.util.FileUtils;
import org.objectweb.asm.ClassReader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import io.quarkus.bootstrap.classloading.QuarkusClassLoader;
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.builditem.BytecodeTransformerBuildItem;

/**
* The DB2 driver is compiled using references to classes in the javax.transaction
* package; we need to transform these to fix compatibility with jakarta.transaction.
* We do this by leveraging the Eclipse Transformer project during Augmentation, so
* that end users don't need to bother.
*/
public class JakartaEnablement {

private static final List<String> CLASSES_NEEDING_TRANSFORMATION = List.of(
"com.ibm.db2.jcc.t2zos.ab",
"com.ibm.db2.jcc.t2zos.T2zosConnection",
"com.ibm.db2.jcc.t2zos.T2zosConfiguration");

@BuildStep
void transformToJakarta(BuildProducer<BytecodeTransformerBuildItem> transformers) {
if (QuarkusClassLoader.isClassPresentAtRuntime("jakarta.transaction.Transaction")) {
JakartaTransformer tr = new JakartaTransformer();
for (String classname : CLASSES_NEEDING_TRANSFORMATION) {
final BytecodeTransformerBuildItem item = new BytecodeTransformerBuildItem.Builder()
.setCacheable(true)
.setContinueOnFailure(false)
.setClassToTransform(classname)
.setClassReaderOptions(ClassReader.SKIP_DEBUG)
.setInputTransformer(tr::transform)
.build();
transformers.produce(item);
}
}
}

private static class JakartaTransformer {

private final Logger logger;
private final ActionContext ctx;
private static final Map<String, String> renames = Collections.singletonMap(forbiddenName(), "jakarta.transaction");

JakartaTransformer() {
logger = LoggerFactory.getLogger("JakartaTransformer");
//N.B. we enable only this single transformation of package renames, not the full set of capabilities of Eclipse Transformer;
//this might need tailoring if the same idea gets applied to a different context.
ctx = new ActionContextImpl(logger,
new SelectionRuleImpl(logger, Collections.emptyMap(), Collections.emptyMap()),
new SignatureRuleImpl(logger, renames, null, null, null, null, null, Collections.emptyMap()));
}

//Need to prevent the Eclipse Transformer - which is run on this whole code base - to actually replace this name:
private static String forbiddenName() {
StringBuilder sb = new StringBuilder("java")
.append("x.")
.append("transaction");
return sb.toString();
}

byte[] transform(final String name, final byte[] bytes) {
logger.info("Jakarta EE compatibility enhancer for Quarkus: transforming " + name);
final ClassActionImpl classTransformer = new ClassActionImpl(ctx);
final ByteBuffer input = ByteBuffer.wrap(bytes);
final ByteData inputData = new ByteDataImpl(name, input, FileUtils.DEFAULT_CHARSET);
final ByteData outputData = classTransformer.apply(inputData);
return outputData.buffer().array();
}
}

}
15 changes: 0 additions & 15 deletions extensions/smallrye-reactive-messaging-amqp/deployment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,6 @@
<groupId>org.apache.activemq</groupId>
<artifactId>artemis-server</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.jboss.logmanager</groupId>
<artifactId>jboss-logmanager</artifactId>
</exclusion>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
<exclusion>
<groupId>jakarta.json</groupId>
<artifactId>jakarta.json-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
Expand Down Expand Up @@ -123,5 +109,4 @@
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
<configuration>
<activeRecipes>
<recipe>io.quarkus.jakarta-jaxb-switch</recipe>
<recipe>io.quarkus.jakarta-json-cleanup</recipe>
</activeRecipes>
</configuration>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,10 @@
@Path("/hello")
public class HelloResource {

private final CarMapper carMapper;

public HelloResource(CarMapper carMapper) {
this.carMapper = carMapper;
}

@GET
@Produces(MediaType.APPLICATION_JSON)
public CarDTO hello() {
Car car = new Car("foo", 4);
return carMapper.carToCarDTO(car);
return CarMapper.INSTANCE.carToCarDTO(car);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

import org.acme.common.domain.Car;
import org.acme.common.domain.CarDTO;
import org.mapstruct.InjectionStrategy;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

@Mapper(componentModel = "cdi", injectionStrategy = InjectionStrategy.CONSTRUCTOR)
@Mapper
public interface CarMapper {

CarMapper INSTANCE = Mappers.getMapper( CarMapper.class );

@Mapping(source = "numberOfSeats", target = "seatNumber")
CarDTO carToCarDTO(Car car);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
import org.mapstruct.InjectionStrategy;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

@Mapper(componentModel = "cdi", injectionStrategy = InjectionStrategy.CONSTRUCTOR)
@Mapper
public interface CarMapper {

CarMapper INSTANCE = Mappers.getMapper( CarMapper.class );

@Mapping(source = "numberOfSeats", target = "seatNumber")
CarDTO carToCarDTO(Car car);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,10 @@
@Path("/hello")
public class HelloResource {

private final CarMapper carMapper;

public HelloResource(CarMapper carMapper) {
this.carMapper = carMapper;
}

@GET
@Produces(MediaType.APPLICATION_JSON)
public CarDTO hello() {
Car car = new Car("foo", 4);
return carMapper.carToCarDTO(car);
return CarMapper.INSTANCE.carToCarDTO(car);
}
}
18 changes: 0 additions & 18 deletions integration-tests/reactive-messaging-amqp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,24 +59,6 @@
<groupId>org.apache.activemq</groupId>
<artifactId>artemis-server</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.jboss.logmanager</groupId>
<artifactId>jboss-logmanager</artifactId>
</exclusion>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.johnzon</groupId>
<artifactId>johnzon-core</artifactId>
</exclusion>
<exclusion>
<groupId>jakarta.json</groupId>
<artifactId>jakarta.json-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
Expand Down
60 changes: 34 additions & 26 deletions jakarta/rewrite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ recipeList:
# WildFly Security
- org.openrewrite.maven.ChangePropertyValue:
key: wildfly-elytron.version
newValue: 2.0.0.Beta3
newValue: 2.0.0.Final
---
type: specs.openrewrite.org/v1beta/recipe
name: io.quarkus.jakarta-jaxrs-jaxb
Expand Down Expand Up @@ -316,6 +316,31 @@ recipeList:
artifactId: resteasy-json-p-provider
exclusionGroupId: jakarta.json
exclusionArtifactId: jakarta.json-api
- org.openrewrite.maven.RemoveExclusion:
groupId: org.apache.activemq
artifactId: artemis-server
exclusionGroupId: jakarta.json
exclusionArtifactId: jakarta.json-api
- org.openrewrite.maven.RemoveExclusion:
groupId: org.apache.activemq
artifactId: artemis-amqp-protocol
exclusionGroupId: jakarta.json
exclusionArtifactId: jakarta.json-api
- org.openrewrite.maven.RemoveExclusion:
groupId: org.eclipse
artifactId: yasson
exclusionGroupId: jakarta.json
exclusionArtifactId: jakarta.json-api
- org.openrewrite.maven.RemoveExclusion:
groupId: org.eclipse
artifactId: yasson
exclusionGroupId: org.glassfish
exclusionArtifactId: jakarta.json
- org.openrewrite.maven.RemoveExclusion:
groupId: jakarta.json.bind
artifactId: jakarta.json.bind-api
exclusionGroupId: jakarta.json
exclusionArtifactId: jakarta.json-api
---
type: specs.openrewrite.org/v1beta/recipe
name: io.quarkus.jakarta-json
Expand Down Expand Up @@ -652,7 +677,7 @@ recipeList:
newValue: 3.0
- org.openrewrite.maven.ChangePropertyValue:
key: resteasy-reactive-testsuite.repo.ref
newValue: c5785f3465fa87395574fde1274c1712b3aa728b
newValue: 4116f1a0c5605ad00d7779367dac8002af8c6882
---
type: specs.openrewrite.org/v1beta/recipe
name: io.quarkus.maven.javax.managed
Expand Down Expand Up @@ -826,10 +851,10 @@ displayName: Adjust Infinispan version and dependencies
recipeList:
- org.openrewrite.maven.ChangePropertyValue:
key: infinispan.version
newValue: 14.0.0.Dev04
newValue: 14.0.0.Final
- org.openrewrite.maven.ChangePropertyValue:
key: infinispan.protostream.version
newValue: 14.0.0.CR2
newValue: 4.5.0.Final
- org.openrewrite.maven.ChangeManagedDependencyGroupIdAndArtifactId:
oldGroupId: org.infinispan
oldArtifactId: infinispan-core
Expand All @@ -840,41 +865,24 @@ recipeList:
oldGroupId: org.infinispan
oldArtifactId: infinispan-client-hotrod
newGroupId: org.infinispan
newArtifactId: infinispan-client-hotrod
newClassifier: jakarta
newArtifactId: infinispan-client-hotrod-jakarta
- org.openrewrite.maven.ChangeManagedDependencyGroupIdAndArtifactId:
oldGroupId: org.infinispan
oldArtifactId: infinispan-commons
newGroupId: org.infinispan
newArtifactId: infinispan-commons
newClassifier: jakarta
newArtifactId: infinispan-commons-jakarta
- org.openrewrite.maven.ChangeDependencyGroupIdAndArtifactId:
oldGroupId: org.infinispan
oldArtifactId: infinispan-core
newGroupId: org.infinispan
newArtifactId: infinispan-core
newClassifier: jakarta
newArtifactId: infinispan-core-jakarta
- org.openrewrite.maven.ChangeDependencyGroupIdAndArtifactId:
oldGroupId: org.infinispan
oldArtifactId: infinispan-client-hotrod
newGroupId: org.infinispan
newArtifactId: infinispan-client-hotrod
newClassifier: jakarta
newArtifactId: infinispan-client-hotrod-jakarta
- org.openrewrite.maven.ChangeDependencyGroupIdAndArtifactId:
oldGroupId: org.infinispan
oldArtifactId: infinispan-commons
newGroupId: org.infinispan
newArtifactId: infinispan-commons
newClassifier: jakarta
---
type: specs.openrewrite.org/v1beta/recipe
name: io.quarkus.fix-infinispan-commons
displayName: Adjust Infinispan version and dependencies
recipeList:
- org.openrewrite.maven.ExcludeDependency:
groupId: org.infinispan
artifactId: infinispan-commons
- org.openrewrite.maven.AddDependencyNoQuestionsAsked:
groupId: org.infinispan
artifactId: infinispan-commons
classifier: jakarta
newArtifactId: infinispan-commons-jakarta
10 changes: 7 additions & 3 deletions jakarta/transform.sh
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,9 @@ sed -i 's@com.sun.xml.bind.v2.ContextFactory@org.glassfish.jaxb.runtime.v2.Conte
sed -i '/com.sun.xml.internal.bind.v2.ContextFactory/d' extensions/jaxb/deployment/src/main/java/io/quarkus/jaxb/deployment/JaxbProcessor.java

## JSON-P implementation switch
sed -i 's@<runnerParentFirstArtifact>org.glassfish:jakarta.json</runnerParentFirstArtifact>@<runnerParentFirstArtifact>org.eclipse.parsson:jakarta.json</runnerParentFirstArtifact>@g' extensions/logging-json/runtime/pom.xml
sed -i 's@<parentFirstArtifact>org.glassfish:jakarta.json</parentFirstArtifact>@<parentFirstArtifact>org.eclipse.parsson:jakarta.json</parentFirstArtifact>@g' extensions/jsonp/runtime/pom.xml
sed -i 's@<runnerParentFirstArtifact>org.glassfish:jakarta.json</runnerParentFirstArtifact>@<runnerParentFirstArtifact>org.eclipse.parsson:parsson</runnerParentFirstArtifact>\n <runnerParentFirstArtifact>jakarta.json:jakarta.json-api</runnerParentFirstArtifact>@g' extensions/logging-json/runtime/pom.xml
sed -i 's@<parentFirstArtifact>org.glassfish:jakarta.json</parentFirstArtifact>@<parentFirstArtifact>org.eclipse.parsson:parsson</parentFirstArtifact>@g' extensions/jsonp/runtime/pom.xml
sed -i 's@<excludedArtifact>org.glassfish:javax.json</excludedArtifact>@<excludedArtifact>org.glassfish:javax.json</excludedArtifact>\n <excludedArtifact>org.glassfish:jakarta.json</excludedArtifact>\n <excludedArtifact>org.eclipse.parsson:jakarta.json</excludedArtifact>@g' extensions/jsonp/runtime/pom.xml
sed -i 's@import org.glassfish.json.JsonProviderImpl;@import org.eclipse.parsson.JsonProviderImpl;@g' extensions/jsonp/deployment/src/main/java/io/quarkus/jsonp/deployment/JsonpProcessor.java

## cleanup phase - needs to be done once everything has been rewritten
Expand Down Expand Up @@ -299,6 +300,9 @@ sed -i 's@org.jboss.narayana.rts:narayana-lra@org.jboss.narayana.rts:narayana-lr
sed -i 's@org.jboss.narayana.rts:lra-client@org.jboss.narayana.rts:lra-client-jakarta@g' extensions/narayana-lra/runtime/pom.xml
sed -i 's@META-INF/services/javax.ws.rs.client.ClientBuilder@META-INF/services/jakarta.ws.rs.client.ClientBuilder@g' extensions/narayana-lra/runtime/pom.xml

find integration-tests/gradle -name build.gradle | xargs sed -i 's/javax.enterprise.context.ApplicationScoped/jakarta.enterprise.context.ApplicationScoped/g'
find integration-tests/gradle -name build.gradle | xargs sed -i 's/javax.ws.rs.Path/jakarta.ws.rs.Path/g'

transform_documentation
sed -i 's@javax/ws/rs@jakarta/ws/rs@g' docs/src/main/asciidoc/resteasy-reactive.adoc
sed -i 's@https://javadoc.io/doc/jakarta.ws.rs/jakarta.ws.rs-api/2.1.1@https://javadoc.io/doc/jakarta.ws.rs/jakarta.ws.rs-api/3.1.0@g' docs/src/main/asciidoc/resteasy-reactive.adoc
Expand Down Expand Up @@ -357,7 +361,7 @@ git cherry-pick -x ${JAKARTA_10_CDI_HASH}

## JAX-RS/RESTEasy Reactive
git fetch origin jakarta-10-jaxrs
git rev-list e466a63792db2e5d87eb0b662384618f16aaa419..origin/jakarta-10-jaxrs | tac | xargs git cherry-pick -x
git rev-list 1ac748346b91512957121e9b2f68c3b960c41565..origin/jakarta-10-jaxrs | tac | xargs git cherry-pick -x

# Build phase

Expand Down

0 comments on commit a237230

Please sign in to comment.