You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by db...@apache.org on 2021/03/19 03:22:28 UTC

[tomee-patch-plugin] branch master updated (0deac80 -> 9c1f23a)

This is an automated email from the ASF dual-hosted git repository.

dblevins pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/tomee-patch-plugin.git.


    from 0deac80  [maven-release-plugin] prepare for next development iteration
     new fd3892c  Add the ability to replace resource files
     new 662c030  [maven-release-plugin] prepare release tomee-patch-parent-0.2
     new 9c1f23a  Merge branch 'master' of github.com:apache/tomee-patch-plugin

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 pom.xml                                            |  2 +-
 .../apache/tomee/patch/core/Transformation.java    | 23 ++++++++++++++++++----
 .../org/apache/tomee/patch/plugin/PatchMojo.java   |  5 ++++-
 3 files changed, 24 insertions(+), 6 deletions(-)

[tomee-patch-plugin] 02/03: [maven-release-plugin] prepare release tomee-patch-parent-0.2

Posted by db...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dblevins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomee-patch-plugin.git

commit 662c030b650dd59145ce8f5bb3687ac2f5eba48e
Author: David Blevins <da...@gmail.com>
AuthorDate: Thu Mar 18 20:19:06 2021 -0700

    [maven-release-plugin] prepare release tomee-patch-parent-0.2
---
 pom.xml                    | 4 ++--
 tomee-patch-core/pom.xml   | 2 +-
 tomee-patch-plugin/pom.xml | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index 854b3f8..49902f5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -32,7 +32,7 @@
   <groupId>org.apache.tomee.patch</groupId>
   <artifactId>tomee-patch-parent</artifactId>
   <packaging>pom</packaging>
-  <version>0.2-SNAPSHOT</version>
+  <version>0.2</version>
 
   <name>Apache TomEE Patch Plugin</name>
   <description>Tools and Maven Plugin to help complete the javax-to-jakarta bytecode transformation</description>
@@ -47,7 +47,7 @@
     <connection>scm:git:git@github.com:apache/tomee-patch-plugin.git</connection>
     <url>scm:git:git@github.com:apache/tomee-patch-plugin.git</url>
     <developerConnection>scm:git:git@github.com:apache/tomee-patch-plugin.git</developerConnection>
-    <tag>HEAD</tag>
+    <tag>tomee-patch-parent-0.2</tag>
   </scm>
 
   <issueManagement>
diff --git a/tomee-patch-core/pom.xml b/tomee-patch-core/pom.xml
index c20152b..b934f34 100644
--- a/tomee-patch-core/pom.xml
+++ b/tomee-patch-core/pom.xml
@@ -25,7 +25,7 @@
   <parent>
     <groupId>org.apache.tomee.patch</groupId>
     <artifactId>tomee-patch-parent</artifactId>
-    <version>0.2-SNAPSHOT</version>
+    <version>0.2</version>
   </parent>
 
   <artifactId>tomee-patch-core</artifactId>
diff --git a/tomee-patch-plugin/pom.xml b/tomee-patch-plugin/pom.xml
index 756a1a6..a108d5e 100644
--- a/tomee-patch-plugin/pom.xml
+++ b/tomee-patch-plugin/pom.xml
@@ -25,7 +25,7 @@
   <parent>
     <groupId>org.apache.tomee.patch</groupId>
     <artifactId>tomee-patch-parent</artifactId>
-    <version>0.2-SNAPSHOT</version>
+    <version>0.2</version>
   </parent>
 
   <artifactId>tomee-patch-plugin</artifactId>

[tomee-patch-plugin] 03/03: Merge branch 'master' of github.com:apache/tomee-patch-plugin

Posted by db...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dblevins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomee-patch-plugin.git

commit 9c1f23a87b735c687416cb493a1088ce82d239f5
Merge: 662c030 0deac80
Author: David Blevins <da...@gmail.com>
AuthorDate: Thu Mar 18 20:21:53 2021 -0700

    Merge branch 'master' of github.com:apache/tomee-patch-plugin

 pom.xml                    | 2 +-
 tomee-patch-core/pom.xml   | 2 +-
 tomee-patch-plugin/pom.xml | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)


[tomee-patch-plugin] 01/03: Add the ability to replace resource files

Posted by db...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dblevins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomee-patch-plugin.git

commit fd3892c245a9de70fa7785c82019272107ea8f2a
Author: David Blevins <da...@gmail.com>
AuthorDate: Thu Mar 18 20:17:14 2021 -0700

    Add the ability to replace resource files
---
 pom.xml                                            |  2 +-
 tomee-patch-core/pom.xml                           |  2 +-
 .../apache/tomee/patch/core/Transformation.java    | 23 ++++++++++++++++++----
 tomee-patch-plugin/pom.xml                         |  2 +-
 .../org/apache/tomee/patch/plugin/PatchMojo.java   |  5 ++++-
 5 files changed, 26 insertions(+), 8 deletions(-)

diff --git a/pom.xml b/pom.xml
index d9ceb64..854b3f8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -32,7 +32,7 @@
   <groupId>org.apache.tomee.patch</groupId>
   <artifactId>tomee-patch-parent</artifactId>
   <packaging>pom</packaging>
