Links

Migrate xmlns entries in persistence.xml files

org.openrewrite.java.migrate.jakarta.JavaxPersistenceXmlToJakartaPersistenceXml Java EE has been rebranded to Jakarta EE, necessitating an XML namespace relocation.

Source

  • groupId: org.openrewrite.recipe
  • artifactId: rewrite-migrate-java
  • version: 1.16.0

Usage

This recipe has no required configuration options and can be activated directly after taking a dependency on org.openrewrite.recipe:rewrite-migrate-java:1.16.0 in your build file:
Gradle
Maven POM
Maven Command Line
build.gradle
plugins {
id("org.openrewrite.rewrite") version("5.34.0")
}
rewrite {
activeRecipe("org.openrewrite.java.migrate.jakarta.JavaxPersistenceXmlToJakartaPersistenceXml")
}
repositories {
mavenCentral()
}
dependencies {
rewrite("org.openrewrite.recipe:rewrite-migrate-java:1.16.0")
}
pom.xml
<project>
<build>
<plugins>
<plugin>
<groupId>org.openrewrite.maven</groupId>
<artifactId>rewrite-maven-plugin</artifactId>
<version>4.39.0</version>
<configuration>
<activeRecipes>
<recipe>org.openrewrite.java.migrate.jakarta.JavaxPersistenceXmlToJakartaPersistenceXml</recipe>
</activeRecipes>
</configuration>
<dependencies>
<dependency>
<groupId>org.openrewrite.recipe</groupId>
<artifactId>rewrite-migrate-java</artifactId>
<version>1.16.0</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
shell
mvn org.openrewrite.maven:rewrite-maven-plugin:4.39.0:run \
-Drewrite.recipeArtifactCoordinates=org.openrewrite.recipe:rewrite-migrate-java:1.16.0 \
-DactiveRecipes=org.openrewrite.java.migrate.jakarta.JavaxPersistenceXmlToJakartaPersistenceXml
Recipes can also be activated directly from the command line by adding the argument -Drewrite.activeRecipes=org.openrewrite.java.migrate.jakarta.JavaxPersistenceXmlToJakartaPersistenceXml

Definition

Recipe List
Yaml Recipe List
    • elementName: //property
    • attributeName: name
    • newValue: jakarta.persistence
    • oldValue: javax.persistence
    • fileMatcher: **/persistence.xml
    • elementName: persistence
    • attributeName: version
    • newValue: 3.0
    • fileMatcher: **/persistence.xml
    • elementName: persistence
    • attributeName: xmlns
    • newValue: https://jakarta.ee
    • oldValue: http://xmlns.jcp.org
    • fileMatcher: **/persistence.xml
    • elementName: persistence
    • attributeName: xsi:schemaLocation
    • newValue: https://jakarta.ee/xml/ns/persistence https://jakarta.ee/xml/ns/persistence/persistence_3_0.xsd
    • fileMatcher: **/persistence.xml
---
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.java.migrate.jakarta.JavaxPersistenceXmlToJakartaPersistenceXml
displayName: Migrate xmlns entries in `persistence.xml` files
description: Java EE has been rebranded to Jakarta EE, necessitating an XML namespace relocation.
recipeList:
- org.openrewrite.xml.ChangeTagAttribute:
elementName: //property
attributeName: name
newValue: jakarta.persistence
oldValue: javax.persistence
fileMatcher: **/persistence.xml
- org.openrewrite.xml.ChangeTagAttribute:
elementName: persistence
attributeName: version
newValue: 3.0
fileMatcher: **/persistence.xml
- org.openrewrite.xml.ChangeTagAttribute:
elementName: persistence
attributeName: xmlns
newValue: https://jakarta.ee
oldValue: http://xmlns.jcp.org
fileMatcher: **/persistence.xml
- org.openrewrite.xml.ChangeTagAttribute:
elementName: persistence
attributeName: xsi:schemaLocation
newValue: https://jakarta.ee/xml/ns/persistence https://jakarta.ee/xml/ns/persistence/persistence_3_0.xsd
fileMatcher: **/persistence.xml

See how this recipe works across multiple open-source repositories

Moderne Link Image
The Moderne public SaaS instance enables you to easily run recipes across thousands of open-source repositories.
Please contact Moderne for more information about safely running the recipes on your own codebase in a private SaaS.