1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275
|
<?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"/>
<exclude name="**/*Mojo*"/>
</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="${asm.jar}"/>
<zipfileset src="${asm-commons.jar}"/>
<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.*"
Author="true"
Version="true"
Use="true">
<classpath>
<path refid="path.run"/>
<pathelement location="${asm.jar}"/>
<pathelement location="${asm-commons.jar}"/>
<pathelement location="${maven-plugin-api.jar}"/>
<pathelement location="${ant.jar}"/>
</classpath>
</javadoc>
</target>
</project>
|