-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
122 lines (108 loc) · 6.83 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
<?xml version="1.0" encoding="utf-8" ?>
<project name="tatin" default="snapshot" basedir=".">
<property name="target.version" value="0.0.2"/>
<property name="build.dir" value="${basedir}/build"/>
<tstamp><format property="build.number" pattern="yyyyMMddHHmmss" timezone="GMT"/></tstamp>
<tstamp><format property="build.timestamp" pattern="yyyy-MM-dd HH:mm:ss" timezone="GMT"/></tstamp>
<macrodef name="jar-module">
<attribute name="modulename"/>
<attribute name="moduleversion"/>
<attribute name="depsjar"/>
<attribute name="manifest"/>
<sequential>
<mkdir dir="${build.dir}/@{modulename}.classes"/>
<javac srcdir="${basedir}/src/@{modulename}/java" destdir="${build.dir}/@{modulename}.classes" includes="**"
includeantruntime="false" encoding="utf-8" source="1.6" target="1.6" debug="true" debuglevel="lines,source"
classpath="@{depsjar}:${build.dir}/${ant.project.name}-main-@{moduleversion}.jar"/>
<jar destfile="${build.dir}/${ant.project.name}-@{modulename}-@{moduleversion}.jar" manifest="@{manifest}">
<fileset dir="${build.dir}/@{modulename}.classes"/>
<fileset dir="${basedir}" includes="LICENSE NOTICE README.md"/>
<zipfileset src="@{depsjar}" excludes="**/META-INF/**"/>
</jar>
<jar destfile="${build.dir}/${ant.project.name}-@{modulename}-@{moduleversion}-sources.jar" manifest="@{manifest}">
<fileset dir="${basedir}/src/@{modulename}/java"/>
<fileset dir="${basedir}" includes="LICENSE NOTICE README.md"/>
</jar>
</sequential>
</macrodef>
<macrodef name="run-tests">
<attribute name="testmodulename"/>
<attribute name="moduleversion"/>
<sequential>
<mkdir dir="${build.dir}/@{testmodulename}.testreport"/>
<mkdir dir="${build.dir}/@{testmodulename}.tmp"/>
<junit printsummary="yes" haltonfailure="yes" forkmode="once" tempdir="${build.dir}/@{testmodulename}.tmp">
<classpath>
<pathelement location="${build.dir}/${ant.project.name}-main-@{moduleversion}.jar"/>
<pathelement location="${build.dir}/${ant.project.name}-@{testmodulename}-@{moduleversion}.jar"/>
</classpath>
<formatter type="xml"/>
<batchtest fork="yes" todir="${build.dir}/@{testmodulename}.testreport">
<zipfileset src="${build.dir}/${ant.project.name}-@{testmodulename}-@{moduleversion}.jar">
<include name="org.netmelody.tatin/**/*Test.class"/>
</zipfileset>
</batchtest>
</junit>
</sequential>
</macrodef>
<target name="-version-for-snapshot" unless="version.label">
<property name="version.label" value="${target.version}-SNAPSHOT-${build.number}"/>
</target>
<target name="-version-for-release" unless="version.label">
<property name="version.label" value="${target.version}"/>
</target>
<target name="-version" depends="-version-for-snapshot,-version-for-release">
<echo message="Building version ${version.label}"/>
</target>
<target name="-pack-deps">
<zip destfile="${build.dir}/main-compiledeps.jar"><zipgroupfileset dir="${basedir}/vendor/lib" includes="**/*.jar"/></zip>
<zip destfile="${build.dir}/test-compiledeps.jar"><zipgroupfileset dir="${basedir}/vendor/buildlib" includes="**/*.jar"/></zip>
</target>
<target name="-jar-javadoc">
<mkdir dir="${build.dir}/javadoc"/>
<javadoc packagenames="org.netmelody.${ant.project.name}.*" sourcepath="src/main/java" defaultexcludes="yes"
destdir="${build.dir}/javadoc" author="true" version="true" use="true" windowtitle="${ant.project.name}"
classpath="${build.dir}/main-compiledeps.jar" />
<jar destfile="${build.dir}/${ant.project.name}-main-${version.label}-javadoc.jar" manifest="${build.dir}/MANIFEST.MF">
<fileset dir="${build.dir}/javadoc"/>
<fileset dir="${basedir}" includes="LICENSE NOTICE README.md"/>
</jar>
</target>
<target name="clean" description="Clean this project">
<delete dir="${build.dir}" failonerror="false"/>
<mkdir dir="${build.dir}"/>
</target>
<target name="jar" description="Create Jar files" depends="clean,-version,-pack-deps">
<manifest file="${build.dir}/MANIFEST.MF">
<attribute name="Main-Class" value="org.netmelody.tatin.Tatin"/>
<attribute name="Implementation-Title" value="${ant.project.name}"/>
<attribute name="Implementation-Vendor" value="netmelody"/>
<attribute name="Implementation-Version" value="${version.label}"/>
<attribute name="Built-By" value="${user.name}"/>
<attribute name="Built-Date" value="${build.timestamp}"/>
</manifest>
<jar-module modulename="main" moduleversion="${version.label}" depsjar="${build.dir}/main-compiledeps.jar" manifest="${build.dir}/MANIFEST.MF"/>
<jar-module modulename="test" moduleversion="${version.label}" depsjar="${build.dir}/test-compiledeps.jar" manifest="${build.dir}/MANIFEST.MF"/>
</target>
<target name="test" description="Test this project" depends="jar">
<run-tests testmodulename="test" moduleversion="${version.label}"/>
</target>
<target name="snapshot" description="Create a tested snapshot jar file" depends="test"/>
<target name="release" description="Create a tested release jar file" depends="-version-for-release,snapshot"/>
<target name="bundle" description="Create a release bundle for deployment to maven central" depends="release,-jar-javadoc">
<copy file="${ant.project.name}.pom" tofile="${build.dir}/${ant.project.name}-${version.label}.pom">
<filterset><filter token="VERSION" value="${version.label}"/></filterset>
</copy>
<move todir="${build.dir}">
<fileset dir="${build.dir}" includes="*-main-*"/>
<mapper type="regexp" from="(.*)-main-(.*)" to="\1-\2"/>
</move>
<exec executable="gpg" dir="${build.dir}"><arg value="-ab"/><arg value="${ant.project.name}-${version.label}.pom"/></exec>
<exec executable="gpg" dir="${build.dir}"><arg value="-ab"/><arg value="${ant.project.name}-${version.label}.jar"/></exec>
<exec executable="gpg" dir="${build.dir}"><arg value="-ab"/><arg value="${ant.project.name}-${version.label}-javadoc.jar"/></exec>
<exec executable="gpg" dir="${build.dir}"><arg value="-ab"/><arg value="${ant.project.name}-${version.label}-sources.jar"/></exec>
<jar destfile="${build.dir}/bundle.jar">
<fileset dir="${build.dir}" includes="${ant.project.name}-${version.label}*"/>
</jar>
</target>
</project>