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 2022/12/13 18:33:46 UTC
[tomee-patch-plugin] 02/02: Reformat
This is an automated email from the ASF dual-hosted git repository.
dblevins pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomee-patch-plugin.git
commit 67fdfc16c695070ebcc0b88dacbb0149e84338fe
Author: David Blevins <db...@tomitribe.com>
AuthorDate: Tue Dec 13 10:33:29 2022 -0800
Reformat
---
.../apache/tomee/patch/core/Transformation.java | 11 +++++--
.../apache/tomee/patch/core/ExcludeJarsTest.java | 38 ++++++++++++----------
.../org/apache/tomee/patch/plugin/PatchMojo.java | 27 ++++++++++++---
3 files changed, 50 insertions(+), 26 deletions(-)
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 3cc2a39..02f6507 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,7 +28,12 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
@@ -138,9 +143,9 @@ public class Transformation {
if (path.endsWith(".class")) {
scanClass(zipInputStream, zipOutputStream);
} else if (isZip(path)) {
- if(isExcludedJar(path)){
+ if (isExcludedJar(path)) {
IO.copy(zipInputStream, zipOutputStream);
- }else{
+ } else {
scanJar(path, zipInputStream, zipOutputStream);
}
} else if (copyUnmodified(path)) {
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 719ba97..e13ff17 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
@@ -8,7 +8,9 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.zip.ZipEntry;
@@ -22,9 +24,9 @@ public class ExcludeJarsTest {
public Skips customSkips = new Skips();
@Before
- public void prepareLists(){
- customSkips.getJars().put("eclipselink-3.0.0.jar","org.eclipse.persistence:eclipselink:jar:3.0.0");
- customSkips.getJars().put("bcprov-jdk15on-1.69.jar","org.bouncycastle:bcprov-jdk15on:jar:1.69");
+ public void prepareLists() {
+ customSkips.getJars().put("eclipselink-3.0.0.jar", "org.eclipse.persistence:eclipselink:jar:3.0.0");
+ customSkips.getJars().put("bcprov-jdk15on-1.69.jar", "org.bouncycastle:bcprov-jdk15on:jar:1.69");
}
@Test
@@ -40,8 +42,8 @@ public class ExcludeJarsTest {
.add("README.txt", "hi")
.add(jarName, testJar).toJar();
- Transformation transformation = new Transformation(new ArrayList<Clazz>(), new File("does not exist"),null, customSkips, null, new NullLog(), false);
- File transformedJar = transformation.transformArchive(zipFile);
+ final Transformation transformation = new Transformation(new ArrayList<Clazz>(), new File("does not exist"), null, customSkips, null, new NullLog(), false);
+ final File transformedJar = transformation.transformArchive(zipFile);
assertTrue(obtainJarContent(transformedJar).contains(jarSignatureFileName));
}
@@ -59,31 +61,31 @@ public class ExcludeJarsTest {
.add("README.txt", "hi")
.add(jarName, testJar).toJar();
- Transformation transformation = new Transformation(new ArrayList<Clazz>(), new File("does not exist"),null, customSkips, null, new NullLog(), false);
- File transformedJar = transformation.transformArchive(zipFile);
+ final Transformation transformation = new Transformation(new ArrayList<Clazz>(), new File("does not exist"), null, customSkips, null, new NullLog(), false);
+ final File transformedJar = transformation.transformArchive(zipFile);
assertFalse(obtainJarContent(transformedJar).contains(jarSignatureFileName));
}
private List obtainJarContent(File transformedJar) throws IOException {
- List<String> jarFileList = new ArrayList<String>();
+ final List<String> jarFileList = new ArrayList<String>();
//Iterating over the zip files
- ZipFile zip = new ZipFile(transformedJar);
- Enumeration content = zip.entries();
+ final ZipFile zip = new ZipFile(transformedJar);
+ final Enumeration content = zip.entries();
for (Enumeration f = content; f.hasMoreElements(); ) {
- ZipEntry entry = (ZipEntry) f.nextElement();
+ final ZipEntry entry = (ZipEntry) f.nextElement();
//System.out.println(entry.getName());
if (entry.getName().endsWith(".jar")) {
//Iterating over the jar foun in the zip file
- File jar = new File(entry.getName());
- copyInputStreamToFile(zip.getInputStream(entry),jar);
- JarFile jarFile = new JarFile(jar);
- Enumeration innerEntries = jarFile.entries();
+ final File jar = new File(entry.getName());
+ copyInputStreamToFile(zip.getInputStream(entry), jar);
+ final JarFile jarFile = new JarFile(jar);
+ final Enumeration innerEntries = jarFile.entries();
for (Enumeration e = innerEntries; e.hasMoreElements(); ) {
- JarEntry file = (JarEntry) e.nextElement();
- //System.out.println(" - " +file.getName());
+ final JarEntry file = (JarEntry) e.nextElement();
+ //System.out.println(" - " +file.getName());
jarFileList.add(file.getName());
}
jarFile.close();
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 3133a04..3704053 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
@@ -27,7 +27,11 @@ import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.plugins.annotations.*;
+import org.apache.maven.plugins.annotations.Component;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.plugins.annotations.ResolutionScope;
import org.apache.maven.project.DefaultProjectBuildingRequest;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.ProjectBuildingRequest;
@@ -44,7 +48,13 @@ import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolver;
import org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolverException;
import org.apache.maven.toolchain.Toolchain;
import org.apache.maven.toolchain.ToolchainManager;
-import org.apache.tomee.patch.core.*;
+import org.apache.tomee.patch.core.Additions;
+import org.apache.tomee.patch.core.Clazz;
+import org.apache.tomee.patch.core.Is;
+import org.apache.tomee.patch.core.Replacements;
+import org.apache.tomee.patch.core.Skips;
+import org.apache.tomee.patch.core.Transformation;
+import org.apache.tomee.patch.core.ZipToTar;
import org.codehaus.plexus.compiler.Compiler;
import org.codehaus.plexus.compiler.CompilerConfiguration;
import org.codehaus.plexus.compiler.CompilerMessage;
@@ -55,7 +65,10 @@ import org.codehaus.plexus.util.StringUtils;
import org.tomitribe.jkta.usage.Dir;
import org.tomitribe.jkta.util.Paths;
import org.tomitribe.swizzle.stream.StreamBuilder;
-import org.tomitribe.util.*;
+import org.tomitribe.util.Files;
+import org.tomitribe.util.IO;
+import org.tomitribe.util.Mvn;
+import org.tomitribe.util.Zips;
import java.io.File;
import java.io.IOException;
@@ -63,9 +76,13 @@ import java.io.InputStream;
import java.io.UncheckedIOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
import java.util.function.Predicate;
-import java.util.function.Supplier;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;