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

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


The following commit(s) were added to refs/heads/main by this push:
     new a040d99  Allow Zip to Tar Allow to apply FileMode Use commons-compress 
to better handler extra data
a040d99 is described below

commit a040d99c2ded016a8ca7f8069bb36057dd4854e7
Author: Jean-Louis Monteiro <[email protected]>
AuthorDate: Fri Sep 5 10:49:32 2025 +0200

    Allow Zip to Tar
    Allow to apply FileMode
    Use commons-compress to better handler extra data
---
 tomee-patch-core/pom.xml                           |  19 +--
 .../apache/tomee/patch/core/ClassTransformer.java  |   2 +-
 .../java/org/apache/tomee/patch/core/FileMode.java |  89 +++++++++++++
 .../apache/tomee/patch/core/Transformation.java    | 143 ++++++++++++++-------
 .../java/org/apache/tomee/patch/core/ZipToTar.java |  13 +-
 .../tomee/patch/core/DontModifyJarsTest.java       |   3 +-
 .../apache/tomee/patch/core/ExcludeJarsTest.java   |   6 +-
 .../tomee/patch/core/MethodTransformerTest.java    |   2 +-
 .../org/apache/tomee/patch/core/ZipToTarTest.java  |   8 +-
 tomee-patch-plugin/pom.xml                         |  10 +-
 .../org/apache/tomee/patch/plugin/PatchMojo.java   |  17 ++-
 11 files changed, 245 insertions(+), 67 deletions(-)

diff --git a/tomee-patch-core/pom.xml b/tomee-patch-core/pom.xml
index 743ea58..8389a0b 100644
--- a/tomee-patch-core/pom.xml
+++ b/tomee-patch-core/pom.xml
@@ -29,32 +29,35 @@
   </parent>
 
   <artifactId>tomee-patch-core</artifactId>
+  <properties>
+    <dependency.asm.version>9.8</dependency.asm.version>
+  </properties>
 
   <dependencies>
     <dependency>
       <groupId>org.ow2.asm</groupId>
       <artifactId>asm</artifactId>
-      <version>8.0.1</version>
+      <version>${dependency.asm.version}</version>
     </dependency>
     <dependency>
       <groupId>org.ow2.asm</groupId>
       <artifactId>asm-tree</artifactId>
-      <version>8.0.1</version>
+      <version>${dependency.asm.version}</version>
     </dependency>
     <dependency>
       <groupId>org.ow2.asm</groupId>
       <artifactId>asm-analysis</artifactId>
-      <version>8.0.1</version>
+      <version>${dependency.asm.version}</version>
     </dependency>
     <dependency>
       <groupId>org.ow2.asm</groupId>
       <artifactId>asm-commons</artifactId>
-      <version>8.0.1</version>
+      <version>${dependency.asm.version}</version>
     </dependency>
     <dependency>
       <groupId>org.ow2.asm</groupId>
       <artifactId>asm-util</artifactId>
-      <version>8.0.1</version>
+      <version>${dependency.asm.version}</version>
     </dependency>
     <dependency>
       <groupId>org.tomitribe</groupId>
@@ -69,7 +72,7 @@
     <dependency>
       <groupId>org.tomitribe</groupId>
       <artifactId>tomitribe-util</artifactId>
-      <version>1.4.4</version>
+      <version>1.5.10</version>
     </dependency>
     <dependency>
       <groupId>org.tomitribe</groupId>
@@ -84,12 +87,12 @@
     <dependency>
       <groupId>org.apache.commons</groupId>
       <artifactId>commons-compress</artifactId>
-      <version>1.20</version>
+      <version>1.27.1</version>
     </dependency>
     <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
-      <version>4.10</version>
+      <version>4.13.2</version>
       <scope>test</scope>
     </dependency>
   </dependencies>
diff --git 
a/tomee-patch-core/src/main/java/org/apache/tomee/patch/core/ClassTransformer.java
 
