Added executable modular build options.

* Added a new property 'executable.jar'. When set to true, the build creates an
  executable jar. It expects the fully qualified main class name in the
  'main.class' property. The executable jar expects all the runtime libs to be
  located in a folder called 'lib' next to the jar.
This commit is contained in:
Jonathan Bernard 2011-12-07 17:40:12 -06:00
parent 5862def565
commit d78bd3386e
2 changed files with 40 additions and 3 deletions

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<project name="Jonathan Bernard Build Common"> <project name="Jonathan Bernard Build Common"
xmlns:ivy="antlib:org.apache.ivy.ant">
<property environment="env"/> <property environment="env"/>
@ -16,6 +17,7 @@
<property name="build.dir" value="${basedir}/build"/> <property name="build.dir" value="${basedir}/build"/>
<property name="lib.dir" value="${basedir}/lib"/> <property name="lib.dir" value="${basedir}/lib"/>
<property name="resources.dir" value="${basedir}/resources"/> <property name="resources.dir" value="${basedir}/resources"/>
<property name="splash.image" value="splash.png"/>
<!--======== PATHS ========--> <!--======== PATHS ========-->
<path id="groovy.classpath"> <path id="groovy.classpath">
@ -71,6 +73,12 @@
conf="compile,runtime"/> conf="compile,runtime"/>
</target> </target>
<target name="-lib-groovy" if="${lib.local}">
<copy todir="${build.dir}/lib/runtime/jar">
<fileset dir="${env.GROOVY_HOME}/embeddable"/>
</copy>
</target>
<target name="-lib-local" if="${lib.local}"> <target name="-lib-local" if="${lib.local}">
<echo message="Resolving libraries locally."/> <echo message="Resolving libraries locally."/>
<mkdir dir="${build.dir}/lib/compile/jar"/> <mkdir dir="${build.dir}/lib/compile/jar"/>
@ -104,7 +112,7 @@
</target> </target>
<!--======== COMPILATION TARGETS ========--> <!--======== COMPILATION TARGETS ========-->
<target name="-compile-groovy" depends="-init,-init-groovy,lib"> <target name="-compile-groovy" depends="-init,-init-groovy,lib,-lib-groovy">
<mkdir dir="${build.dir}/main/classes"/> <mkdir dir="${build.dir}/main/classes"/>
<groovyc srcdir="${src.dir}/main" destdir="${build.dir}/main/classes" <groovyc srcdir="${src.dir}/main" destdir="${build.dir}/main/classes"
includeAntRuntime="false"> includeAntRuntime="false">
@ -186,13 +194,42 @@
</target> </target>
<!--======== BUILD TARGETS ========--> <!--======== BUILD TARGETS ========-->
<target name="-build-modular" <target name="-build-modular-lib" unless="executable.jar"
depends="compile,increment-build-number,resources"> depends="compile,increment-build-number,resources">
<jar destfile="${build.dir}/${name}-${version}.${build.number}.jar" <jar destfile="${build.dir}/${name}-${version}.${build.number}.jar"
basedir="${build.dir}/main/classes"/> basedir="${build.dir}/main/classes"/>
</target> </target>
<target name="-build-modular-executable" if="executable.jar"
depends="compile,increment-build-number,resources">
<pathconvert property="jar.classpath" pathsep=" " refid="runtime-libs">
<mapper>
<chainedmapper>
<!-- remove absolute path -->
<flattenmapper />
<!-- add lib/ prefix -->
<globmapper from="*" to="lib/*" />
</chainedmapper>
</mapper>
</pathconvert>
<jar destfile="${build.dir}/${name}-${version}.${build.number}.jar"
basedir="${build.dir}/main/classes">
<manifest>
<attribute name="Main-Class" value="${main.class}"/>
<attribute name="Class-Path" value="${jar.classpath}"/>
<attribute name="SplashScreen-Image" value="${splash.image}"/>
</manifest>
</jar>
</target>
<target name="-build-modular"
depends="-build-modular-lib,-build-modular-executable"/>
<target name="-build-packed-libs" <target name="-build-packed-libs"
depends="compile,increment-build-number,resources"> depends="compile,increment-build-number,resources">