summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Hudson <nick.hudson@isode.com>2013-10-29 16:02:20 (GMT)
committerNick Hudson <nick.hudson@isode.com>2013-10-29 16:26:50 (GMT)
commitb2f5e0d7c7409ef78ff83708e9ba068f6f0ad535 (patch)
treee049bd45e223b9ba19db3ee19a5a1e2b86261e4b
parentbd9407d3f0ef8a1f94fedc5b68fc1e05c129b562 (diff)
downloadstroke-b2f5e0d7c7409ef78ff83708e9ba068f6f0ad535.zip
stroke-b2f5e0d7c7409ef78ff83708e9ba068f6f0ad535.tar.bz2
Enable building of jar file without examples
The example code includes references to Swing, which isn't available for all environments (e.g. Android) and so this change provides an alternate build target to allow stroke.jar to be built without processing the example code. The original "dist" target was incorrect in the way it was creating the jar file, because it was creating a standalone MANIFEST.MF file (which didn't get used for the jar file at all). So that has been corrected (for the dist-with-examples target). So if now do % ant -Dnoexamples=1 Tnen no examples will be built. If you do % ant then the jar file will include examples (as before) and will also have a manifest that specifies "Main-class" properly. Note that this change has already been made to the isode repository and will not need applying there. Test-information: Tested building with/without examples. The jar file appears correct in each case. Prior to this patch, saying "java -jar stroke.jar" did not work, because the manifest wasn't being used properly. After this patch, it does (for the jar file that includes examples). Change-Id: I68eadc4355cb655dd31e6afec48405a6fe2c057e Signed-off-by: Nick Hudson <nick.hudson@isode.com>
-rw-r--r--build.xml58
1 files changed, 43 insertions, 15 deletions
diff --git a/build.xml b/build.xml
index 72cc618..7fe424c 100644
--- a/build.xml
+++ b/build.xml
@@ -44,32 +44,60 @@
<mkdir dir="${build}"/>
</target>
- <target name="compile" depends="init"
- description="compile the source " >
- <javac srcdir="${src}" destdir="${build}" classpathref="classpath"
- debug="${compile.debug}"
- source="1.6"
- target="1.6">
+ <target name="-compile-with-examples" depends="init"
+ description="compile the source, including examples "
+ unless="noexamples">
+ <javac srcdir="${src}" destdir="${build}" classpathref="classpath"
+ debug="${compile.debug}"
+ source="1.6"
+ target="1.6">
+ <compilerarg line="-encoding utf-8"/>
+ </javac>
+ </target>
+
+ <target name="-compile-without-examples" depends="init"
+ description="compile the source, excluding examples "
+ if="noexamples">
+ <javac srcdir="${src}" destdir="${build}" classpathref="classpath"
+ debug="${compile.debug}"
+ source="1.6"
+ target="1.6">
+ <exclude name="com/isode/stroke/examples/**"/>
<compilerarg line="-encoding utf-8"/>
</javac>
</target>
- <target name="dist" depends="compile"
- description="generate the distribution" >
+
+ <target name="dist" depends="-dist-with-examples,-dist-without-examples"/>
+
+ <target name="-dist-with-examples" depends="-compile-with-examples"
+ description="generate the distribution including examples"
+ unless="noexamples">
+ <mkdir dir="${dist}/lib"/>
+
+ <jar jarfile="${jar}" basedir="${build}">
+ <manifest>
+ <attribute name="Main-Class" value="${main-class}"/>
+ </manifest>
+ </jar>
+ </target>
+
+ <target name="-dist-without-examples" depends="-compile-without-examples"
+ description="generate the distribution excluding examples"
+ if="noexamples">
<mkdir dir="${dist}/lib"/>
- <jar jarfile="${jar}" basedir="${build}"/>
- <manifest file="MANIFEST.MF">
- <attribute name="Main-Class" value="${main-class}"/>
- </manifest>
+ <jar jarfile="${jar}" basedir="${build}">
+ </jar>
</target>
+
<target name="compile-tests" depends="dist"
description="compile the test sources " >
- <javac srcdir="${src.tests}" destdir="${src.tests}"
+ <javac srcdir="${src.tests}" destdir="${src.tests}"
debug="${compile.debug}"
- source="1.6"
- target="1.6">
+ source="1.6"
+ target="1.6">
<compilerarg line="-encoding utf-8"/>
<classpath>
<pathelement location="${jar}"/>