Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
34 changes: 33 additions & 1 deletion src/main/resources/META-INF/rewrite/ibm-java.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ recipeList:
- org.openrewrite.java.migrate.JREDoNotUseSunNetSslInternalWwwProtocol
- org.openrewrite.java.migrate.JREDoNotUseSunNetSslInternalSslProvider
- org.openrewrite.java.migrate.JREDoNotUseSunNetSslAPIs
- org.openrewrite.java.migrate.RemovedJavaXMLWSModuleProvided
- org.openrewrite.java.migrate.RemovedJaxBModuleProvided

---
type: specs.openrewrite.org/v1beta/recipe
Expand Down Expand Up @@ -110,4 +112,34 @@ recipeList:
- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: com.ibm.security.auth.module.Krb5LoginModule
newFullyQualifiedTypeName: com.sun.security.auth.module.Krb5LoginModule
ignoreDefinition: true
ignoreDefinition: true
---
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.java.migrate.RemovedJavaXMLWSModuleProvided
displayName: Do not use `java.xml.ws` module in WebSphere Liberty
description:
The `java.xml.ws` module was removed in Java11. Websphere Liberty provides its own implementation of the module, which can be used by specifying the `jaxws-2.2` feature in the server.xml file.
This recipe removes the `javax.xml.ws` module from the application's build dependency in favor of the Websphere Liberty implementation to avoid class loading issues.
tags:
- java11
recipeList:
- org.openrewrite.java.dependencies.RemoveDependency:
groupId: javax.xml.ws
artifactId: jaxws-api
---
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.java.migrate.RemovedJaxBModuleProvided
displayName: Do not use `java.xml.bind` and `java.activation` modules in WebSphere Liberty
description:
The `java.xml.bind` and `java.activation` modules were removed in Java11.
Websphere Liberty provides its own implementation of the modules, which can be used by specifying the `jaxb-2.2` feature in the server.xml file.
This recipe removes the `javax.xml.bind` and `javax.activation` modules from the application's build dependency in favor of the Websphere Liberty implementation to avoid class loading issues.
tags:
- java11
recipeList:
- org.openrewrite.java.dependencies.RemoveDependency:
groupId: javax.xml.bind
artifactId: jaxb-api
- org.openrewrite.java.dependencies.RemoveDependency:
groupId: javax.activation
artifactId: activation
266 changes: 266 additions & 0 deletions src/test/java/org/openrewrite/java/migrate/IBMSemeruTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@
import org.openrewrite.test.RecipeSpec;
import org.openrewrite.test.RewriteTest;

import static org.openrewrite.gradle.Assertions.buildGradle;
import static org.openrewrite.gradle.toolingapi.Assertions.withToolingApi;
import static org.openrewrite.java.Assertions.java;
import static org.openrewrite.java.Assertions.version;
import static org.openrewrite.maven.Assertions.pomXml;


class IBMSemeruTest implements RewriteTest {
@Override
Expand Down Expand Up @@ -289,4 +293,266 @@ public boolean verify(String arg0, String arg1) {
), 6)
);
}

@Test
void removeMavenXMLWSModuleDependency() {
rewriteRun(
//language=xml
pomXml(
"""
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://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>com.mycom.myapp</groupId>
<artifactId>myapp</artifactId>
<version>2.0.0</version>
<packaging>war</packaging>
<name>MyApp</name>
<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.version>2.0.0</project.version>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.10.1</version>
</dependency>
<dependency>
<groupId>javax.xml.ws</groupId>
<artifactId>jaxws-api</artifactId>
<version>2.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<packagingExcludes>pom.xml, src/, target/, WebContent/</packagingExcludes>
<warSourceDirectory>WebContent</warSourceDirectory>
<webResources>
<resource>
<directory>src/main/resources</directory>
<targetPath>WEB-INF/classes</targetPath>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
</build>
</project>
""",
"""
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://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>com.mycom.myapp</groupId>
<artifactId>myapp</artifactId>
<version>2.0.0</version>
<packaging>war</packaging>
<name>MyApp</name>
<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.version>2.0.0</project.version>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.10.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<packagingExcludes>pom.xml, src/, target/, WebContent/</packagingExcludes>
<warSourceDirectory>WebContent</warSourceDirectory>
<webResources>
<resource>
<directory>src/main/resources</directory>
<targetPath>WEB-INF/classes</targetPath>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
</build>
</project>
"""
)
);
}

@Test
void gradleDependencyXMLWSModuleExclusion() {
rewriteRun(
spec -> spec.beforeRecipe(withToolingApi())
.recipeFromResource("/META-INF/rewrite/ibm-java.yml", "org.openrewrite.java.migrate.RemovedJavaXMLWSModuleProvided"),
//language=groovy
buildGradle(
"""
plugins {
id 'java-library'
}
repositories {
mavenCentral()
}
dependencies {
implementation("org.springframework.boot:spring-boot-starter-web:2.7.0") {
exclude group: "junit"
}
implementation("javax.xml.ws:jaxws-api:2.0")
testImplementation "org.junit.vintage:junit-vintage-engine:5.6.2"
}
""",
"""
plugins {
id 'java-library'
}
repositories {
mavenCentral()
}
dependencies {
implementation("org.springframework.boot:spring-boot-starter-web:2.7.0") {
exclude group: "junit"
}
testImplementation "org.junit.vintage:junit-vintage-engine:5.6.2"
}
"""
)
);
}

@Test
void removeMavenXMLJaxBModuleDependency() {
rewriteRun(
//language=xml
pomXml(
"""
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://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>com.mycom.myapp</groupId>
<artifactId>myapp</artifactId>
<version>2.0.0</version>
<packaging>war</packaging>
<name>MyApp</name>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.10.1</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1.1</version>
</dependency>
</dependencies>
</project>
""",
"""
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://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>com.mycom.myapp</groupId>
<artifactId>myapp</artifactId>
<version>2.0.0</version>
<packaging>war</packaging>
<name>MyApp</name>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.10.1</version>
</dependency>
</dependencies>
</project>
"""
)
);
}

@Test
void gradleDependencyXMLJaxBModuleExclusion() {
rewriteRun(
spec -> spec.beforeRecipe(withToolingApi())
.recipeFromResource("/META-INF/rewrite/ibm-java.yml", "org.openrewrite.java.migrate.RemovedJaxBModuleProvided"),
//language=groovy
buildGradle(
"""
plugins {
id 'java-library'
}
repositories {
mavenCentral()
}
dependencies {
implementation("org.springframework.boot:spring-boot-starter-web:2.7.0") {
exclude group: "junit"
}
implementation("javax.xml.bind:jaxb-api:2.3.1")
implementation("javax.activation:activation:1.1.1")
testImplementation "org.junit.vintage:junit-vintage-engine:5.6.2"
}
""",
"""
plugins {
id 'java-library'
}
repositories {
mavenCentral()
}
dependencies {
implementation("org.springframework.boot:spring-boot-starter-web:2.7.0") {
exclude group: "junit"
}
testImplementation "org.junit.vintage:junit-vintage-engine:5.6.2"
}
"""
)
);
}
}