-  <version>0.1-SNAPSHOT</version>
+  <version>0.2-SNAPSHOT</version>
 
   <name>Apache TomEE Patch Plugin</name>
   <description>Tools and Maven Plugin to help complete the javax-to-jakarta bytecode transformation</description>
diff --git a/tomee-patch-core/pom.xml b/tomee-patch-core/pom.xml
index 5a12ccb..c20152b 100644
--- a/tomee-patch-core/pom.xml
+++ b/tomee-patch-core/pom.xml
@@ -25,7 +25,7 @@
   <parent>
     <groupId>org.apache.tomee.patch</groupId>
     <artifactId>tomee-patch-parent</artifactId>
-    <version>0.1-SNAPSHOT</version>
+    <version>0.2-SNAPSHOT</version>
   </parent>
 
   <artifactId>tomee-patch-core</artifactId>
diff --git a/tomee-patch-core/src/main/java/org/apache/tomee/patch/core/Transformation.java b/tomee-patch-core/src/main/java/org/apache/tomee/patch/core/Transformation.java
index 12d1480..2625c5a 100644
--- a/tomee-patch-core/src/main/java/org/apache/tomee/patch/core/Transformation.java
+++ b/tomee-patch-core/src/main/java/org/apache/tomee/patch/core/Transformation.java
@@ -28,8 +28,10 @@ import java.io.InputStream;
 import java.io.OutputStream;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 import java.util.stream.Collectors;
 import java.util.zip.ZipEntry;
@@ -42,15 +44,18 @@ public class Transformation {
 
     private final List<Clazz> classes = new ArrayList<Clazz>();
     private final Log log;
+    private final Map<String, String> replacements;
 
     public Transformation() {
         this.log = new NullLog();
+        this.replacements = Collections.EMPTY_MAP;
     }
 
 
-    public Transformation(final List<Clazz> classes, final Log log) {
+    public Transformation(final List<Clazz> classes, final Map<String, String> replacements, final Log log) {
         this.classes.addAll(classes);
         this.log = log;
+        this.replacements = replacements;
     }
 
     public static File transform(final File jar) throws IOException {
@@ -85,7 +90,7 @@ public class Transformation {
                     IO.copy(zipInputStream, skipped);
                     continue;
                 }
-                
+
                 /*
                  * If this entry has been patched, skip it
                  * We will add the patched version at the end
@@ -154,9 +159,9 @@ public class Transformation {
         }
         return false;
     }
-    
+
     private String updatePath(final String name) {
-        return name.replace("resources/javax.faces","resources/jakarta.faces");
+        return name.replace("resources/javax.faces", "resources/jakarta.faces");
     }
 
     private boolean copyUnmodified(final String path) {
@@ -210,6 +215,16 @@ public class Transformation {
                 .replace("javax.xml.ws", "jakarta.xml.ws")
                 .replace("javax\\.faces", "jakarta\\.faces") // in some javascript files
                 .get();
+
+        {
+            final String name = new File(path).getName();
+            final String replacement = replacements.get(name);
+            if (replacement != null) {
+                log.debug(String.format("Replaced %s with %s", path, replacement));
+                inputStream = IO.read(new File(replacement));
+            }
+        }
+        
         IO.copy(inputStream, outputStream);
     }
 
diff --git a/tomee-patch-plugin/pom.xml b/tomee-patch-plugin/pom.xml
index 2d7ff90..756a1a6 100644
--- a/tomee-patch-plugin/pom.xml
+++ b/tomee-patch-plugin/pom.xml
@@ -25,7 +25,7 @@
   <parent>
     <groupId>org.apache.tomee.patch</groupId>
     <artifactId>tomee-patch-parent</artifactId>
-    <version>0.1-SNAPSHOT</version>
+    <version>0.2-SNAPSHOT</version>
   </parent>
 
   <artifactId>tomee-patch-plugin</artifactId>
diff --git a/tomee-patch-plugin/src/main/java/org/apache/tomee/patch/plugin/PatchMojo.java b/tomee-patch-plugin/src/main/java/org/apache/tomee/patch/plugin/PatchMojo.java
index a74eb2e..c76ab47 100644
--- a/tomee-patch-plugin/src/main/java/org/apache/tomee/patch/plugin/PatchMojo.java
+++ b/tomee-patch-plugin/src/main/java/org/apache/tomee/patch/plugin/PatchMojo.java
@@ -86,6 +86,9 @@ public class PatchMojo extends AbstractMojo {
     @Parameter
     private Map<String, String> jdkToolchain;
 
+    @Parameter
+    private Map<String, String> replacements;
+
     /**
      * Sets the executable of the compiler to use when fork is <code>true</code>.
      */
@@ -171,7 +174,7 @@ public class PatchMojo extends AbstractMojo {
 
             final List<Clazz> clazzes = classes();
 
-            final Transformation transformation = new Transformation(clazzes, new MavenLog(getLog()));
+            final Transformation transformation = new Transformation(clazzes, replacements, new MavenLog(getLog()));
             for (final Artifact artifact : artifacts) {
                 final File file = artifact.getFile();
                 getLog().debug("Patching " + file.getAbsolutePath());