b/tomee-patch-core/src/main/java/org/apache/tomee/patch/core/ClassTransformer.java
index ab1b775..9fd66a6 100644
--- 
a/tomee-patch-core/src/main/java/org/apache/tomee/patch/core/ClassTransformer.java
+++ 
b/tomee-patch-core/src/main/java/org/apache/tomee/patch/core/ClassTransformer.java
@@ -30,7 +30,7 @@ public class ClassTransformer extends ClassVisitor {
     private String className;
 
     public ClassTransformer(final ClassWriter classVisitor) {
-        super(Opcodes.ASM8, classVisitor);
+        super(Opcodes.ASM9, classVisitor);
     }
 
     @Override
diff --git 
a/tomee-patch-core/src/main/java/org/apache/tomee/patch/core/FileMode.java 
b/tomee-patch-core/src/main/java/org/apache/tomee/patch/core/FileMode.java
new file mode 100644
index 0000000..284761e
--- /dev/null
+++ b/tomee-patch-core/src/main/java/org/apache/tomee/patch/core/FileMode.java
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
+ *
+ *     http://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.apache.tomee.patch.core;
+
+import org.apache.commons.compress.archivers.zip.UnixStat;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Pattern;
+
+public class FileMode {
+
+    /**
+     * Java regex matched against the entry path inside the zip (forward 
slashes).
+     * Examples:
+     *  - ^bin/.*            (everything under bin/)
+     *  - ^bin/[^/]+$        (direct children of bin/)
+     *  - .*\.sh$            (all .sh files)
+     */
+    private String pattern;
+
+    /**
+     * File mode in octal string, e.g. "0755", "0644".
+     * We'll OR in the appropriate UnixStat FILE_FLAG or DIR_FLAG 
automatically.
+     */
+    private String mode;
+
+    public String getPattern() { return pattern; }
+    public void setPattern(final String pattern) { this.pattern = pattern; }
+
+    public String getMode() { return mode; }
+    public void setMode(final String mode) { this.mode = mode; }
+
+
+    public static class ModeOverride {
+        final Pattern pattern;
+        final int mode; // already parsed octal, e.g. 0755
+        ModeOverride(Pattern p, int m) { this.pattern = p; this.mode = m; }
+    }
+
+    public static List<ModeOverride> compileModeOverrides(final List<FileMode> 
rules) {
+        final List<ModeOverride> list = new ArrayList<>();
+        if (rules != null) {
+            for (final FileMode r : rules) {
+                if (r == null || r.getPattern() == null || r.getMode() == 
null) continue;
+                final Pattern p = Pattern.compile(r.getPattern());
+                final int mode = parseOctal(r.getMode().trim());
+                list.add(new ModeOverride(p, mode));
+            }
+        }
+        return list;
+    }
+
+    private static int parseOctal(final String s) {
+        // accept "755" or "0755"
+        return Integer.parseInt(s.startsWith("0") ? s.substring(1) : s, 8);
+    }
+
+    /** returns null if no override matches */
+    public static Integer overrideModeFor(final String path, final boolean 
directory, List<ModeOverride> modeOverrides) {
+        if (modeOverrides == null || modeOverrides.isEmpty()) return null;
+        for (final ModeOverride o : modeOverrides) {
+            if (o.pattern.matcher(path).matches()) {
+                // Apply the right file/dir flag; ignore any 
FILE_FLAG/DIR_FLAG the user might imply
+                return (directory ? UnixStat.DIR_FLAG : UnixStat.FILE_FLAG) | 
o.mode;
+            }
+        }
+        return null;
+    }
+
+    public static int normalizeDirMode(final int old) {
+        final int mode = (old != 0 ? old : UnixStat.DIR_FLAG | 0755);
+        return (mode & ~UnixStat.FILE_FLAG) | UnixStat.DIR_FLAG;
+    }
+}
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 02f6507..298f0fe 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
@@ -16,6 +16,10 @@
  */
 package org.apache.tomee.patch.core;
 
+import org.apache.commons.compress.archivers.zip.UnixStat;
+import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
+import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream;
+import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream;
 import org.objectweb.asm.ClassReader;
 import org.objectweb.asm.ClassWriter;
 import org.objectweb.asm.Opcodes;
@@ -24,6 +28,8 @@ import org.tomitribe.util.IO;
 import org.tomitribe.util.Mvn;
 import org.tomitribe.util.dir.Dir;
 
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
@@ -36,9 +42,6 @@ import java.util.Map;
 import java.util.Set;
 import java.util.regex.Pattern;
 import java.util.stream.Collectors;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipInputStream;
-import java.util.zip.ZipOutputStream;
 
 import static org.tomitribe.jkta.util.Predicates.not;
 
@@ -48,6 +51,7 @@ public class Transformation {
     private final Log log;
     private final Replacements replacements;
     private final Skips skips;
+    private final List<FileMode.ModeOverride> modeOverrides;
     private final Additions additions;
     private final Boolean skipTransform;
     private final File patchResources;
@@ -59,10 +63,12 @@ public class Transformation {
         this.additions = new Additions();
         this.skipTransform = false;
         this.patchResources = new File("does not exist");
+        this.modeOverrides = new ArrayList<>();
     }
 
 
-    public Transformation(final List<Clazz> classes, final File 
patchResources, final Replacements replacements, final Skips skips, final 
Additions additions, final Log log, final Boolean skipTransform) {
+    public Transformation(final List<Clazz> classes, final File 
patchResources, final Replacements replacements, final Skips skips,
+                          final List<FileMode> fileModes, final Additions 
additions, final Log log, final Boolean skipTransform) {
         this.classes.addAll(classes);
         this.log = log;
         this.replacements = replacements == null ? new Replacements() : 
replacements;
@@ -70,6 +76,7 @@ public class Transformation {
         this.additions = additions == null ? new Additions() : additions;
         this.patchResources = patchResources;
         this.skipTransform = skipTransform;
+        this.modeOverrides = FileMode.compileModeOverrides(fileModes);
     }
 
     public static File transform(final File jar) throws IOException {
@@ -108,17 +115,16 @@ public class Transformation {
 
         final Jar oldJar = Jar.enter(name);
         final Jar jar = Jar.current();
-        try {
-            final ZipInputStream zipInputStream = new 
ZipInputStream(inputStream);
-            final ZipOutputStream zipOutputStream = new 
ZipOutputStream(outputStream);
+        try (ZipArchiveInputStream zin = new 
ZipArchiveInputStream(inputStream);
+             ZipArchiveOutputStream zout = new 
ZipArchiveOutputStream(outputStream)) {
 
-            ZipEntry oldEntry;
-            while ((oldEntry = zipInputStream.getNextEntry()) != null) {
+            ZipArchiveEntry oldEntry;
+            while ((oldEntry = zin.getNextEntry()) != null) {
                 // TODO: the name may be changed in transformation
                 final String path = updatePath(oldEntry.getName());
 
                 if (skip(path)) {
-                    IO.copy(zipInputStream, skipped);
+                    IO.copy(zin, skipped);
                     continue;
                 }
 
@@ -128,33 +134,82 @@ public class Transformation {
                  */
                 if (isPatched(path, jar)) {
                     log.debug("Skipping class " + path);
-                    IO.copy(zipInputStream, skipped);
+                    IO.copy(zin, skipped);
+                    continue;
+                }
+
+                if (oldEntry.isDirectory()) {
+                    final ZipArchiveEntry dir = new 
ZipArchiveEntry(path.endsWith("/") ? path : path + "/");
+                    dir.setTime(oldEntry.getTime());
+                    int mode = normalizeDirMode(oldEntry.getUnixMode());
+                    final Integer override = FileMode.overrideModeFor(path, 
true, modeOverrides);
+                    if (override != null) {
+                        log.info(String.format("Overriding dir mode %o -> %o 
for %s", mode & 0777, override & 0777, path));
+                        mode = override;
+                    }
+                    dir.setUnixMode(mode);
+                    zout.putArchiveEntry(dir);
+                    zout.closeArchiveEntry();
                     continue;
                 }
 
 
-                final ZipEntry newEntry = new ZipEntry(path);
+                final ZipArchiveEntry newEntry = new ZipArchiveEntry(path);
 
-                //            copyAttributes(oldEntry, newEntry);
+                // copy attributes
+                newEntry.setTime(oldEntry.getTime());
+                newEntry.setComment(oldEntry.getComment());
 
-                zipOutputStream.putNextEntry(newEntry);
+                // compute base mode (fallback 0644 if missing)
+                int mode = oldEntry.getUnixMode();
+                if (mode == 0) {
+                    mode = UnixStat.FILE_FLAG | 0644;
+                }
+
+                // apply override if any
+                final Integer override = FileMode.overrideModeFor(path, false, 
modeOverrides);
+                if (override != null) {
+                    log.info(String.format("Overriding file mode %o -> %o for 
%s", mode & 0777, override & 0777, path));
+                    mode = override;
+                }
+                newEntry.setUnixMode(mode);
+
+                zout.putArchiveEntry(newEntry);
 
                 try {
                     if (path.endsWith(".class")) {
-                        scanClass(zipInputStream, zipOutputStream);
+                        scanClass(zin, zout);
                     } else if (isZip(path)) {
                         if (isExcludedJar(path)) {
-                            IO.copy(zipInputStream, zipOutputStream);
+                            IO.copy(zin, zout);
                         } else {
-                            scanJar(path, zipInputStream, zipOutputStream);
+                            // Read the inner entry fully first
+                            final ByteArrayOutputStream buf = new 
ByteArrayOutputStream(Math.max(32_768, (int) oldEntry.getSize()));
+                            IO.copy(zin, buf);
+                            final byte[] bytes = buf.toByteArray();
+
+                            try (ByteArrayInputStream innerIn = new 
ByteArrayInputStream(bytes);
+                                 ByteArrayOutputStream innerOut = new 
ByteArrayOutputStream(bytes.length)) {
+
+                                // Transform the inner archive into innerOut
+                                scanJar(path, innerIn, innerOut);
+
+                                // Write transformed inner archive to the 
current entry
+                                innerOut.writeTo(zout);
+
+                            } catch (IOException ex) {
+                                // Could not parse/transform (eg. corrupt 
inner JAR) -> copy raw as-is
+                                log.warn("Could not transform " + path + " (" 
+ ex.getMessage() + "), copying raw.");
+                                IO.copy(new ByteArrayInputStream(bytes), zout);
+                            }
                         }
                     } else if (copyUnmodified(path)) {
-                        IO.copy(zipInputStream, zipOutputStream);
+                        IO.copy(zin, zout);
                     } else {
-                        scanResource(path, zipInputStream, zipOutputStream);
+                        scanResource(path, zin, zout);
                     }
                 } finally {
-                    zipOutputStream.closeEntry();
+                    zout.closeArchiveEntry();
                 }
             }
 
@@ -164,13 +219,16 @@ public class Transformation {
                 for (final Clazz clazz : jar.getSkipped()) {
                     log.debug("Applying patch " + clazz.getName());
 
-                    final ZipEntry newEntry = new ZipEntry(clazz.getName());
-                    zipOutputStream.putNextEntry(newEntry);
+                    final ZipArchiveEntry newEntry = new 
ZipArchiveEntry(clazz.getName());
+                    zout.putArchiveEntry(newEntry);
 
-                    // Run any transformations on these classes as well
-                    IO.copy(IO.read(clazz.getFile()), zipOutputStream);
+                    try {
+                        // Run any transformations on these classes as well
+                        IO.copy(IO.read(clazz.getFile()), zout);
+                    } finally {
+                        zout.closeArchiveEntry();
 
-                    zipOutputStream.closeEntry();
+                    }
                     clazz.applied();
                 }
             }
@@ -189,17 +247,19 @@ public class Transformation {
                 for (final Resource resource : resources) {
                     log.info("Adding " + resource.getPath());
 
-                    final ZipEntry newEntry = new ZipEntry(resource.getPath());
-                    zipOutputStream.putNextEntry(newEntry);
+                    final ZipArchiveEntry newEntry = new 
ZipArchiveEntry(resource.getPath());
+                    zout.putArchiveEntry(newEntry);
 
-                    // Run any transformations on these classes as well
-                    IO.copy(IO.read(resource.getFile()), zipOutputStream);
-
-                    zipOutputStream.closeEntry();
+                    try {
+                        // Run any transformations on these classes as well
+                        IO.copy(IO.read(resource.getFile()), zout);
+                    } finally {
+                        zout.closeArchiveEntry();
+                    }
                 }
             }
 
-            zipOutputStream.finish();
+            zout.finish();
         } catch (IOException e) {
             throw new IOException(jar.getPath() + e.getMessage(), e);
         } finally {
@@ -216,6 +276,11 @@ public class Transformation {
         }
     }
 
+    private int normalizeDirMode(final int old) {
+        final int mode = (old != 0 ? old : UnixStat.DIR_FLAG | 0755);
+        return (mode & ~UnixStat.FILE_FLAG) | UnixStat.DIR_FLAG;
+    }
+
     public static class Resource {
         private final File file;
         private final String path;
@@ -437,17 +502,6 @@ public class Transformation {
         IO.copy(inputStream, outputStream);
     }
 
-    private static void copyAttributes(final ZipEntry oldEntry, final ZipEntry 
newEntry) {
-        Copy.copy(oldEntry, newEntry)
-                .att(ZipEntry::getTime, ZipEntry::setTime)
-                .att(ZipEntry::getComment, ZipEntry::setComment)
-                .att(ZipEntry::getExtra, ZipEntry::setExtra)
-                .att(ZipEntry::getMethod, ZipEntry::setMethod)
-                .att(ZipEntry::getCreationTime, ZipEntry::setCreationTime)
-                .att(ZipEntry::getLastModifiedTime, 
ZipEntry::setLastModifiedTime)
-                .att(ZipEntry::getLastAccessTime, ZipEntry::setLastAccessTime);
-    }
-
     private static boolean isZip(final String path) {
         return Is.Zip.accept(path);
     }
@@ -460,7 +514,7 @@ public class Transformation {
             return;
         }
 
-        final ClassWriter classWriter = new ClassWriter(Opcodes.ASM8);
+        final ClassWriter classWriter = new ClassWriter(Opcodes.ASM9);
         final ClassTransformer classTransformer = new 
ClassTransformer(classWriter);
         final ClassReader classReader = new ClassReader(in);
         classReader.accept(classTransformer, 0);
@@ -582,4 +636,5 @@ public class Transformation {
         public void write(final int b) {
         }
     };
+
 }
diff --git 
a/tomee-patch-core/src/main/java/org/apache/tomee/patch/core/ZipToTar.java 
b/tomee-patch-core/src/main/java/org/apache/tomee/patch/core/ZipToTar.java
index cd9bd53..576c4d1 100644
--- a/tomee-patch-core/src/main/java/org/apache/tomee/patch/core/ZipToTar.java
+++ b/tomee-patch-core/src/main/java/org/apache/tomee/patch/core/ZipToTar.java
@@ -18,19 +18,22 @@ package org.apache.tomee.patch.core;
 
 import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
 import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream;
+import org.apache.commons.compress.archivers.zip.UnixStat;
 import org.tomitribe.util.IO;
 
 import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.List;
 import java.util.zip.GZIPOutputStream;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipInputStream;
 
 public class ZipToTar {
 
-    public static File toTarGz(final File zip) throws Exception {
+    public static File toTarGz(final File zip, final List<FileMode> fileModes, 
final Log log) throws Exception {
+        final List<FileMode.ModeOverride> modeOverrides = 
FileMode.compileModeOverrides(fileModes);
 
         final String tarGzName = zip.getName().replaceAll("\\.(zip|jar)$", 
".tar.gz");
         final File tarGz = new File(zip.getParentFile(), tarGzName);
@@ -59,6 +62,14 @@ public class ZipToTar {
                 tarEntry.setSize(bytes.length);
                 tarEntry.setModTime(zipEntry.getLastModifiedTime().toMillis());
 
+                // compute base mode (fallback 0644 if missing)
+                int mode = UnixStat.FILE_FLAG | 0644;
+                final Integer override = FileMode.overrideModeFor(name, 
zip.isDirectory(), modeOverrides);
+                if (override != null) {
+                    log.info(String.format("Overriding file mode %o -> %o for 
%s", mode & 0777, override & 0777, name));
+                    tarEntry.setMode(override);
+                }
+
                 // Mark any shell scripts as executable
                 if (name.endsWith(".sh")) {
                     tarEntry.setMode(493);
diff --git 
a/tomee-patch-core/src/test/java/org/apache/tomee/patch/core/DontModifyJarsTest.java
 
b/tomee-patch-core/src/test/java/org/apache/tomee/patch/core/DontModifyJarsTest.java
index 721168d..e380d80 100644
--- 
a/tomee-patch-core/src/test/java/org/apache/tomee/patch/core/DontModifyJarsTest.java
+++ 
b/tomee-patch-core/src/test/java/org/apache/tomee/patch/core/DontModifyJarsTest.java
@@ -59,7 +59,8 @@ public class DontModifyJarsTest {
                 .add("README.txt", "hi")
                 .add(jarName, testJar).toJar();
 
-        Transformation transformation = new Transformation(new ArrayList<>(), 
new File("does not exist"), null, null, null, new NullLog(), skipTransform);
+        Transformation transformation = new Transformation(new ArrayList<>(), 
new File("does not exist"), null,
+                                                           null, null, null, 
new NullLog(), skipTransform);
         File transformedZip = transformation.transformArchive(zipFile);
 
         final String testJarHashTransformed = sha512FromJarInsideZip(jarName, 
transformedZip);
diff --git 
a/tomee-patch-core/src/test/java/org/apache/tomee/patch/core/ExcludeJarsTest.java
 
b/tomee-patch-core/src/test/java/org/apache/tomee/patch/core/ExcludeJarsTest.java
index e13ff17..e34f844 100644
--- 
a/tomee-patch-core/src/test/java/org/apache/tomee/patch/core/ExcludeJarsTest.java
+++ 
b/tomee-patch-core/src/test/java/org/apache/tomee/patch/core/ExcludeJarsTest.java
@@ -42,7 +42,8 @@ public class ExcludeJarsTest {
                 .add("README.txt", "hi")
                 .add(jarName, testJar).toJar();
 
-        final Transformation transformation = new Transformation(new 
ArrayList<Clazz>(), new File("does not exist"), null, customSkips, null, new 
NullLog(), false);
+        final Transformation transformation = new Transformation(new 
ArrayList<Clazz>(), new File("does not exist"), null,
+                                                                 customSkips, 
null, null, new NullLog(), false);
         final File transformedJar = transformation.transformArchive(zipFile);
         
assertTrue(obtainJarContent(transformedJar).contains(jarSignatureFileName));
     }
@@ -61,7 +62,8 @@ public class ExcludeJarsTest {
                 .add("README.txt", "hi")
                 .add(jarName, testJar).toJar();
 
-        final Transformation transformation = new Transformation(new 
ArrayList<Clazz>(), new File("does not exist"), null, customSkips, null, new 
NullLog(), false);
+        final Transformation transformation = new Transformation(new 
ArrayList<Clazz>(), new File("does not exist"), null, customSkips,
+                                                                 null, null, 
new NullLog(), false);
         final File transformedJar = transformation.transformArchive(zipFile);
         
assertFalse(obtainJarContent(transformedJar).contains(jarSignatureFileName));
     }
diff --git 
a/tomee-patch-core/src/test/java/org/apache/tomee/patch/core/MethodTransformerTest.java
 
b/tomee-patch-core/src/test/java/org/apache/tomee/patch/core/MethodTransformerTest.java
index 914d1f7..a65e175 100644
--- 
a/tomee-patch-core/src/test/java/org/apache/tomee/patch/core/MethodTransformerTest.java
+++ 
b/tomee-patch-core/src/test/java/org/apache/tomee/patch/core/MethodTransformerTest.java
@@ -214,7 +214,7 @@ public class MethodTransformerTest {
     @Test
     public void visitInvokeDynamicInsn_Direct() {
         final Usage usage = new Usage();
-        final MethodScanner methodScanner = new MethodScanner(Opcodes.ASM8, 
new BytecodeUsage(usage, Opcodes.ASM8));
+        final MethodScanner methodScanner = new MethodScanner(Opcodes.ASM9, 
new BytecodeUsage(usage, Opcodes.ASM9));
         methodScanner.visitInvokeDynamicInsn(
                 "accept",
                 "(Ljavax/ejb/Process;)Ljavax/jms/Consumer;",
diff --git 
a/tomee-patch-core/src/test/java/org/apache/tomee/patch/core/ZipToTarTest.java 
b/tomee-patch-core/src/test/java/org/apache/tomee/patch/core/ZipToTarTest.java
index b8a0c1a..f8a1dea 100644
--- 
a/tomee-patch-core/src/test/java/org/apache/tomee/patch/core/ZipToTarTest.java
+++ 
b/tomee-patch-core/src/test/java/org/apache/tomee/patch/core/ZipToTarTest.java
@@ -25,6 +25,7 @@ import org.tomitribe.util.PrintString;
 
 import java.io.File;
 import java.io.InputStream;
+import java.util.ArrayList;
 import java.util.zip.GZIPInputStream;
 
 import static org.junit.Assert.assertEquals;
@@ -42,7 +43,12 @@ public class ZipToTarTest {
                 .toJar();
 
 
-        final File tarGz = ZipToTar.toTarGz(zip);
+        final File tarGz = ZipToTar.toTarGz(zip, new ArrayList<>(), new 
NullLog() {
+            @Override
+            public void info(final CharSequence message) {
+                System.out.println(message);
+            }
+        });
 
         final PrintString out = new PrintString();
         {
diff --git a/tomee-patch-plugin/pom.xml b/tomee-patch-plugin/pom.xml
index 41c74e7..17f4469 100644
--- a/tomee-patch-plugin/pom.xml
+++ b/tomee-patch-plugin/pom.xml
@@ -32,10 +32,10 @@
   <packaging>maven-plugin</packaging>
 
   <properties>
-    <maven.version>3.2.2</maven.version>
+    <maven.version>3.3.9</maven.version>
     <maven-plugin.prefix>patch</maven-plugin.prefix>
-    <plexus-compiler.version>2.8.6</plexus-compiler.version>
-    <plexus-java.version>1.0.4</plexus-java.version>
+    <plexus-compiler.version>2.15.0</plexus-compiler.version>
+    <plexus-java.version>1.2.0</plexus-java.version>
     <doxiaVersion>1.9.1</doxiaVersion>
     <doxiaSiteVersion>1.9.2</doxiaSiteVersion>
     <jettyVersion>9.2.28.v20190418</jettyVersion>
@@ -56,7 +56,7 @@
     <dependency>
       <groupId>commons-io</groupId>
       <artifactId>commons-io</artifactId>
-      <version>2.6</version>
+      <version>2.19.0</version>
     </dependency>
     <dependency>
       <groupId>javax</groupId>
@@ -78,7 +78,7 @@
     <dependency>
       <groupId>org.apache.commons</groupId>
       <artifactId>commons-lang3</artifactId>
-      <version>3.8.1</version>
+      <version>3.17.0</version>
     </dependency>
     <dependency>
       <groupId>org.apache.maven.doxia</groupId>
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 3704053..08b7741 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
@@ -50,6 +50,7 @@ import org.apache.maven.toolchain.Toolchain;
 import org.apache.maven.toolchain.ToolchainManager;
 import org.apache.tomee.patch.core.Additions;
 import org.apache.tomee.patch.core.Clazz;
+import org.apache.tomee.patch.core.FileMode;
 import org.apache.tomee.patch.core.Is;
 import org.apache.tomee.patch.core.Replacements;
 import org.apache.tomee.patch.core.Skips;
@@ -185,6 +186,9 @@ public class PatchMojo extends AbstractMojo {
     @Parameter
     private Skips skips;
 
+    @Parameter
+    private List<FileMode> fileModes;
+
     @Parameter
     private Additions add;
 
@@ -272,6 +276,12 @@ public class PatchMojo extends AbstractMojo {
     @Parameter(property = "maven.compiler.target", defaultValue = "1.8")
     protected String target;
 
+    /**
+     * <p>The -release argument for the Java compiler.</p>
+     */
+    @Parameter(property = "maven.compiler.release")
+    protected String release;
+
     /**
      * The compiler id of the compiler to use. See this
      * <a href="non-javac-compilers.html">guide</a> for more information.
@@ -300,7 +310,8 @@ public class PatchMojo extends AbstractMojo {
 
             final List<Clazz> clazzes = classes();
 
-            final Transformation transformation = new Transformation(clazzes, 
patchResourceDirectory, replace, skips, add, new MavenLog(getLog()), 
skipTransform);
+            final Transformation transformation = new Transformation(clazzes, 
patchResourceDirectory, replace, skips,
+                                                                     
fileModes, add, new MavenLog(getLog()), skipTransform);
             for (final Artifact artifact : artifacts) {
                 final File file = artifact.getFile();
                 getLog().debug("Patching " + file.getAbsolutePath());
@@ -310,7 +321,7 @@ public class PatchMojo extends AbstractMojo {
                 if (createTarGz && file.getName().endsWith(".zip")) {
                     final File tarGz;
                     try {
-                        tarGz = ZipToTar.toTarGz(file);
+                        tarGz = ZipToTar.toTarGz(file, fileModes, new 
MavenLog(getLog()));
                     } catch (Exception e) {
                         getLog().error("Failed to create tar.gz from " + 
file.getAbsolutePath(), e);
                         continue;
@@ -527,9 +538,9 @@ public class PatchMojo extends AbstractMojo {
         compilerConfiguration.setShowWarnings(false);
         compilerConfiguration.setFailOnWarning(false);
         compilerConfiguration.setShowDeprecation(false);
+        compilerConfiguration.setReleaseVersion(release);
         compilerConfiguration.setSourceVersion(source);
         compilerConfiguration.setTargetVersion(target);
-        compilerConfiguration.setReleaseVersion(null);
         compilerConfiguration.setProc(null);
         
compilerConfiguration.setSourceLocations(Collections.singletonList(patchSourceDirectory.getAbsolutePath()));
         compilerConfiguration.setAnnotationProcessors(null);

Reply via email to