MinimalBible-Legacy/jsword-minimalbible/build.xml
Bradlee Speice bfe6eeda0c Get the JarJar system running to build a shaded Jar
Unfortunately means I can't just copy the ivy.xml from jSword.
But I do have excludes="" that I didn't with maven previously.
2014-04-19 00:17:05 -04:00

167 lines
6.6 KiB
XML

<project name="buildJswordTweakedJar" default="copyJarsToMinimalBible"
basedir="." xmlns:ivy="antlib:org.apache.ivy.ant">
<!-- Much of this code taken lovingly from https://github.com/mjdenham/and-bible/blob/master/jsword-tweaks/build.xml -->
<property name="jsword.project" location="../jsword" />
<property name="jsword.src" location="${jsword.project}/src/main/java" />
<property name="jsword.resources" location="${jsword.project}/src/main/resources" />
<property name="minbible.jsword.src" location="src/main/java/jsword" />
<property name="build.src" location="build/src" />
<property name="build.class" location="build/class" />
<property name="distribution" location="distribution" />
<property name="MinimalBible" location="../MinimalBible" />
<dirname property="core.basedir" file="${ant.file.core}" />
<property name="jsword-tweaks.home" location="${core.basedir}" />
<property name="jsword-dependencydir" location="${jsword-tweaks.home}/lib/jars" />
<path id="classpath">
<!-- First set of jars is given us by ivy -->
<fileset dir="${jsword-dependencydir}" includes="*.jar" />
<fileset dir="./libs" includes="*.jar" />
</path>
<target name="clean">
<delete dir="${build.src}" />
<delete dir="${build.class}" />
<delete dir="${distribution}" />
<delete dir="${jsword-dependencydir}" />
</target>
<target name="init" depends="clean">
<tstamp />
<mkdir dir="${build.src}" />
<mkdir dir="${build.class}" />
<mkdir dir="${distribution}" />
<mkdir dir="${jsword-dependencydir}" />
</target>
<target name="mergeCode" depends="init">
<copy todir="${build.src}">
<fileset dir="${jsword.src}" />
<fileset dir="${jsword.resources}">
<exclude name="org/crosswire/jsword/versification/**" />
</fileset>
</copy>
<copy todir="${build.src}" filtering="yes">
<fileset dir="${jsword.resources}">
<include name="org/crosswire/jsword/versification/**" />
</fileset>
<!-- zerosUnmapped causes exceptions and does not map verse 0 so comment
it out -->
<filterchain>
<tokenfilter>
<replaceregex pattern="!zerosUnmapped"
replace="#!zerosUnmapped // commented out" />
</tokenfilter>
</filterchain>
</copy>
<!-- switch the Chinese localisation defaults around so default CN is simplified
and TW is Traditional -->
<copy file="${jsword.resources}/BibleNames_zh.properties" tofile="${build.src}/BibleNames_zh_TW.properties" />
<copy file="${jsword.resources}/BibleNames_zh_CN.properties"
tofile="${build.src}/BibleNames_zh.properties" overwrite="true" />
<!--
<copy todir="${build.src}" overwrite="true">
<fileset dir="${minbible.jsword.src}" />
</copy>
-->
</target>
<target name="compile" depends="mergeCode, ivy">
<javac srcdir="${build.src}" destdir="${build.class}"
classpathref="classpath" debug="true" source="1.6" target="1.6" />
</target>
<target name="jar" depends="compile">
<!-- And use JarJar to shade the HttpClient -->
<taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask"
classpath="${jsword-dependencydir}/jarjar-1.3.jar" />
<jarjar jarfile="${distribution}/jsword.jar">
<fileset dir="${build.class}" />
<!-- need to include the .properties and .plugin files -->
<fileset dir="${build.src}">
<exclude name="**/*.java" />
<exclude name="**/*.html" />
</fileset>
<zipgroupfileset dir="${jsword-dependencydir}" includes="*.jar" excludes="junit-*.jar, hamcrest-*.jar, jarjar-*.jar" />
<rule pattern="org.apache.http.**" result="org.apache.shaded.http.@1" />
</jarjar>
<!-- We can use regular jar to build the src -->
<jar jarfile="${distribution}/jsword-src.jar" basedir="${build.src}" />
</target>
<target name="copyJarsToMinimalBible" depends="jar"
description="Copy generated jars to And Bible for use">
<copy todir="${MinimalBible}/libs">
<fileset dir="${distribution}" includes="*.jar" excludes="*-src.jar" />
<!-- We only need to include jsword.jar, the jarjar already included dependencies. -->
</copy>
<copy todir="${MinimalBible}/libs-src">
<fileset dir="${distribution}" includes="*-src.jar" />
</copy>
</target>
<!--=======================================================================
== Use ivy to manage external jars. == These are properties related to ivy.
========================================================================= -->
<property name="ivy.version" value="2.3.0" />
<property name="tools.home" location="${jsword-tweaks.home}/tools" />
<property name="ivy.home" location="${tools.home}/ivy" />
<property name="ivy.url"
value="http://repo1.maven.org/maven2/org/apache/ivy/ivy/${ivy.version}/ivy-${ivy.version}.jar" />
<property name="ivy.jar.file" location="${ivy.home}/ivy-${ivy.version}.jar" />
<property name="ivy.quiet" value="default" /> <!-- default or quiet -->
<property name="ivy.sync" value="false" /> <!-- true or false -->
<property name="ivy.project.dir" location="${jsword-tweaks.home}" />
<property name="ivy.lib.dir" location="${ivy.project.dir}/lib" />
<property name="ivy.dep.file" location="${ivy.project.dir}/ivy.xml" />
<property name="ivy.default.ivy.user.dir" location="${ivy.project.dir}/ivy" />
<!-- Ivy.sync controls whether only the current version of jar is allowed.
== This is good when updating the project, but not from day-to-day == since
we build extra stuff into the same location. Having sync="true" == causes
that to be deleted and need to be restored. -->
<target name="ivy" description="Retrieve dependencies with ivy"
depends="ivy.task">
<ivy:retrieve sync="${ivy.sync}"
pattern="${ivy.lib.dir}/[type]s/[artifact]-[revision].[ext]" log="${ivy.quiet}" />
<ivy:cachepath pathid="default.path" />
</target>
<target name="ivy.clean" description="Remove the ivy installation">
<delete dir="${ivy.home}" />
</target>
<target name="ivy.clean-cache" description="Remove dependent jars that ivy manages"
depends="ivy.task">
<ivy:cleancache />
</target>
<!-- Make ivy visible to Ant -->
<target name="ivy.task" depends="ivy.download">
<path id="ivy.lib.path">
<fileset dir="${ivy.home}" includes="*.jar" />
</path>
<taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant"
classpathref="ivy.lib.path" />
</target>
<!-- Download ivy -->
<target name="ivy.download" depends="ivy.check" unless="ivy.present">
<mkdir dir="${ivy.home}" />
<!-- download Ivy from web site so that it can be used even without any
special installation -->
<get src="${ivy.url}" dest="${ivy.jar.file}" usetimestamp="true" />
</target>
<!-- See if Ivy is installed -->
<target name="ivy.check">
<available file="${ivy.jar.file}" type="file" property="ivy.present" />
</target>
</project>