forked from polydawn/mdm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
200 lines (168 loc) · 6.02 KB
/
build.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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ant-project>
<project name="mdm" basedir="." default="dist">
<description>
Modern Dependancy Management automates the organization of a project and the
libraries it depends on with clever git submodules, giving you a project
structure that is:
- strongly versioned and guaranteed repeatable builds!
- checking out a project gives you exactly everything you need to do a build!
- your repository doesn't bloat over time and doing a fresh clone ships you
the bare minimum number of bytes that you need!
</description>
<property name="app" value="mdm"/>
<property name="exus.build.java.version.source" value="1.6"/>
<property name="exus.build.java.version.target" value="1.6"/>
<exec executable="git" failonerror="true">
<arg value="submodule"/>
<arg value="update"/>
<arg value="--init"/>
<arg value="lib/exus-build"/>
</exec>
<import file="lib/exus-build/build-exultant.xml"/>
<import file="lib/exus-build/build-exultant-java.xml"/>
<import file="lib/exus-build/bootstrap-mdm.xml"/>
<target name="bootstrap"
depends="-bootstrap-mdm-modules">
</target>
<target name="init"
depends="exusInit,bootstrap">
</target>
<path id="mdm.path.deps.main" cache="true">
<pathelement location="${lib}/jgit/org.eclipse.jgit.jar"/>
<pathelement location="${lib}/ahslib/ahslib-core.jar"/>
<pathelement location="${lib}/argparse4j/argparse4j.jar"/>
<pathelement location="${lib}/jsch/jsch.jar"/>
<pathelement location="${lib}/commons-lang/commons-lang.jar"/>
</path>
<path id="mdm.path.main">
<path refid="mdm.path.deps.main" />
<pathelement location="${target.javac}/main" />
</path>
<path id="mdm.path.deps.test">
<path refid="mdm.path.main" />
<pathelement location="${lib}/josh/josh.jar"/>
<pathelement location="${lib}/junit/junit.jar"/>
<pathelement location="${target.javac}/test-fixtures" />
</path>
<path id="mdm.path.test">
<path refid="mdm.path.deps.test" />
<pathelement location="${target.javac}/test-unit" />
<pathelement location="${target.javac}/test-integration" />
</path>
<target name="compile" depends="init" description="compile the source">
<exusJavac
classes="net/polydawn/${app}/Mdm.java"
>
<classpath refid="mdm.path.deps.main" />
</exusJavac>
</target>
<target name="dist"
depends="compile"
description="pack distributable artifacts">
<exusPack destfile="${dist}/${app}">
<manifest>
<attribute name="Main-Class" value="net.polydawn.${app}.Mdm"/>
</manifest>
<fileset file="${target.javac}/main/**"/>
<zipfileset src="${lib}/jgit/org.eclipse.jgit.jar" includes="**/*.class org/**/*.properties"/>
<zipfileset src="${lib}/ahslib/ahslib-core.jar" includes="**/*.class"/>
<zipfileset src="${lib}/argparse4j/argparse4j.jar" includes="**/*.class"/>
<zipfileset src="${lib}/jsch/jsch.jar" includes="**/*.class"/>
<zipfileset src="${lib}/commons-lang/commons-lang.jar" includes="**/*.class"/>
</exusPack>
<chmod file="${dist}/${app}" perm="755"/>
</target>
<!-- Mac doesn't put things in the standard location -->
<condition property="mdm.java.lib.path" value="${java.home}/../Classes/classes.jar" else="${java.home}/lib/rt.jar">
<os family="mac" />
</condition>
<target name="dist-packed" depends="dist"
description="minify distributable artifact to contain only needed classes">
<move file="${dist}/${app}" tofile="${dist}/${app}-loose.jar"/>
<taskdef resource="proguard/ant/task.properties"
classpath="lib/proguard/proguard.jar" />
<proguard>
-libraryjars ${mdm.java.lib.path}
-injars ${dist}/${app}-loose.jar
-outjars ${dist}/${app}-packed.jar
-dontoptimize
-dontobfuscate
-dontwarn
-dontnote
-keepclasseswithmembers public class * {
public static void main(java.lang.String[]);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class com.jcraft.jsch.** { *; }
</proguard>
<delete file="${dist}/${app}-loose.jar"/>
<exusJavaBang
src="${dist}/${app}-packed.jar"
dest="${dist}/${app}"
/>
<delete file="${dist}/${app}-packed.jar"/>
<chmod file="${dist}/${app}" perm="755"/>
</target>
<target name="clean" description="clean up">
<delete dir="${target}"/>
</target>
<target name="run-mdma"
depends="dist-packed"
description="runs the 'mdma' acceptance test script"
>
<!-- actually, just running this in a shell can be nicer since then you don't have ant dicking up your output buffering in strange ways:
ant clean dist && export MDM=$(pwd)/dist/mdm MDMA=$(pwd)/mdma.sh && ( cd /tmp/ ; rm -rf mdm-demo/ ; $MDMA -t )
-->
<delete dir="mdm-demo" />
<exec executable="mdma.sh" failonerror="true">
<env key="MDM" value="${basedir}/${dist}/${app}" />
<arg value="-t" />
</exec>
</target>
<target name="compile-test" depends="compile">
<exusJavac
tree="test-fixtures"
depends="${toString:mdm.path.deps.test}"
/>
<exusJavac
tree="test-unit"
depends="${toString:mdm.path.deps.test}"
/>
<exusJavac
tree="test-integration"
depends="${toString:mdm.path.deps.test}"
/>
</target>
<target name="run-test"
depends="compile, compile-test"
description="runs junit tests"
>
<property name="mdm.test.dir" value="${java.io.tmpdir}/mdm-test"/>
<mkdir dir="${mdm.test.dir}"/>
<property name="keep" value="false"/>
<junit printsummary="off" haltonfailure="yes" dir="${mdm.test.dir}" newenvironment="true">
<sysproperty key="keep" value="${keep}"/>
<formatter type="plain" usefile="false" />
<classpath refid="mdm.path.test"/>
<batchtest fork="yes">
<fileset dir="${target.javac}/test-unit">
<include name="**/*Test*.class"/>
</fileset>
<fileset dir="${target.javac}/test-integration">
<include name="**/*Test*.class"/>
</fileset>
</batchtest>
</junit>
</target>
<target name="release" depends="clean, dist-packed">
<exec executable="${dist}/mdm">
<arg value="release" />
<arg value="--version=${version}" />
<arg value="--files=${dist}" />
</exec>
</target>
</project>