From dfd3d599271d52c5820c42ca62a5b6a25cb5fc0e Mon Sep 17 00:00:00 2001 From: radomir Date: Sun, 7 Sep 2014 22:26:32 +0200 Subject: [PATCH 1/6] Improves war processing --- pom.xml | 8 +- .../wvengen/maven/proguard/ProGuardMojo.java | 243 +++++++++++++++--- 2 files changed, 218 insertions(+), 33 deletions(-) diff --git a/pom.xml b/pom.xml index bf929d2f..1a6fe44b 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ com.github.wvengen - proguard-maven-plugin + proguard-war-maven-plugin proguard-maven-plugin 2.0.9-SNAPSHOT maven-plugin @@ -84,6 +84,12 @@ 3.1.1 + + org.codehaus.plexus + plexus-utils + 1.5.15 + + diff --git a/src/main/java/com/github/wvengen/maven/proguard/ProGuardMojo.java b/src/main/java/com/github/wvengen/maven/proguard/ProGuardMojo.java index eeb5af80..3fdb9b8c 100644 --- a/src/main/java/com/github/wvengen/maven/proguard/ProGuardMojo.java +++ b/src/main/java/com/github/wvengen/maven/proguard/ProGuardMojo.java @@ -32,10 +32,14 @@ import org.apache.maven.project.MavenProjectHelper; import org.apache.tools.ant.DefaultLogger; import org.apache.tools.ant.Project; +import org.apache.tools.ant.Target; +import org.apache.tools.ant.taskdefs.Expand; import org.apache.tools.ant.taskdefs.Java; import org.codehaus.plexus.archiver.jar.JarArchiver; import java.io.File; +import java.io.FilenameFilter; +import java.io.IOException; import java.net.URL; import java.util.*; @@ -258,6 +262,14 @@ public class ProGuardMojo extends AbstractMojo { */ protected String proguardMainClass = "proguard.ProGuard"; + /** + * Specifies whether or not to pass war's WEB-INF/classes/ directory to Proguard. + * + * @parameter default-value="true" + */ + private boolean processWarClassesDir = true; + + private Log log; /** @@ -297,6 +309,35 @@ public void execute() throws MojoExecutionException, MojoFailureException { } } + // check and extract war + boolean processingWar = false; + boolean mainIsWar = mavenProject.getPackaging().equals("war"); + File expandedDir = null; + File priorityLibsDir = null; + if (mainIsWar) { + processingWar = injar.endsWith(".war"); + if (processingWar) { + expandedDir = (new File(outputDirectory, nameNoType(injar) + "_war_proguard_expanded")).getAbsoluteFile(); + if (expandedDir.exists()) { + if (!deleteFileOrDirectory(expandedDir)) { + throw new MojoFailureException("Can't delete " + expandedDir); + } + } + if (!expandedDir.mkdirs()) { + throw new MojoFailureException("Can't create " + outputDirectory); + } + + try { + unzip(inJarFile, expandedDir); + } catch (IOException e) { + throw new MojoFailureException("Can't extract " + inJarFile, e); + } + + priorityLibsDir = new File(expandedDir, "WEB-INF/lib"); + } + } + + if (!outputDirectory.exists()) { if (!outputDirectory.mkdirs()) { throw new MojoFailureException("Can't create " + outputDirectory); @@ -314,7 +355,20 @@ public void execute() throws MojoExecutionException, MojoFailureException { outjar += "." + attachArtifactType; } - if ((outjar != null) && (!outjar.equals(injar))) { + if (processingWar) { + // When processing war, we update outJarFile to point to proguarded jar + if (outjar == null) { + outjar = injar; + } + String outJarName = nameNoType(outjar) + ".jar"; + outJarFile = (new File(priorityLibsDir, outJarName)).getAbsoluteFile(); + if (outJarFile.exists()) { + if (!deleteFileOrDirectory(outJarFile)) { + throw new MojoFailureException("Can't delete " + outJarFile); + } + } + sameArtifact = (outjar != null) && (!outjar.equals(injar)); + } else if ((outjar != null) && (!outjar.equals(injar))) { sameArtifact = false; outJarFile = (new File(outputDirectory, outjar)).getAbsoluteFile(); if (outJarFile.exists()) { @@ -366,40 +420,73 @@ public void execute() throws MojoExecutionException, MojoFailureException { } } + Set inFiles = new HashSet(); + + if (processingWar) { + File classesDir = new File(expandedDir, "WEB-INF/classes"); + if (processWarClassesDir) { + File classesDirInput = new File(expandedDir, "WEB-INF/classes_input"); + classesDir.renameTo(classesDirInput); + + args.add("-injars"); + args.add(fileToString(classesDirInput)); + inFiles.add(classesDirInput); + + // class files are processes separately! + args.add("-outjars"); + args.add(fileToString(classesDir)); + + } else { + args.add("-libraryjars"); + args.add(fileToString(classesDir)); + } + } + Set inPath = new HashSet(); boolean hasInclusionLibrary = false; if (assembly != null) { - for (Iterator iter = assembly.inclusions.iterator(); iter.hasNext();) { + for (Iterator iter = assembly.inclusions.iterator(); iter.hasNext(); ) { Inclusion inc = (Inclusion) iter.next(); - if (!inc.library) { - File file = getClasspathElement(getDependancy(inc, mavenProject), mavenProject); - inPath.add(file.toString()); - log.debug("--- ADD injars:" + inc.artifactId); - StringBuffer filter = new StringBuffer(fileToString(file)); - filter.append("(!META-INF/MANIFEST.MF"); - if (!addMavenDescriptor) { - filter.append(","); - filter.append("!META-INF/maven/**"); - } - if (inc.filter != null) { - filter.append(",").append(inc.filter); + Set deps = getDependancies(inc, mavenProject); // get all matching dependencies and wildcard may have been used + for (Artifact artifact : deps) { + if (!inc.library) { + File file = getClasspathElement(artifact, mavenProject, priorityLibsDir); + if (processingWar && "*".equals(inc.artifactId) && !priorityLibsDir.equals(file.getParentFile())) { + log.debug("Wildcard matching artifact will be included as a library (as does not belong to enclosed libs): " + file); + inPath.add(file.toString()); + args.add("-libraryjars"); + args.add(fileToString(file)); + continue; + } + inPath.add(file.toString()); + log.debug("--- ADD injars:" + inc.artifactId); + StringBuffer filter = new StringBuffer(fileToString(file)); + filter.append("(!META-INF/MANIFEST.MF"); + if (!addMavenDescriptor) { + filter.append(","); + filter.append("!META-INF/maven/**"); + } + if (inc.filter != null) { + filter.append(",").append(inc.filter); + } + filter.append(")"); + inFiles.add(file); + args.add("-injars"); + args.add(filter.toString()); + } else { + hasInclusionLibrary = true; + log.debug("--- ADD libraryjars:" + inc.artifactId); + // This may not be CompileArtifacts, maven 2.0.6 bug + File file = getClasspathElement(artifact, mavenProject, priorityLibsDir); + inPath.add(file.toString()); + args.add("-libraryjars"); + args.add(fileToString(file)); } - filter.append(")"); - args.add("-injars"); - args.add(filter.toString()); - } else { - hasInclusionLibrary = true; - log.debug("--- ADD libraryjars:" + inc.artifactId); - // This may not be CompileArtifacts, maven 2.0.6 bug - File file = getClasspathElement(getDependancy(inc, mavenProject), mavenProject); - inPath.add(file.toString()); - args.add("-libraryjars"); - args.add(fileToString(file)); } } } - if (inJarFile.exists()) { + if (inJarFile.exists() && !processingWar) { args.add("-injars"); StringBuffer filter = new StringBuffer(fileToString(inJarFile)); if ((inFilter != null) || (!addMavenDescriptor)) { @@ -432,7 +519,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { if (isExclusion(artifact)) { continue; } - File file = getClasspathElement(artifact, mavenProject); + File file = getClasspathElement(artifact, mavenProject, priorityLibsDir); if (inPath.contains(file.toString())) { log.debug("--- ignore library since one in injar:" + artifact.getArtifactId()); @@ -440,11 +527,11 @@ public void execute() throws MojoExecutionException, MojoFailureException { } if(includeDependencyInjar){ log.debug("--- ADD library as injars:" + artifact.getArtifactId()); + inFiles.add(file); args.add("-injars"); } else { log.debug("--- ADD libraryjars:" + artifact.getArtifactId()); args.add("-libraryjars"); - } args.add(fileToString(file)); } @@ -453,7 +540,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { if (args.contains("-injars")) { args.add("-outjars"); args.add(fileToString(outJarFile)); - } + } if (!obfuscate) { args.add("-dontobfuscate"); @@ -493,9 +580,25 @@ public void execute() throws MojoExecutionException, MojoFailureException { } } - log.info("execute ProGuard " + args.toString()); + log.debug("Run Proguard with options" + args.toString()); proguardMain(getProguardJar(this), args, this); + if (processingWar) { + for (File f : inFiles) { + if (f.isDirectory()) { + log.info("Removing proguarded: " + f); + if (!deleteFileOrDirectory(f)) { + throw new MojoFailureException("Can't delete " + f); + } + } else if (priorityLibsDir.equals(f.getParentFile())) { + log.info("Removing proguarded: " + f); + if (!deleteFileOrDirectory(f)) { + throw new MojoFailureException("Can't delete " + f); + } + } + } + } + if ((assembly != null) && (hasInclusionLibrary)) { log.info("creating assembly"); @@ -524,7 +627,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { if (inc.library) { File file; Artifact artifact = getDependancy(inc, mavenProject); - file = getClasspathElement(artifact, mavenProject); + file = getClasspathElement(artifact, mavenProject, priorityLibsDir); if (file.isDirectory()) { getLog().info("merge project: " + artifact.getArtifactId() + " " + file); jarArchiver.addDirectory(file); @@ -537,12 +640,36 @@ public void execute() throws MojoExecutionException, MojoFailureException { archiver.createArchive(mavenProject, archive); + // delete baseFile right away so we don't include it in war + if (!baseFile.delete()) { + throw new MojoFailureException("Can't delete " + baseFile); + } + } catch (Exception e) { throw new MojoExecutionException("Unable to create jar", e); } } + if (processingWar) { + File outputWar = new File(outputDirectory, outjar); + if (outputWar.exists()) { + if (!outputWar.delete()) { + throw new MojoFailureException("Can't delete " + outputWar); + } + } + MavenArchiver archiver = new MavenArchiver(); + archiver.setArchiver(jarArchiver); + archiver.setOutputFile(outputWar); + archive.setAddMavenDescriptor(addMavenDescriptor); + try { + jarArchiver.addDirectory(expandedDir); + archiver.createArchive(mavenProject, archive); + } catch (Exception e) { + throw new MojoExecutionException("Unable to create war", e); + } + } + if (attach && !sameArtifact) { if (useArtifactClassifier()) { projectHelper.attachArtifact(mavenProject, attachArtifactType, attachArtifactClassifier, outJarFile); @@ -675,6 +802,20 @@ private static boolean deleteFileOrDirectory(File path) throws MojoFailureExcept } + private static Set getDependancies(Inclusion inc, MavenProject mavenProject) throws MojoExecutionException { + Set dependancy = mavenProject.getArtifacts(); + Set deps = new HashSet(); + for (Iterator i = dependancy.iterator(); i.hasNext(); ) { + Artifact artifact = (Artifact) i.next(); + if (inc.match(artifact)) { + deps.add(artifact); + } + } + if (deps.size() == 0) + throw new MojoExecutionException("artifactId Not found " + inc.artifactId); + return deps; + } + private static Artifact getDependancy(Inclusion inc, MavenProject mavenProject) throws MojoExecutionException { Set dependancy = mavenProject.getArtifacts(); for (Iterator i = dependancy.iterator(); i.hasNext();) { @@ -699,7 +840,7 @@ private boolean isExclusion(Artifact artifact) { return false; } - private static File getClasspathElement(Artifact artifact, MavenProject mavenProject) throws MojoExecutionException { + private static File getClasspathElement(Artifact artifact, MavenProject mavenProject, File libsDir) throws MojoExecutionException { if (artifact.getClassifier() != null) { return artifact.getFile(); } @@ -708,6 +849,25 @@ private static File getClasspathElement(Artifact artifact, MavenProject mavenPro if (project != null) { return new File(project.getBuild().getOutputDirectory()); } else { + + if (libsDir != null) { + final String filenameBase = artifact.getArtifactId() + "-"; + File[] artifactFilesInLib = libsDir.listFiles(new FilenameFilter() { + public boolean accept(File dir, String name) { + if (name.startsWith(filenameBase) && name.length() > filenameBase.length() + 4) { + // check if the first char after base name is a digit (assuming version number) + boolean digitFound = Character.isDigit(name.charAt(filenameBase.length())); + return digitFound; + } + return false; + } + }); + if (artifactFilesInLib.length > 1) + System.out.println("Warn: Found more than one library for artifact " + artifact + ": " + artifactFilesInLib); + if (artifactFilesInLib.length > 0) + return artifactFilesInLib[0]; + } + File file = artifact.getFile(); if ((file == null) || (!file.exists())) { throw new MojoExecutionException("Dependency Resolution Required " + artifact); @@ -715,4 +875,23 @@ private static File getClasspathElement(Artifact artifact, MavenProject mavenPro return file; } } + + /** + * Unzips archive from the given path to the given destination dir. + */ + private static void unzip(File archiveFile, File destDir) throws IOException, MojoFailureException { + final class Expander extends Expand { + public Expander() { + project = new Project(); + project.init(); + taskType = "unzip"; + taskName = "unzip"; + target = new Target(); + } + } + Expander expander = new Expander(); + expander.setSrc(archiveFile); + expander.setDest(destDir); + expander.execute(); + } } From bb08983dda148772768b3a100eb4d421d0eb663e Mon Sep 17 00:00:00 2001 From: radomir Date: Sun, 7 Sep 2014 22:35:23 +0200 Subject: [PATCH 2/6] Updated groupId+artifactId and other project references in pom --- pom.xml | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index 1a6fe44b..fc9bb515 100644 --- a/pom.xml +++ b/pom.xml @@ -9,14 +9,14 @@ - com.github.wvengen - proguard-war-maven-plugin + com.github.radomirml + proguard-maven-plugin proguard-maven-plugin 2.0.9-SNAPSHOT maven-plugin Maven 2 Plugin for ProGuard - http://github.com/wvengen/proguard-maven-plugin + http://github.com/radomirml/proguard-maven-plugin @@ -26,16 +26,21 @@ - http://github.com/wvengen/proguard-maven-plugin - scm:git:git://github.com/wvengen/proguard-maven-plugin.git + http://github.com/radomirml/proguard-maven-plugin + scm:git:git://github.com/radomirml/proguard-maven-plugin.git GitHub - https://github.com/wvengen/proguard-maven-plugin/issues + https://github.com/radomirml/proguard-maven-plugin/issues + + radomirml + radomirml + radomirml@gmail.com + wvengen wvengen From 543798484daaa61742270a32af0f77f06113f219 Mon Sep 17 00:00:00 2001 From: radomir Date: Sun, 7 Sep 2014 22:49:26 +0200 Subject: [PATCH 3/6] Support for output filter --- .../wvengen/maven/proguard/ProGuardMojo.java | 53 +++++++++++-------- 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/github/wvengen/maven/proguard/ProGuardMojo.java b/src/main/java/com/github/wvengen/maven/proguard/ProGuardMojo.java index 3fdb9b8c..35abf240 100644 --- a/src/main/java/com/github/wvengen/maven/proguard/ProGuardMojo.java +++ b/src/main/java/com/github/wvengen/maven/proguard/ProGuardMojo.java @@ -166,6 +166,13 @@ public class ProGuardMojo extends AbstractMojo { */ protected String outjar; + /** + * Apply ProGuard classpathentry Filters to output jar. e.g. !**.gif,!**/tests/**' + * + * @parameter + */ + protected String outFilter; + /** * Specifies whether or not to attach the created artifact to the project * @@ -488,26 +495,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { if (inJarFile.exists() && !processingWar) { args.add("-injars"); - StringBuffer filter = new StringBuffer(fileToString(inJarFile)); - if ((inFilter != null) || (!addMavenDescriptor)) { - filter.append("("); - boolean coma = false; - - if (!addMavenDescriptor) { - coma = true; - filter.append("!META-INF/maven/**"); - } - - if (inFilter != null) { - if (coma) { - filter.append(","); - } - filter.append(inFilter); - } - - filter.append(")"); - } - args.add(filter.toString()); + args.add(buildJarReference(inJarFile, inFilter)); } @@ -539,7 +527,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { if (args.contains("-injars")) { args.add("-outjars"); - args.add(fileToString(outJarFile)); + args.add(buildJarReference(outJarFile, outFilter)); } if (!obfuscate) { @@ -894,4 +882,27 @@ public Expander() { expander.setDest(destDir); expander.execute(); } + + private String buildJarReference(File jarFile, String jarFilter) { + StringBuffer filter = new StringBuffer(fileToString(jarFile)); + if ((jarFilter != null) || (!addMavenDescriptor)) { + filter.append("("); + boolean coma = false; + + if (!addMavenDescriptor) { + coma = true; + filter.append("!META-INF/maven/**"); + } + + if (jarFilter != null) { + if (coma) { + filter.append(","); + } + filter.append(jarFilter); + } + + filter.append(")"); + } + return filter.toString(); + } } From 62562f9413f38c055905b256882451c845f904a9 Mon Sep 17 00:00:00 2001 From: radomir Date: Mon, 8 Sep 2014 11:39:16 +0200 Subject: [PATCH 4/6] Fixing sameArtifact flag and attached artifact reference --- .../java/com/github/wvengen/maven/proguard/ProGuardMojo.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/github/wvengen/maven/proguard/ProGuardMojo.java b/src/main/java/com/github/wvengen/maven/proguard/ProGuardMojo.java index 35abf240..a1f76432 100644 --- a/src/main/java/com/github/wvengen/maven/proguard/ProGuardMojo.java +++ b/src/main/java/com/github/wvengen/maven/proguard/ProGuardMojo.java @@ -374,7 +374,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { throw new MojoFailureException("Can't delete " + outJarFile); } } - sameArtifact = (outjar != null) && (!outjar.equals(injar)); + sameArtifact = (outjar != null) && (outjar.equals(injar)); } else if ((outjar != null) && (!outjar.equals(injar))) { sameArtifact = false; outJarFile = (new File(outputDirectory, outjar)).getAbsoluteFile(); @@ -656,6 +656,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { } catch (Exception e) { throw new MojoExecutionException("Unable to create war", e); } + outJarFile = outputWar; } if (attach && !sameArtifact) { From 1209e392a7143ba856f070b5130869cfdf7455ac Mon Sep 17 00:00:00 2001 From: radomir Date: Mon, 8 Sep 2014 12:42:40 +0200 Subject: [PATCH 5/6] Added options to attach proguard map and seed files as artifacts --- .../wvengen/maven/proguard/ProGuardMojo.java | 80 ++++++++++++++++++- 1 file changed, 78 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/github/wvengen/maven/proguard/ProGuardMojo.java b/src/main/java/com/github/wvengen/maven/proguard/ProGuardMojo.java index a1f76432..4767d51d 100644 --- a/src/main/java/com/github/wvengen/maven/proguard/ProGuardMojo.java +++ b/src/main/java/com/github/wvengen/maven/proguard/ProGuardMojo.java @@ -201,6 +201,50 @@ public class ProGuardMojo extends AbstractMojo { */ private boolean appendClassifier; + /** + * Specifies whether or not to attach the created proguard map artifact to the project + * + * @parameter default-value="false" + */ + private boolean attachMap = false; + + /** + * Specifies attach proguard map artifact type + * + * @parameter default-value="txt" + */ + private String attachMapArtifactType = "txt"; + + /** + * Specifies attach proguard seed artifact type + * + * @parameter default-value="txt" + */ + private String attachSeedArtifactType = "txt"; + + /** + * Specifies whether or not to attach the created proguard seed artifact to the project + * + * @parameter default-value="false" + */ + private boolean attachSeed = false; + + /** + * Specifies attach artifact Classifier, ignored if attachMap=false + * + * @parameter default-value="proguard-map" + */ + private String attachMapArtifactClassifier = "proguard-map"; + + /** + * Specifies attach artifact Classifier, ignored if attachSeed=false + * + * @parameter default-value="proguard-seed" + */ + private String attachSeedArtifactClassifier = "proguard-seed"; + + + /** * Set to true to include META-INF/maven/** maven descriptord * @@ -295,6 +339,14 @@ private boolean useArtifactClassifier() { return appendClassifier && ((attachArtifactClassifier != null) && (attachArtifactClassifier.length() > 0)); } + private boolean useMapArtifactClassifier() { + return ((attachMapArtifactClassifier != null) && (attachMapArtifactClassifier.length() > 0)); + } + + private boolean useSeedArtifactClassifier() { + return ((attachSeedArtifactClassifier != null) && (attachSeedArtifactClassifier.length() > 0)); + } + public void execute() throws MojoExecutionException, MojoFailureException { log = getLog(); @@ -552,11 +604,13 @@ public void execute() throws MojoExecutionException, MojoFailureException { } } + File proguardMapFile = (new File(outputDirectory, "proguard_map.txt").getAbsoluteFile()); args.add("-printmapping"); - args.add(fileToString((new File(outputDirectory, "proguard_map.txt").getAbsoluteFile()))); + args.add(fileToString(proguardMapFile)); + File proguardSeedFile = (new File(outputDirectory, "proguard_seeds.txt").getAbsoluteFile()); args.add("-printseeds"); - args.add(fileToString((new File(outputDirectory, "proguard_seeds.txt").getAbsoluteFile()))); + args.add(fileToString(proguardSeedFile)); if (log.isDebugEnabled()) { args.add("-verbose"); @@ -666,6 +720,28 @@ public void execute() throws MojoExecutionException, MojoFailureException { projectHelper.attachArtifact(mavenProject, attachArtifactType, null, outJarFile); } } + + if (attachMap && attach) { + if (!proguardMapFile.exists()) { + log.warn("Cannot attach proguard map artifact as file does nto exist."); + } else if (useMapArtifactClassifier()) { + projectHelper.attachArtifact(mavenProject, attachMapArtifactType, attachMapArtifactClassifier, proguardMapFile); + } else { + throw new MojoExecutionException("Map artifact classifier cannot be empty"); +// projectHelper.attachArtifact(mavenProject, attachMapArtifactType, null, proguardMapFile); + } + } + + if (attachSeed && attach) { + if (!proguardSeedFile.exists()) { + log.warn("Cannot attach proguard seed artifact as file does nto exist."); + } else if (useSeedArtifactClassifier()) { + projectHelper.attachArtifact(mavenProject, attachSeedArtifactType, attachSeedArtifactClassifier, proguardSeedFile); + } else { + throw new MojoExecutionException("Seed artifact classifier cannot be empty"); +// projectHelper.attachArtifact(mavenProject, attachSeedArtifactType, null, proguardSeedFile); + } + } } private static File getProguardJar(ProGuardMojo mojo) throws MojoExecutionException { From 86c1d721cdd73cb794a424bc8782004abb7aa0cf Mon Sep 17 00:00:00 2001 From: radomir Date: Wed, 10 Sep 2014 14:31:38 +0200 Subject: [PATCH 6/6] Documentation for war handling --- README.md | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 91 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 19b41de5..f6738dd5 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,94 @@ -ProGuard Maven Plugin ---------------------- +ProGuard Maven Plugin (with WAR support) +---------------------------------------- + +This project is a fork of [wvengen's proguard maven plugin](https://github.com/wvengen/proguard-maven-plugin) +with focus on easier _war_ file processing with [ProGuard]. + +If plugin's input jar is a war file, the plugin uses the following workflow: + + 1. The war file is extracted to a temporary directory + (in build directory, with _'_war_proguard_expanded'_ appended to base war file name) + 1. Artifacts referenced by assembly inclusions section (with wildcard supported for artifactId) + are used as ProGuard _injars_. All other artifacts are used as _libraryjars_. + Input artifacts files that exist in _WEB-INF/lib_, are referenced using that location + rather than location within user's maven repository. + 1. Proguarded classes and resources will be out to a jar file in _WEB-INF/lib_ named by the artifact. + Processed input jars located in _WEB-INF/lib_ are deleted. + 1. If _processWarClassesDir_ option is enabled, _WEB-INF/classes_ will be processed as _injars_ + and output separately (to replace existing _WEB-INF/classes_ directory). + 1. Finally, output war archive is created. + +Additional configuration parameters supported: + + - processWarClassesDir - if enabled, WEB-INF/classes will be processed as _injars_ + - attachMap - whether or not to attach proguard map file as an artifact + - attachMapArtifactType - defaults to _txt_ + - attachMapArtifactClassifier - defaults to _proguard-map_ + - attachSeed - whether or not to attach proguard seed file as an artifact + - attachSeedArtifactType - defaults to _txt_ + - attachSeedArtifactClassifier - defaults to _proguard-seed_ + + +### Configuration example for war + + + com.github.radomirml + proguard-maven-plugin + 2.0.9 + + + package + + proguard + + + + + 4.8 + true + 1024m + true + true + + + + + + + + + ${project.groupId}* + + + + + + commons-logging* + + + log4j* + + + ${project.build.finalName}.war + + ${project.build.directory} + true + true + proguarded + war + true + true + ${basedir}/proguard.conf + + ${java.home}/lib/rt.jar + + false + false + + + + +## Base project description Run [ProGuard] as part of your [Maven] build. For usage, please read the generated [Documentation](http://wvengen.github.io/proguard-maven-plugin/).