Revamped the Maven build to use the Maven Proguard plugin (PITA!) instead of

calling out to Ant to do the Proguard build.

Running Ant from within Maven (which then runs Maven from within Ant) no longer
works as of Maven 3.

While I was in here, I changed the build to use the Proguard-ed artifact as the
primary artifact, and changed the POM to reflect that none of the dependencies
are transitive.
This commit is contained in:
Michael Bayne
2011-09-17 17:39:23 +00:00
parent f1f6b26bb0
commit 71d3abddf1
3 changed files with 86 additions and 69 deletions
+6 -16
View File
@@ -100,17 +100,12 @@
</javadoc> </javadoc>
</target> </target>
<target name="dist" depends="compile" description="Builds jar files."> <target name="dist" depends="compile" description="Builds jar file.">
<jar destfile="${deploy.dir}/${ant.project.name}.jar" manifest="lib/manifest.mf" <jar destfile="${deploy.dir}/${ant.project.name}-bare.jar" manifest="lib/manifest.mf"
basedir="${deploy.dir}/classes"/> basedir="${deploy.dir}/classes"/>
<!-- generate our proguard client and tool jar files -->
<antcall target="-proguard">
<param name="getdown.jar" value="${deploy.dir}/${ant.project.name}.jar"/>
<param name="version.suff" value=""/>
</antcall>
</target> </target>
<target name="-proguard" depends="-prepare"> <target name="proguard" depends="dist" description="Builds dependencies included jar file.">
<!-- locate the platform classes --> <!-- locate the platform classes -->
<condition property="rt.jar" value="${java.home}/../Classes/classes.jar"> <condition property="rt.jar" value="${java.home}/../Classes/classes.jar">
<available file="${java.home}/../Classes/classes.jar"/> <available file="${java.home}/../Classes/classes.jar"/>
@@ -126,13 +121,13 @@
<!-- build the dependencies included jar file --> <!-- build the dependencies included jar file -->
<proguard> <proguard>
<injar path="${getdown.jar}"/> <injar path="${deploy.dir}/${ant.project.name}-bare.jar"/>
<injar path="${jregistrykey:jregistrykey:jar}" filter="!META-INF/**"/> <injar path="${jregistrykey:jregistrykey:jar}" filter="!META-INF/**"/>
<injar path="${com.samskivert:samskivert:jar}" filter="!META-INF/**, <injar path="${com.samskivert:samskivert:jar}" filter="!META-INF/**,
!**/Log4JLogger*,!**/*.java,com/samskivert/Log.class,**/samskivert/io/**, !**/Log4JLogger*,!**/*.java,com/samskivert/Log.class,**/samskivert/io/**,
**/samskivert/swing/**,**/samskivert/text/**,**/samskivert/util/**"/> **/samskivert/swing/**,**/samskivert/text/**,**/samskivert/util/**"/>
<injar path="${commons-codec:commons-codec:jar}" filter="!META-INF/**"/> <injar path="${commons-codec:commons-codec:jar}" filter="!META-INF/**"/>
<outjar path="${deploy.dir}/getdown-pro${version.suff}.jar"/> <outjar path="${deploy.dir}/${ant.project.name}.jar"/>
<libraryjar name="${rt.jar}"/> <libraryjar name="${rt.jar}"/>
<libraryjar name="${org.apache.ant:ant:jar}"/> <libraryjar name="${org.apache.ant:ant:jar}"/>
<libraryjar name="${java.home}/lib/plugin.jar"/> <libraryjar name="${java.home}/lib/plugin.jar"/>
@@ -154,7 +149,7 @@
</target> </target>
<property name="maven.deploy.repo" value="file://${user.home}/.m2/repository"/> <property name="maven.deploy.repo" value="file://${user.home}/.m2/repository"/>
<target name="maven-deploy" depends="dist" <target name="maven-deploy" depends="proguard"
description="Deploys our build artifacts to a Maven repository."> description="Deploys our build artifacts to a Maven repository.">
<jar basedir="${src.dir}" destfile="${deploy.dir}/${ant.project.name}-sources.jar"/> <jar basedir="${src.dir}" destfile="${deploy.dir}/${ant.project.name}-sources.jar"/>
<artifact:deploy file="${deploy.dir}/${ant.project.name}.jar" uniqueVersion="false"> <artifact:deploy file="${deploy.dir}/${ant.project.name}.jar" uniqueVersion="false">
@@ -162,10 +157,5 @@
<pom refid="pom"/> <pom refid="pom"/>
<attach file="${deploy.dir}/${ant.project.name}-sources.jar" classifier="sources"/> <attach file="${deploy.dir}/${ant.project.name}-sources.jar" classifier="sources"/>
</artifact:deploy> </artifact:deploy>
<artifact:pom id="proguard-pom" file="proguard-pom.xml"/>
<artifact:deploy file="${deploy.dir}/${ant.project.name}-pro.jar" uniqueVersion="false">
<remoteRepository url="${maven.deploy.repo}"/>
<pom refid="proguard-pom"/>
</artifact:deploy>
</target> </target>
</project> </project>
+80 -39
View File
@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.threerings</groupId> <groupId>com.threerings</groupId>
<artifactId>getdown</artifactId> <artifactId>getdown</artifactId>
@@ -52,19 +54,18 @@
<groupId>com.samskivert</groupId> <groupId>com.samskivert</groupId>
<artifactId>samskivert</artifactId> <artifactId>samskivert</artifactId>
<version>1.2</version> <version>1.2</version>
<scope>compile</scope> <optional>true</optional>
</dependency> </dependency>
<dependency> <dependency>
<groupId>commons-codec</groupId> <groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId> <artifactId>commons-codec</artifactId>
<version>1.4</version> <version>1.4</version>
<scope>compile</scope> <optional>true</optional>
</dependency> </dependency>
<dependency> <dependency>
<groupId>jregistrykey</groupId> <groupId>jregistrykey</groupId>
<artifactId>jregistrykey</artifactId> <artifactId>jregistrykey</artifactId>
<version>1.0</version> <version>1.0</version>
<scope>compile</scope>
<optional>true</optional> <optional>true</optional>
</dependency> </dependency>
<dependency> <dependency>
@@ -73,6 +74,13 @@
<version>1.7.1</version> <version>1.7.1</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>java</groupId>
<artifactId>plugin</artifactId>
<version>1.5</version>
<scope>system</scope>
<systemPath>${java.home}/lib/plugin.jar</systemPath>
</dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>
@@ -105,11 +113,6 @@
<encoding>UTF-8</encoding> <encoding>UTF-8</encoding>
</configuration> </configuration>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.6</version>
</plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId> <artifactId>maven-javadoc-plugin</artifactId>
@@ -120,28 +123,56 @@
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>com.pyx4me</groupId>
<artifactId>maven-antrun-plugin</artifactId> <artifactId>proguard-maven-plugin</artifactId>
<version>1.6</version> <version>2.0.4</version>
<executions> <executions>
<execution> <execution>
<id>package</id> <phase>package</phase>
<phase>package</phase> <goals><goal>proguard</goal></goals>
<configuration> </execution>
<target>
<property name="deploy.dir" value="target" />
<property name="getdown.jar" value="target/getdown-${project.version}.jar" />
<property name="version.suff" value="-${project.version}" />
<ant antfile="${basedir}/build.xml">
<target name="-proguard" />
</ant>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions> </executions>
<dependencies>
<dependency>
<groupId>net.sf.proguard</groupId>
<artifactId>proguard</artifactId>
<version>4.4</version>
<scope>runtime</scope>
</dependency>
</dependencies>
<configuration>
<proguardVersion>4.4</proguardVersion>
<outputDirectory>${project.build.directory}</outputDirectory>
<outjar>${project.build.finalName}.jar</outjar>
<injar>${project.build.finalName}.jar</injar>
<assembly>
<inclusions>
<inclusion>
<groupId>com.samskivert</groupId>
<artifactId>samskivert</artifactId>
<filter>!**/Log4JLogger*,!**/*.java,com/samskivert/Log.class,**/samskivert/io/**,
**/samskivert/swing/**,**/samskivert/text/**,**/samskivert/util/**</filter>
</inclusion>
<inclusion>
<groupId>jregistrykey</groupId>
<artifactId>jregistrykey</artifactId>
</inclusion>
<inclusion>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</inclusion>
</inclusions>
</assembly>
<obfuscate>true</obfuscate>
<options>
<option>-keep public class com.threerings.getdown.** { *; }</option>
<option>-keep public class ca.beq.util.win32.registry.** { *; }</option>
</options>
<libs>
<lib>${rt.jar.path}</lib>
</libs>
<addMavenDescriptor>false</addMavenDescriptor>
</configuration>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
@@ -155,17 +186,8 @@
</archive> </archive>
</configuration> </configuration>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.3.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.5</version>
</plugin>
</plugins> </plugins>
<pluginManagement> <pluginManagement>
<plugins> <plugins>
<plugin> <plugin>
@@ -226,5 +248,24 @@
</plugins> </plugins>
</build> </build>
</profile> </profile>
<!-- finagling to deal with rt.jar not existing on Macs, thanks Apple! -->
<profile>
<id>mac</id>
<activation>
<file><exists>${java.home}/../Classes/classes.jar</exists></file>
</activation>
<properties>
<rt.jar.path>${java.home}/../Classes/classes.jar</rt.jar.path>
</properties>
</profile>
<profile>
<id>non-mac</id>
<activation>
<file><exists>${java.home}/../lib/rt.jar</exists></file>
</activation>
<properties>
<rt.jar.path>${java.home}/../lib/rt.jar</rt.jar.path>
</properties>
</profile>
</profiles> </profiles>
</project> </project>
-14
View File
@@ -1,14 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.threerings</groupId>
<artifactId>getdown-pro</artifactId>
<packaging>jar</packaging>
<version>1.2-SNAPSHOT</version>
<name>getdown-pro</name>
<description>A dependencies-included version of getdown.jar.</description>
<dependencies>
<!-- none! -->
</dependencies>
</project>