Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
331 lines (300 sloc) 16.3 KB
<project name="json-lib" default="compile" basedir="." xmlns:artifact="urn:maven-artifact-ant">
<property file="${user.home}/.m2/maven.properties" />
<property file="build.properties" />
<property name="maven.project.build.finalName" value="json-lib-2.4.1" />
<property name="maven.build.output" value="target/classes" />
<property name="maven.build.directory" value="target" />
<property name="maven.test.reports" value="${maven.build.directory}/test-reports" />
<property name="maven.test.output" value="target/test-classes" />
<property name="project.lib.dir" value="${basedir}/src/lib" />
<property name="project.src.jdk3.dir" value="${basedir}/src/main/java" />
<property name="project.src.jdk5.dir" value="${basedir}/src/main/jdk15" />
<property name="project.src.groovy.dir" value="${basedir}/src/main/groovy" />
<property name="project.test.jdk3.dir" value="${basedir}/src/test/java" />
<property name="project.test.jdk5.dir" value="${basedir}/src/test/jdk15" />
<property name="project.test.groovy.dir" value="${basedir}/src/test/groovy" />
<property name="javadoc.jdk3.dir" value="${maven.build.directory}/site/apidocs" />
<property name="javadoc.jdk5.dir" value="${maven.build.directory}/site/apidocs/jdk15" />
<typedef resource="org/apache/maven/artifact/ant/antlib.xml" uri="urn:maven-artifact-ant">
<classpath>
<pathelement location="${project.lib.dir}/maven-ant-tasks-2.0.9.jar" />
</classpath>
</typedef>
<artifact:pom file="pom.xml" id="maven.project" />
<artifact:dependencies pathId="build.classpath" filesetId="compile.fileset" useScope="compile">
<pom refid="maven.project" />
</artifact:dependencies>
<artifact:dependencies pathId="test.classpath" filesetId="test.fileset" useScope="test">
<pom refid="maven.project" />
</artifact:dependencies>
<artifact:dependencies pathId="runtime.classpath" filesetId="runtime.fileset" useScope="runtime">
<pom refid="maven.project" />
</artifact:dependencies>
<target name="clean" description="Clean the output directory">
<delete dir="${maven.build.directory}" />
</target>
<taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc" classpathref="build.classpath" />
<target name="compile" description="Compile the code (jdk1.3)">
<mkdir dir="${maven.build.output}" />
<javac destdir="${maven.build.output}" excludes="**/package.html" debug="true" deprecation="true" source="1.3" target="1.1">
<src path="${project.src.jdk3.dir}" />
<classpath refid="build.classpath" />
</javac>
</target>
<target name="compile.jdk5" depends="compile" description="Compile the code (jdk5)">
<delete file="${maven.build.output}/net/sf/json/JSONObject.class" />
<delete file="${maven.build.output}/net/sf/json/JSONArray.class" />
<javac destdir="${maven.build.output}" debug="true" deprecation="true" source="1.5" target="1.5">
<src path="${project.src.jdk5.dir}" />
<classpath>
<path refid="build.classpath" />
<pathelement location="${maven.build.output}" />
</classpath>
</javac>
</target>
<target name="compile.groovy" depends="compile" description="Compile the code (Groovy)">
<groovyc srcdir="${project.src.groovy.dir}" destdir="${maven.build.output}">
<classpath>
<path refid="build.classpath" />
<pathelement location="${maven.build.output}" />
</classpath>
</groovyc>
</target>
<target name="compile-tests" depends="junit-present, compile" description="Compile the test code (jdk1.3)" if="junit.present">
<mkdir dir="${maven.test.output}" />
<javac destdir="${maven.test.output}" debug="true" deprecation="true" optimize="false" source="1.3" target="1.1">
<src path="${project.test.jdk3.dir}" />
<classpath>
<path refid="build.classpath" />
<path refid="test.classpath" />
<pathelement location="${maven.build.output}" />
</classpath>
</javac>
<copy todir="${maven.test.output}">
<fileset dir="src/test/resources" />
</copy>
</target>
<target name="compile-tests.jdk5" depends="junit-present, compile.jdk5, compile-tests" description="Compile the test code (jdk5)" if="junit.present">
<mkdir dir="${maven.test.output}" />
<javac destdir="${maven.test.output}" debug="true" deprecation="true" optimize="false" source="1.5" target="1.5">
<src path="${project.test.jdk5.dir}" />
<classpath>
<path refid="build.classpath" />
<path refid="test.classpath" />
<pathelement location="${maven.build.output}" />
</classpath>
</javac>
</target>
<target name="compile-tests.groovy" depends="compile.groovy" description="Compile the test code (Groovy)">
<mkdir dir="${maven.test.output}" />
<groovyc srcdir="${project.test.groovy.dir}" destdir="${maven.test.output}">
<classpath>
<path refid="build.classpath" />
<path refid="test.classpath" />
<pathelement location="${maven.build.output}" />
</classpath>
</groovyc>
</target>
<target name="test" depends="test.jdk3,test.groovy" description="Run JDK13 &amp; Groovy test cases" />
<target name="test.jdk3" depends="junit-present, compile-tests" if="junit.present" description="Run the test cases (jdk1.3)">
<mkdir dir="${maven.test.reports}" />
<junit printSummary="yes" haltonerror="true" haltonfailure="true" fork="true" dir="." forkmode="once">
<sysproperty key="basedir" value="." />
<formatter type="xml" />
<formatter type="plain" usefile="true" />
<classpath>
<path refid="build.classpath" />
<path refid="test.classpath" />
<path refid="runtime.classpath" />
<pathelement location="${maven.build.output}" />
<pathelement location="${maven.test.output}" />
</classpath>
<batchtest todir="${maven.test.reports}">
<fileset dir="src/test/java">
<include name="**/Test*.java" />
<exclude name="**/*Abstract*Test.java" />
</fileset>
</batchtest>
</junit>
</target>
<target name="test.jdk5" depends="junit-present, compile-tests.jdk5" if="junit.present" description="Run the test cases (jdk5)">
<mkdir dir="${maven.test.reports}" />
<junit printSummary="yes" haltonerror="true" haltonfailure="true" fork="true" dir="." forkmode="once">
<sysproperty key="basedir" value="." />
<formatter type="xml" />
<formatter type="plain" usefile="true" />
<classpath>
<path refid="build.classpath" />
<path refid="test.classpath" />
<path refid="runtime.classpath" />
<pathelement location="${maven.build.output}" />
<pathelement location="${maven.test.output}" />
</classpath>
<batchtest todir="${maven.test.reports}">
<path>
<fileset dir="src/test/java">
<include name="**/Test*.java" />
<exclude name="**/*Abstract*Test.java" />
</fileset>
<fileset dir="src/test/jdk15">
<include name="**/Test*.java" />
<exclude name="**/*Abstract*Test.java" />
</fileset>
</path>
</batchtest>
</junit>
<antcall target="test.groovy"/>
</target>
<target name="test.groovy" depends="junit-present, compile-tests.groovy" if="junit.present" description="Run the test cases (Groovy)">
<mkdir dir="${maven.test.reports}" />
<junit printSummary="yes" haltonerror="true" haltonfailure="true" fork="true" dir="." forkmode="once">
<sysproperty key="basedir" value="." />
<formatter type="xml" />
<formatter type="plain" usefile="true" />
<classpath>
<path refid="build.classpath" />
<path refid="test.classpath" />
<path refid="runtime.classpath" />
<pathelement location="${maven.build.output}" />
<pathelement location="${maven.test.output}" />
</classpath>
<batchtest todir="${maven.test.reports}">
<fileset dir="${maven.test.output}">
<include name="net/sf/json/groovy/AllTests.class" />
</fileset>
</batchtest>
</junit>
</target>
<target name="test-junit-present">
<available classname="junit.framework.Test" property="junit.present" />
</target>
<target name="junit-present" depends="test-junit-present" unless="junit.present">
<echo>================================= WARNING ================================</echo>
<echo> Junit isn&apos;t present in your $ANT_HOME/lib directory. Tests not executed. </echo>
<echo>==========================================================================</echo>
</target>
<target name="jar" depends="clean,test" description="Binary jar (jdk3)">
<jar jarfile="${maven.build.directory}/${maven.project.build.finalName}-jdk13.jar" basedir="${maven.build.output}" excludes="**/package.html" />
</target>
<target name="jar.jdk5" depends="clean,test.jdk5" description="Binary jar (jdk5)">
<jar jarfile="${maven.build.directory}/${maven.project.build.finalName}-jdk15.jar" basedir="${maven.build.output}" excludes="**/package.html" />
</target>
<target name="jarjar" depends="jar">
<taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask"
classpath="${project.lib.dir}/jarjar-1.0.jar"/>
<property name="jarfile" value="${maven.build.directory}/${maven.project.name}-all-${maven.project.version}-jdk13.jar"/>
<delete file="${jarfile}"/>
<jarjar jarfile="${jarfile}">
<zipfileset src="${maven.build.directory}/${maven.project.build.finalName}-jdk13.jar"/>
<zipfileset src="${maven.repo.local}/commons-beanutils/commons-beanutils/1.8.0/commons-beanutils-1.8.0.jar"/>
<zipfileset src="${maven.repo.local}/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.jar"/>
<zipfileset src="${maven.repo.local}/commons-lang/commons-lang/2.5/commons-lang-2.5.jar"/>
<zipfileset src="${maven.repo.local}/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar"/>
<zipfileset src="${maven.repo.local}/net/sf/ezmorph/ezmorph/1.0.6/ezmorph-1.0.6.jar"/>
<rule pattern="org.apache.commons.**" result="_json.org.apache.commons.@1"/>
<rule pattern="net.sf.ezmorph.**" result="_json.net.sf.ezmorph.@1"/>
</jarjar>
</target>
<target name="jarjar.jdk5" depends="jar.jdk5">
<taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask"
classpath="${project.lib.dir}/jarjar-1.0.jar"/>
<property name="jarfile" value="${maven.build.directory}/${maven.project.name}-all-${maven.project.version}-jdk15.jar"/>
<delete file="${jarfile}"/>
<jarjar jarfile="${jarfile}">
<zipfileset src="${maven.build.directory}/${maven.project.build.finalName}-jdk15.jar"/>
<zipfileset src="${maven.repo.local}/commons-beanutils/commons-beanutils/1.8.0/commons-beanutils-1.8.0.jar"/>
<zipfileset src="${maven.repo.local}/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.jar"/>
<zipfileset src="${maven.repo.local}/commons-lang/commons-lang/2.5/commons-lang-2.5.jar"/>
<zipfileset src="${maven.repo.local}/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar"/>
<zipfileset src="${maven.repo.local}/net/sf/ezmorph/ezmorph/1.0.6/ezmorph-1.0.6.jar"/>
<rule pattern="org.apache.commons.**" result="_json.org.apache.commons.@1"/>
<rule pattern="net.sf.ezmorph.**" result="_json.net.sf.ezmorph.@1"/>
</jarjar>
</target>
<target name="source.jar" description="Source jar (jdk1.3)">
<delete dir="${maven.build.directory}/source/jdk13" />
<mkdir dir="${maven.build.directory}/source/jdk13" />
<copy todir="${maven.build.directory}/source/jdk13">
<fileset dir="src/main/java">
<include name="**/*.java" />
</fileset>
</copy>
<jar jarfile="${maven.build.directory}/${maven.project.build.finalName}-jdk13-sources.jar" basedir="${maven.build.directory}/source/jdk13" />
</target>
<target name="source.jar.jdk5" description="Source jar (jdk5)">
<delete dir="${maven.build.directory}/source/jdk15" />
<mkdir dir="${maven.build.directory}/source/jdk15" />
<copy todir="${maven.build.directory}/source/jdk15">
<fileset dir="src/main/java">
<include name="**/*.java" />
</fileset>
</copy>
<delete file="${maven.build.directory}/source/jdk15/net/sf/json/JSONObject.java" />
<delete file="${maven.build.directory}/source/jdk15/net/sf/json/JSONArray.java" />
<copy todir="${maven.build.directory}/source/jdk15">
<fileset dir="src/main/jdk15">
<include name="**/*.java" />
</fileset>
</copy>
<jar jarfile="${maven.build.directory}/${maven.project.build.finalName}-jdk15-sources.jar" basedir="${maven.build.directory}/source/jdk15" />
</target>
<target name="javadoc" description="Build javadocs (jdk1.3)" depends="setup">
<mkdir dir="${javadoc.jdk3.dir}" />
<mkdir dir="${maven.build.directory}/source/jdk13" />
<copy todir="${maven.build.directory}/source/jdk13">
<fileset dir="src/main/java">
<include name="**/*" />
</fileset>
</copy>
<javadoc destdir="${javadoc.jdk3.dir}" windowtitle="Overview (json-lib jdk 1.3 API)" useexternalfile="true">
<packageset dir="${maven.build.directory}/source/jdk13">
<include name="**/*" />
</packageset>
<classpath>
<path refid="build.classpath" />
</classpath>
<link href="http://java.sun.com/j2se/1.5.0/docs/api/" />
<link href="http://www.junit.org/junit/javadoc/" />
<link href="http://jakarta.apache.org/commons/beanutils/commons-beanutils-1.7.0/docs/api/" />
<link href="http://jakarta.apache.org/commons/lang/api-2.2/" />
<link href="http://ezmorph.sourceforge.net/apidocs/" />
</javadoc>
<jar jarfile="${maven.build.directory}/${maven.project.build.finalName}-jdk13-javadoc.jar" basedir="${javadoc.jdk3.dir}" />
</target>
<target name="javadoc.jdk5" description="Build javadocs (jdk5)" depends="setup">
<delete dir="${javadoc.jdk5.dir}" />
<delete dir="${maven.build.directory}/source/jdk15" />
<mkdir dir="${javadoc.jdk5.dir}" />
<mkdir dir="${maven.build.directory}/source/jdk15" />
<copy todir="${maven.build.directory}/source/jdk15">
<fileset dir="src/main/java">
<include name="**/*" />
</fileset>
</copy>
<delete file="${maven.build.directory}/source/jdk15/net/sf/json/JSONObject.java" />
<delete file="${maven.build.directory}/source/jdk15/net/sf/json/JSONArray.java" />
<copy todir="${maven.build.directory}/source/jdk15">
<fileset dir="src/main/jdk15">
<include name="**/*.java" />
</fileset>
</copy>
<javadoc destdir="${javadoc.jdk5.dir}" windowtitle="Overview (json-lib jdk 5 API)" useexternalfile="true">
<packageset dir="${maven.build.directory}/source/jdk15">
<include name="**/*" />
</packageset>
<classpath>
<path refid="build.classpath" />
</classpath>
<link href="http://java.sun.com/j2se/1.5.0/docs/api/" />
<link href="http://www.junit.org/junit/javadoc/" />
<link href="http://jakarta.apache.org/commons/beanutils/commons-beanutils-1.7.0/docs/api/" />
<link href="http://jakarta.apache.org/commons/lang/api-2.2/" />
<link href="http://ezmorph.sourceforge.net/apidocs/" />
</javadoc>
<jar jarfile="${maven.build.directory}/${maven.project.build.finalName}-jdk15-javadoc.jar" basedir="${javadoc.jdk5.dir}" />
</target>
<target name="setup" if="use.proxy">
<echo message="Setting proxy values [${maven.proxy.host}:${maven.proxy.port}]" />
<setproxy proxyhost="${maven.proxy.host}" proxyport="${maven.proxy.port}" proxyuser="${maven.proxy.username}" proxypassword="${maven.proxy.password}" />
</target>
</project>