-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathant__create_runnable_jar.xml
185 lines (126 loc) · 6.01 KB
/
ant__create_runnable_jar.xml
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project default="create_run_jar" name="fastaTrimmer.jar Create Runnable Jar for Jar-in-Jar Loader">
<property name="java_target" value="1.8"/>
<property name="java_source" value="1.8"/>
<property name="java.source.character.set" value="iso-8859-1"/>
<property name="jar.main.class" value="org.uwpr.fasta_trimmer.program.MainProgram" />
<property name="output_runnable_jar" value="fastaTrimmer.jar"/>
<property name="deploy" value="deploy" />
<property name="src" value="src" />
<property name="classes" value="classes" />
<available file=".git" type="dir" property="git.present"/>
<target name="create_run_jar" depends="compile,prepare,git.revision">
<path id="build.classpath">
<fileset dir="lib">
<include name="**/*.jar" />
</fileset>
</path>
<!-- convert classpath to a flat list/string for use in manifest task -->
<pathconvert property="jars.classpath" pathsep=" ">
<path refid="build.classpath" />
<flattenmapper />
</pathconvert>
<property name="final.classpath" value="./ ${jars.classpath}"/>
<echo >Classpath for runnable jar ${final.classpath}</echo>
<jar destfile="deploy/${output_runnable_jar}">
<manifest>
<attribute name="Main-Class" value="org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader"/>
<attribute name="Rsrc-Main-Class"
value="${jar.main.class}"/>
<attribute name="Class-Path" value="."/>
<attribute name="Rsrc-Class-Path" value="${final.classpath}"/>
<attribute name="GIT-last-tag-commit-hash" value="${git.last.tag.and.commit.hash}"/>
<attribute name="GIT-commit-hash" value="${git.last.commit.hash}"/>
<attribute name="Date" value="${build-info.current-date}" />
<attribute name="Time" value="${build-info.current-time}" />
</manifest>
<zipfileset src="jar-in-jar-loader.zip"/>
<fileset dir="${classes}"/>
<zipfileset dir="lib" />
</jar>
</target>
<target name="create_jar_this_project" depends="compile,prepare,git.revision">
<jar destfile="${jar_this_project_dir}/${output_jar_this_project}">
<manifest>
<attribute name="Main-Class" value="${jar.main.class}"/>
<attribute name="GIT-last-tag-commit-hash" value="${git.last.tag.and.commit.hash}"/>
<attribute name="GIT-commit-hash" value="${git.last.commit.hash}"/>
<attribute name="Date" value="${build-info.current-date}" />
<attribute name="Time" value="${build-info.current-time}" />
</manifest>
<fileset dir="${classes}"/>
<fileset dir="${config}"/>
</jar>
</target>
<target name="prepare">
<tstamp prefix="build-info">
<format property="current-date" pattern="d-MMMM-yyyy" locale="en" />
<format property="current-time" pattern="hh:mm:ss a z" locale="en" />
<format property="year-month-day" pattern="yyyy-MM-dd" locale="en" />
</tstamp>
</target>
<target name="git.revision"
description="Store git revision in ${git.last.tag.and.commit.hash} and ${git.last.commit.hash}"
if="git.present">
<exec executable="git" outputproperty="git.last.tag.and.commit.hash.from.cmd" failifexecutionfails="false" errorproperty="">
<arg value="describe"/>
<arg value="--tags"/>
<arg value="--always"/>
<arg value="HEAD"/>
</exec>
<echo message="git.last.tag.and.commit.hash.from.cmd: ${git.last.tag.and.commit.hash.from.cmd}"/>
<condition property="git.last.tag.and.commit.hash" value="${git.last.tag.and.commit.hash.from.cmd}" else="unknown">
<and>
<isset property="git.last.tag.and.commit.hash.from.cmd"/>
<length string="${git.last.tag.and.commit.hash.from.cmd}" trim="yes" length="0" when="greater"/>
</and>
</condition>
<echo message="git.last.tag.and.commit.hash: ${git.last.tag.and.commit.hash}"/>
<exec executable="git" outputproperty="git.last.commit.hash.from.cmd" failifexecutionfails="false" errorproperty="">
<arg value="describe"/>
<arg value="--always"/>
<arg value="HEAD"/>
</exec>
<echo message="git.last.commit.hash.from.cmd: ${git.last.commit.hash.from.cmd}"/>
<condition property="git.last.commit.hash" value="${git.last.commit.hash.from.cmd}" else="unknown">
<and>
<isset property="git.last.commit.hash.from.cmd"/>
<length string="${git.last.commit.hash.from.cmd}" trim="yes" length="0" when="greater"/>
</and>
</condition>
<echo message="git.last.commit.hash: ${git.last.commit.hash}"/>
</target>
<!-- ================================================================================== -->
<!-- Clean the build directory -->
<!-- ================================================================================== -->
<target name="clean" description="Prepare for clean build">
<delete dir="${classes}"/>
<mkdir dir="${classes}"/>
<delete dir="${deploy}" />
<mkdir dir="${deploy}"/>
</target>
<!-- ================================================================================== -->
<!-- Normal build of application -->
<!-- ================================================================================== -->
<target name="compile" depends="clean">
<!-- <echo message="${toString:compile.classpath}"/> -->
<javac includeantruntime="false" debug="on" srcdir="src" destdir="${classes}" source="${java_source}" target="${java_target}" encoding="${java.source.character.set}" >
<classpath refid="compile.classpath"/>
</javac>
<!--
<copy todir="${classes}">
</copy>
-->
<copy todir="${classes}">
<fileset dir="${src}">
<exclude name="**/*.java" />
</fileset>
</copy>
</target>
<!-- classpath -->
<path id="compile.classpath">
<fileset dir="lib">
<include name="**/*.jar"/>
</fileset>
</path>
</project>