Added an Ant build file and a small SPI test
[kaka/cakelight.git] / build.xml
1 <?xml version="1.0" encoding="UTF-8"?>
2 <project name="cakelight" default="all">
3   
4   
5   <property file="config.properties"/>
6   <property name="jdk.home.1.8" value="/usr/lib/jvm/java-8-openjdk-amd64" />
7   <!-- Uncomment the following property if no tests compilation is needed -->
8   <!-- 
9   <property name="skip.tests" value="true"/>
10    -->
11   
12   <!-- Compiler options -->
13   
14   <property name="compiler.debug" value="on"/>
15   <property name="compiler.generate.no.warnings" value="off"/>
16   <property name="compiler.args" value=""/>
17   <property name="compiler.max.memory" value="700m"/>
18   <patternset id="ignored.files">
19     <exclude name="**/*.hprof/**"/>
20     <exclude name="**/*.pyc/**"/>
21     <exclude name="**/*.pyo/**"/>
22     <exclude name="**/*.rbc/**"/>
23     <exclude name="**/*.yarb/**"/>
24     <exclude name="**/*~/**"/>
25     <exclude name="**/.DS_Store/**"/>
26     <exclude name="**/.git/**"/>
27     <exclude name="**/.hg/**"/>
28     <exclude name="**/.svn/**"/>
29     <exclude name="**/CVS/**"/>
30     <exclude name="**/__pycache__/**"/>
31     <exclude name="**/_svn/**"/>
32     <exclude name="**/vssver.scc/**"/>
33     <exclude name="**/vssver2.scc/**"/>
34   </patternset>
35   <patternset id="library.patterns">
36     <include name="*.war"/>
37     <include name="*.swc"/>
38     <include name="*.zip"/>
39     <include name="*.egg"/>
40     <include name="*.ane"/>
41     <include name="*.jar"/>
42     <include name="*.ear"/>
43   </patternset>
44   <patternset id="compiler.resources">
45     <exclude name="**/?*.java"/>
46     <exclude name="**/?*.form"/>
47     <exclude name="**/?*.class"/>
48     <exclude name="**/?*.groovy"/>
49     <exclude name="**/?*.scala"/>
50     <exclude name="**/?*.flex"/>
51     <exclude name="**/?*.kt"/>
52     <exclude name="**/?*.clj"/>
53     <exclude name="**/?*.aj"/>
54   </patternset>
55   
56   <!-- JDK definitions -->
57   
58   <property name="jdk.bin.1.8" value="${jdk.home.1.8}/bin"/>
59   <path id="jdk.classpath.1.8">
60     <fileset dir="${jdk.home.1.8}">
61       <include name="jre/lib/charsets.jar"/>
62       <include name="jre/lib/ext/cldrdata.jar"/>
63       <include name="jre/lib/ext/dnsns.jar"/>
64       <include name="jre/lib/ext/icedtea-sound.jar"/>
65       <include name="jre/lib/ext/jaccess.jar"/>
66       <include name="jre/lib/ext/localedata.jar"/>
67       <include name="jre/lib/ext/nashorn.jar"/>
68       <include name="jre/lib/ext/sunec.jar"/>
69       <include name="jre/lib/ext/sunjce_provider.jar"/>
70       <include name="jre/lib/ext/sunpkcs11.jar"/>
71       <include name="jre/lib/ext/zipfs.jar"/>
72       <include name="jre/lib/jce.jar"/>
73       <include name="jre/lib/jsse.jar"/>
74       <include name="jre/lib/management-agent.jar"/>
75       <include name="jre/lib/resources.jar"/>
76       <include name="jre/lib/rt.jar"/>
77       <include name="jre/lib/ext/jfxrt.jar"/>
78     </fileset>
79   </path>
80   
81   <property name="project.jdk.home" value="${jdk.home.1.8}"/>
82   <property name="project.jdk.bin" value="${jdk.bin.1.8}"/>
83   <property name="project.jdk.classpath" value="jdk.classpath.1.8"/>
84   
85   
86   <!-- Project Libraries -->
87   
88   <path id="library.opencv.classpath">
89     <pathelement location="/usr/share/java/opencv.jar"/>
90   </path>
91   
92   <path id="library.pi4j.classpath">
93     <fileset dir="${basedir}/lib/pi4j">
94       <patternset refid="library.patterns"/>
95     </fileset>
96   </path>
97   
98   <!-- Modules -->
99   
100   
101   <!-- Module CakeLight -->
102   
103   <dirname property="module.cakelight.basedir" file="${ant.file}"/>
104   
105   
106   <property name="module.jdk.home.cakelight" value="${project.jdk.home}"/>
107   <property name="module.jdk.bin.cakelight" value="${project.jdk.bin}"/>
108   <property name="module.jdk.classpath.cakelight" value="${project.jdk.classpath}"/>
109   
110   <property name="compiler.args.cakelight" value="-encoding UTF-8 -source 8 -target 8 ${compiler.args}"/>
111   
112   <property name="cakelight.output.dir" value="${module.cakelight.basedir}/out/production/CakeLight"/>
113   <property name="cakelight.testoutput.dir" value="${module.cakelight.basedir}/out/test/CakeLight"/>
114   
115   <path id="cakelight.module.bootclasspath">
116     <!-- Paths to be included in compilation bootclasspath -->
117   </path>
118   
119   <path id="cakelight.module.production.classpath">
120     <path refid="${module.jdk.classpath.cakelight}"/>
121     <path refid="library.opencv.classpath"/>
122     <path refid="library.pi4j.classpath"/>
123   </path>
124   
125   <path id="cakelight.runtime.production.module.classpath">
126     <pathelement location="${cakelight.output.dir}"/>
127     <path refid="library.opencv.classpath"/>
128     <path refid="library.pi4j.classpath"/>
129   </path>
130   
131   <path id="cakelight.module.classpath">
132     <path refid="${module.jdk.classpath.cakelight}"/>
133     <pathelement location="${cakelight.output.dir}"/>
134     <path refid="library.opencv.classpath"/>
135     <path refid="library.pi4j.classpath"/>
136   </path>
137   
138   <path id="cakelight.runtime.module.classpath">
139     <pathelement location="${cakelight.testoutput.dir}"/>
140     <pathelement location="${cakelight.output.dir}"/>
141     <path refid="library.opencv.classpath"/>
142     <path refid="library.pi4j.classpath"/>
143   </path>
144   
145   
146   <patternset id="excluded.from.module.cakelight">
147     <patternset refid="ignored.files"/>
148   </patternset>
149   
150   <patternset id="excluded.from.compilation.cakelight">
151     <patternset refid="excluded.from.module.cakelight"/>
152   </patternset>
153   
154   <path id="cakelight.module.sourcepath">
155     <dirset dir="${module.cakelight.basedir}">
156       <include name="src"/>
157     </dirset>
158   </path>
159   
160   
161   <target name="compile.module.cakelight" depends="compile.module.cakelight.production,compile.module.cakelight.tests" description="Compile module CakeLight"/>
162   
163   <target name="compile.module.cakelight.production" description="Compile module CakeLight; production classes">
164     <mkdir dir="${cakelight.output.dir}"/>
165     <javac destdir="${cakelight.output.dir}" debug="${compiler.debug}" nowarn="${compiler.generate.no.warnings}" memorymaximumsize="${compiler.max.memory}" fork="true" executable="${module.jdk.bin.cakelight}/javac">
166       <compilerarg line="${compiler.args.cakelight}"/>
167       <bootclasspath refid="cakelight.module.bootclasspath"/>
168       <classpath refid="cakelight.module.production.classpath"/>
169       <src refid="cakelight.module.sourcepath"/>
170       <patternset refid="excluded.from.compilation.cakelight"/>
171     </javac>
172     
173     <copy todir="${cakelight.output.dir}">
174       <fileset dir="${module.cakelight.basedir}/src">
175         <patternset refid="compiler.resources"/>
176         <type type="file"/>
177       </fileset>
178     </copy>
179
180     <jar destfile="${cakelight.output.dir}/cakelight.jar">
181       <fileset dir="${cakelight.output.dir}" />
182       <!-- TODO replace hard links -->
183       <zipfileset includes="**/*.class" src="${module.cakelight.basedir}/lib/pi4j/pi4j-core.jar" />
184       <zipfileset includes="**/*.class" src="/usr/share/java/opencv.jar" />
185       <manifest>
186         <attribute name="Main-Class" value="kaka.cakelight.LedController" />
187       </manifest>
188     </jar>
189   </target>
190   
191   <target name="compile.module.cakelight.tests" depends="compile.module.cakelight.production" description="compile module CakeLight; test classes" unless="skip.tests"/>
192   
193   <target name="clean.module.cakelight" description="cleanup module">
194     <delete dir="${cakelight.output.dir}"/>
195     <delete dir="${cakelight.testoutput.dir}"/>
196   </target>
197   
198   <target name="init" description="Build initialization">
199     <!-- Perform any build initialization in this target -->
200   </target>
201   
202   <target name="clean" depends="clean.module.cakelight" description="cleanup all"/>
203   
204   <target name="build.modules" depends="init, clean, compile.module.cakelight" description="build all modules"/>
205   
206   <target name="all" depends="build.modules" description="build all"/>
207 </project>