<?xml version='1.0' encoding='UTF-8'?> <project name="Jar Jar Links" default="jar" xmlns:artifact="antlib:org.apache.maven.artifact.ant"> <property file="${user.home}/build.properties" /> <property file="build.properties" /> <property name="javadoc.access" value="public"/> <property name="compile.source" value="1.5"/> <property name="compile.target" value="1.5"/> <property name="compile.bootclasspath" value=""/> <property name="compile.extdirs" value=""/> <property name="compile.debug" value="true"/> <property name="compile.deprecation" value="false"/> <property name="compile.optimize" value="false"/> <property name="src" location="src" /> <property name="build" location="build" /> <property name="dist" location="dist" /> <!-- define Maven coordinates --> <property name="groupId" value="com.googlecode.jarjar" /> <property name="artifactId" value="jarjar" /> <property name="version" value="1.4"/> <!-- define artifacts' name, which follows the convention of Maven --> <property name="maven-jar" value="${dist}/${artifactId}-${version}.jar" /> <property name="maven-javadoc-jar" value="${dist}/${artifactId}-${version}-javadoc.jar" /> <property name="maven-sources-jar" value="${dist}/${artifactId}-${version}-sources.jar" /> <!-- defined maven snapshots and staging repository id and url --> <property name="maven-snapshots-repository-id" value="sonatype-nexus-snapshots" /> <property name="maven-snapshots-repository-url" value="https://oss.sonatype.org/content/repositories/snapshots/" /> <property name="maven-staging-repository-id" value="sonatype-nexus-staging" /> <property name="maven-staging-repository-url" value="https://oss.sonatype.org/service/local/staging/deploy/maven2/" /> <property name="jarfile" value="dist/jarjar-${version}.jar"/> <property name="jarfile.util" value="dist/jarjar-util-${version}.jar"/> <property name="jarfile.mojo" value="dist/jarjar-plugin-${version}.jar"/> <property name="test.jar" value="build/rejar.jar"/> <target name="init"> <echo>bootclasspath ${compile.bootclasspath}</echo> <tstamp/> <path id="path.build"> <fileset dir="lib" includes="**/*.jar"/> </path> <path id="path.run"> <path refid="path.build"/> <pathelement path="build/main"/> </path> <path id="path.test"> <path refid="path.run"/> <pathelement path="build/test"/> </path> </target> <macrodef name="compile"> <attribute name="module"/> <attribute name="refid"/> <attribute name="bootclasspath" default=""/> <sequential> <mkdir dir="build/@{module}"/> <copy todir="build/@{module}"> <fileset dir="src/@{module}" excludes="**/*.java"/> </copy> <javac includeantruntime="true" srcdir="src/@{module}" destdir="build/@{module}" source="${compile.source}" target="${compile.target}" bootclasspath="@{bootclasspath}" extdirs="${compile.extdirs}" debug="${compile.debug}" optimize="${compile.optimize}" deprecation="${compile.deprecation}"> <classpath refid="@{refid}"/> <compilerarg value="-Xlint"/> </javac> </sequential> </macrodef> <target name="compile" depends="init" description="Compile"> <compile module="main" refid="path.build" bootclasspath="${compile.bootclasspath}"/> <taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask" classpathref="path.run"/> </target> <target name="compile-test" depends="compile" description="Compile tests"> <compile module="test" refid="path.run"/> </target> <target name="clean" description="Clean"> <delete dir="build"/> <delete dir="dist"/> <delete dir="dist/javadoc"/> </target> <target name="jar" depends="compile" description="Create Jar"> <mkdir dir="dist"/> <jarjar jarfile="${jarfile}"> <fileset dir="build/main"/> <zipfileset src="lib/asm-4.0.jar"/> <zipfileset src="lib/asm-commons-4.0.jar"> <include name="org/objectweb/asm/commons/Remap*.class"/> <include name="org/objectweb/asm/commons/LocalVariablesSorter.class"/> </zipfileset> <keep pattern="com.tonicsystems.jarjar.Main"/> <keep pattern="com.tonicsystems.jarjar.JarJarTask"/> <rule pattern="com.tonicsystems.jarjar.util.**" result="com.tonicsystems.jarjar.ext_util.@1"/> <rule pattern="org.objectweb.asm.**" result="com.tonicsystems.jarjar.asm.@1"/> <manifest> <attribute name="Main-Class" value="com.tonicsystems.jarjar.Main"/> <attribute name="Implementation-Version" value="${version}"/> </manifest> </jarjar> </target> <target name="jar-util" depends="compile" description="Create utility Jar"> <mkdir dir="dist"/> <jar jarfile="${jarfile.util}"> <fileset dir="build/main" includes="com/tonicsystems/jarjar/util/**"/> </jar> </target> <target name="dist" depends="jar,dist-src,javadoc" description="generate the distribution"> <copy file="${dist}/jarjar-src-${version}.zip" tofile="${maven-sources-jar}" /> <jar jarfile="${maven-javadoc-jar}"> <fileset dir="${dist}/javadoc" /> </jar> </target> <!-- before this, update project version (both build.xml and pom.xml) from SNAPSHOT to RELEASE --> <target name="stage" depends="dist" description="deploy release version to Maven staging repository"> <!-- sign and deploy the main artifact --> <artifact:mvn> <arg value="org.apache.maven.plugins:maven-gpg-plugin:1.3:sign-and-deploy-file" /> <arg value="-Durl=${maven-staging-repository-url}" /> <arg value="-DrepositoryId=${maven-staging-repository-id}" /> <arg value="-DpomFile=pom.xml" /> <arg value="-Dfile=${maven-jar}" /> <arg value="-Pgpg" /> </artifact:mvn> <!-- sign and deploy the sources artifact --> <artifact:mvn> <arg value="org.apache.maven.plugins:maven-gpg-plugin:1.3:sign-and-deploy-file" /> <arg value="-Durl=${maven-staging-repository-url}" /> <arg value="-DrepositoryId=${maven-staging-repository-id}" /> <arg value="-DpomFile=pom.xml" /> <arg value="-Dfile=${maven-sources-jar}" /> <arg value="-Dclassifier=sources" /> <arg value="-Pgpg" /> </artifact:mvn> <!-- sign and deploy the javadoc artifact --> <artifact:mvn> <arg value="org.apache.maven.plugins:maven-gpg-plugin:1.3:sign-and-deploy-file" /> <arg value="-Durl=${maven-staging-repository-url}" /> <arg value="-DrepositoryId=${maven-staging-repository-id}" /> <arg value="-DpomFile=pom.xml" /> <arg value="-Dfile=${maven-javadoc-jar}" /> <arg value="-Dclassifier=javadoc" /> <arg value="-Pgpg" /> </artifact:mvn> </target> <target name="dist-src" depends="compile" description="Create source distribution"> <mkdir dir="${dist}"/> <zip destfile="${dist}/jarjar-src-${version}.zip"> <zipfileset dir="src" excludes="**/*.save" prefix="jarjar-${version}/src"/> <zipfileset dir="lib" prefix="jarjar-${version}/lib"/> <zipfileset dir="maven" prefix="jarjar-${version}/maven"/> <zipfileset dir="." includes="build.xml,COPYING" prefix="jarjar-${version}"/> </zip> </target> <target name="mojo" depends="jar" description="Create Maven plugin"> <mkdir dir="dist"/> <copy todir="dist/maven"> <fileset dir="maven"/> <filterset> <filter token="VERSION" value="${version}"/> </filterset> </copy> <jar jarfile="${jarfile.mojo}"> <zipfileset src="${jarfile}"/> <zipfileset dir="dist/maven" prefix="META-INF/maven" includes="plugin.xml"/> <zipfileset dir="dist/maven" prefix="META-INF/maven/com.tonicsystems.jarjar/jarjar-plugin" includes="pom.xml,pom.properties"/> </jar> </target> <target name="test" depends="junit,test-rejar,test-manifest,test-enum" description="Run tests"/> <target name="junit" depends="compile-test"> <junit haltonfailure="on"> <!-- <jvmarg value="-Xint"/> --> <!-- <jvmarg value="-Xprof"/> --> <!-- <jvmarg value="-server"/> --> <formatter type="plain" usefile="false"/> <classpath refid="path.test"/> <batchtest> <fileset dir="src/test" includes="**/*Test.java"/> </batchtest> </junit> </target> <target name="test-rejar" depends="jar"> <taskdef name="jarjar2" classname="com.tonicsystems.jarjar.JarJarTask" classpath="${jarfile}"/> <delete file="${test.jar}"/> <jarjar2 jarfile="${test.jar}"> <fileset dir="build/main"/> <zipfileset src="lib/asm-4.0.jar"/> <zipfileset src="lib/asm-commons-4.0.jar"/> <rule pattern="org.objectweb.asm.**" result="com.tonicsystems.jarjar.asm.@1"/> </jarjar2> <delete file="${test.jar}"/> </target> <target name="test-enum" depends="compile"> <delete file="build/enumtest.jar"/> <jarjar jarfile="build/enumtest.jar" verbose="true"> <zipfileset src="src/test/enumtest.jar"/> <rule pattern="foo.**" result="bar.@1"/> </jarjar> <java classpath="build/enumtest.jar" classname="bar.EnumTest"/> <!-- TODO: check output --> <!-- <delete file="build/enumtest.jar"/> --> </target> <target name="test-manifest" depends="compile"> <delete> <fileset dir="build" includes="manifest*.jar"/> </delete> <jar jarfile="build/manifest1.jar"> <manifest> <attribute name="Built-By" value="Chris"/> <attribute name="Specification-Title" value="Example"/> </manifest> </jar> <jar jarfile="build/manifest2.jar"> <manifest> <attribute name="Built-By" value="CJN"/> <attribute name="Implementation-Title" value="common"/> </manifest> </jar> <jar jarfile="build/manifest3.jar" filesetmanifest="merge"> <zipfileset src="build/manifest1.jar"/> <zipfileset src="build/manifest2.jar"/> </jar> <jarjar jarfile="build/manifest4.jar" filesetmanifest="merge"> <zipfileset src="build/manifest1.jar"/> <zipfileset src="build/manifest2.jar"/> </jarjar> <!-- TODO: check manifest contents here --> </target> <!-- TODO: reference ant javadocs --> <target name="javadoc" depends="compile" description="Generate the javadoc"> <mkdir dir="dist/javadoc"/> <javadoc sourcepath="${src}/main" destdir="${dist}/javadoc" access="${javadoc.access}" failonerror="true" packagenames="com.tonicsystems.jarjar.*" classpathref="path.run" Author="true" Version="true" Use="true" /> </target> </project>