diff --git a/src/main/resources/META-INF/rewrite/java-version-11.yml b/src/main/resources/META-INF/rewrite/java-version-11.yml index ce4332d5c2..05f04cf6ed 100644 --- a/src/main/resources/META-INF/rewrite/java-version-11.yml +++ b/src/main/resources/META-INF/rewrite/java-version-11.yml @@ -37,6 +37,7 @@ recipeList: # Add an explicit JAXB/JAX-WS runtime and upgrade the dependencies to Jakarta EE 8 - org.openrewrite.java.migrate.javax.AddJaxbDependenciesWithRuntime - org.openrewrite.java.migrate.javax.AddJaxwsDependencies + - org.openrewrite.java.migrate.javax.MigrateJaxBWSPlugin - org.openrewrite.java.migrate.javax.AddInjectDependencies - org.openrewrite.java.migrate.javax.AddCommonAnnotationsDependencies # Remediate deprecations diff --git a/src/main/resources/META-INF/rewrite/jaxb-plugins.yml b/src/main/resources/META-INF/rewrite/jaxb-plugins.yml new file mode 100644 index 0000000000..ac042c88a0 --- /dev/null +++ b/src/main/resources/META-INF/rewrite/jaxb-plugins.yml @@ -0,0 +1,35 @@ +# +# Copyright 2025 the original author or authors. +#

+# Licensed under the Moderne Source Available License (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +#

+# https://docs.moderne.io/licensing/moderne-source-available-license +#

+# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +--- +type: specs.openrewrite.org/v1beta/recipe +name: org.openrewrite.java.migrate.javax.MigrateJaxBWSPlugin +displayName: Migrate JAXB-WS Plugin +description: Upgrade the JAXB-WS Maven plugin to be compatible with Java 11. +tags: + - java11 +recipeList: + - org.openrewrite.maven.ChangePluginGroupIdAndArtifactId: + oldGroupId: org.jvnet.jax-ws-commons + oldArtifactId: jaxws-maven-plugin + newGroupId: com.sun.xml.ws + newVersion: 2.3.7 + - org.openrewrite.xml.AddOrUpdateChildTag: + parentXPath: //plugin[artifactId='jaxws-maven-plugin']/executions/execution + newChildTag: generate-sources + - org.openrewrite.xml.ChangeTagName: + elementName: //plugin[artifactId='jaxws-maven-plugin']/executions/execution/configuration/nocompile + newName: xnocompile diff --git a/src/test/java/org/openrewrite/java/migrate/maven/MigrateJaxwsMavenPluginTest.java b/src/test/java/org/openrewrite/java/migrate/maven/MigrateJaxwsMavenPluginTest.java new file mode 100644 index 0000000000..e48aa3f92c --- /dev/null +++ b/src/test/java/org/openrewrite/java/migrate/maven/MigrateJaxwsMavenPluginTest.java @@ -0,0 +1,138 @@ +/* + * Copyright 2025 the original author or authors. + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * https://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.openrewrite.java.migrate.maven; + +import org.junit.jupiter.api.Test; +import org.openrewrite.DocumentExample; +import org.openrewrite.test.RecipeSpec; +import org.openrewrite.test.RewriteTest; + +import static org.openrewrite.maven.Assertions.pomXml; + +class MigrateJaxwsMavenPluginTest implements RewriteTest { + + @Override + public void defaults(RecipeSpec spec) { + spec.recipeFromResources("org.openrewrite.java.migrate.javax.MigrateJaxBWSPlugin"); + } + + @DocumentExample + @Test + void migrateJaxwsPluginFromJvnetToSunXmlWs() { + rewriteRun( + //language=xml + pomXml( + """ + + 4.0.0 + com.example + jaxws-service + 1.0.0 + + + + org.jvnet.jax-ws-commons + jaxws-maven-plugin + 2.1 + + + wsimport-from-jdk + + wsimport + + + ${project.build.directory}/generated-sources/wsimport + ${project.basedir}/src/main/resources/wsdl + + STSSAPPrimingService.wsdl + + org.example.generated + true + true + true + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.14.1 + + + + true + + + + + + + + """, + """ + + 4.0.0 + com.example + jaxws-service + 1.0.0 + + + + com.sun.xml.ws + jaxws-maven-plugin + 2.3.7 + + + wsimport-from-jdk + + wsimport + + + ${project.build.directory}/generated-sources/wsimport + ${project.basedir}/src/main/resources/wsdl + + STSSAPPrimingService.wsdl + + org.example.generated + true + true + true + + generate-sources + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.14.1 + + + + true + + + + + + + + """ + ) + ); + } +}