Skip to content

Commit

Permalink
Create Jakarta variant of jaxb module
Browse files Browse the repository at this point in the history
Based on automatic rewriting the sources of the javax variant using
OpenRewrite rewrite-maven-plugin.
  • Loading branch information
runeflobakk committed Sep 2, 2024
1 parent c83f61a commit 665185f
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 0 deletions.
2 changes: 2 additions & 0 deletions bind-jakarta/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
src/main/java/no/posten/jakarta
src/main/java/no/posten/javax
102 changes: 102 additions & 0 deletions bind-jakarta/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,106 @@
<maven.compiler.release>11</maven.compiler.release>
</properties>

<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>digipost-xml-fundamentals</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<!--
This is a sort of hack to ensure the javax variant is built _before_ this
module in the Maven multimodule reactor, as this module uses the former
to generate its output. Maven does not have a "build time" scope (that I
know of at least?), so this is as close as we get. The dependency is "provided"
in the sense that it should not be included transitively in dependency resolution
from dependants of this library. It is also marked "optional" to remove it from
the dependency graph of dependants.
-->
<groupId>${project.groupId}</groupId>
<artifactId>digipost-xml-bind-javax</artifactId>
<version>${project.version}</version>
<optional>true</optional>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>4.0.2</version>
</dependency>
</dependencies>

<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<configuration>
<filesets>
<fileset>
<directory>src/main/java/no</directory>
</fileset>
</filesets>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>get-javax-sources</id>
<phase>generate-sources</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>${project.groupId}</groupId>
<artifactId>digipost-xml-bind-javax</artifactId>
<version>${project.version}</version>
<classifier>sources</classifier>
<includes>**/*.java</includes>
</artifactItem>
</artifactItems>
<outputDirectory>src/main/java</outputDirectory>
<skipDuringIncrementalBuild>true</skipDuringIncrementalBuild>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.openrewrite.maven</groupId>
<artifactId>rewrite-maven-plugin</artifactId>
<executions>
<execution>
<id>transform-to-jakarta-sources</id>
<phase>process-sources</phase>
<goals>
<goal>runNoFork</goal>
</goals>
<configuration>
<runPerSubmodule>true</runPerSubmodule>
<skipMavenParsing>true</skipMavenParsing>
<configLocation>src/main/rewrite.yml</configLocation>
<activeRecipes>
<recipe>org.openrewrite.java.migrate.jakarta.JavaxXmlBindMigrationToJakartaXmlBind</recipe>
<recipe>no.posten.ChangeJavaxPackageToJakarta</recipe>
</activeRecipes>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.openrewrite.recipe</groupId>
<artifactId>rewrite-migrate-java</artifactId>
<version>2.23.0</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>

</project>
8 changes: 8 additions & 0 deletions bind-jakarta/src/main/rewrite.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
type: specs.openrewrite.org/v1beta/recipe
name: no.posten.ChangeJavaxPackageToJakarta
displayName: Rename package to jakarta
recipeList:
- org.openrewrite.java.ChangePackage:
oldPackageName: no.posten.javax
newPackageName: no.posten.jakarta
recursive: true
10 changes: 10 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,16 @@
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.6.0</version>
</plugin>
<plugin>
<groupId>org.openrewrite.maven</groupId>
<artifactId>rewrite-maven-plugin</artifactId>
<version>5.39.2</version>
</plugin>
<plugin>
<groupId>com.mycila</groupId>
<artifactId>license-maven-plugin</artifactId>
Expand Down

0 comments on commit 665185f

Please sign in to comment.