aboutsummaryrefslogtreecommitdiffstats
path: root/build/cardbasecli.xml
blob: 6490ae6b51b7db49330ece35b0f3e24ae7afa6ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?xml version="1.0"?>
<project name="cardbasecli" default="deploy" basedir="..">
   
	<property name="jar.name" value="cardbase" />
	<property name="src.dir" location="src" />
	<property name="bin.dir" location="bin" />
	<property name="build.dir" location="build" />
	<property name="dist.dir" location="dist" />
	<property name="lib.dir" value="lib" />
	<property name="res.dir" value="res" />
	<property name="main-class" value="eu.equalparts.cardbase.standalone.CardbaseCLI" />
	
	<!-- Clean up temporary directories -->
	<target name="clean" description="clean up">
		<delete dir="${bin.dir}" />
		<delete dir="${dist.dir}" />
	</target>
	
	<!-- Initialise temporary directories -->
	<target name="init">
		<mkdir dir="${bin.dir}" />
	</target>
	
	<!-- External libraries classpath, we don't need sources and javadoc -->
	<path id="classpath">
		<fileset dir="${basedir}/">
			<include name="${res.dir}/*" />
			
			<include name="${lib.dir}/*.jar" />
			<exclude name="${lib.dir}/*sources.jar"/>
			<exclude name="${lib.dir}/*javadoc.jar"/>
		</fileset>
	</path>
	
	<!-- Compile project including external libraries and copy resource files across as well -->
	<target name="compile" depends="init" description="compile the source">
		<javac includeantruntime="false" srcdir="${src.dir}" destdir="${bin.dir}" classpathref="classpath" />
		
		<copy todir="${bin.dir}">
		   <fileset dir="${res.dir}" excludes=""/>
		</copy>
	</target>
	
	<!-- Create the jar and declare the ext libraries in manifest.mf file -->
	<target name="jar" depends="compile" >
		
		<mkdir dir="${dist.dir}" />
	 
		<jar jarfile="${dist.dir}/${jar.name}.jar" basedir="${bin.dir}">
			
			<zipgroupfileset dir="${lib.dir}" includes="*.jar" excludes="*sources.jar, *javadoc.jar" />
			
			<manifest>
				<attribute name="Main-Class" value="${main-class}" />
				<attribute name="Class-Path" value="${classpath.name}" />
			</manifest>
		</jar>
	</target>
	
	<!-- Concatenate a the jar to a pre-set header and chmod 755 it -->
	<target name="shebang" depends="deploy" >
		<concat destfile="${dist.dir}/${jar.name}" binary="yes">
			<fileset dir="${build.dir}" includes="header"/>
			<fileset dir="${dist.dir}" includes="${jar.name}.jar"/>
		</concat>
		
		<chmod file="${dist.dir}/${jar.name}" perm="755"/>
		
	</target>
	
	<!-- Produce a standalone, runnable jar -->
	<target name="deploy" depends="clean, compile, jar" />
	
	<!-- Deploy, add header and set permission to run on Linux -->
	<target name="cli" depends="deploy, shebang" />
	
</project>