forked from jbellis/jamm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
205 lines (181 loc) · 8.52 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
201
202
203
204
205
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project basedir="." default="build" name="jamm" xmlns:ivy="antlib:org.apache.ivy.ant">
<property name="debuglevel" value="source,lines,vars"/>
<property name="version" value="0.3.2-SNAPSHOT"/>
<property name="basedir" value="."/>
<property name="build.src" value="${basedir}/src"/>
<property name="build.dir" value="${basedir}/target"/>
<property name="build.lib" value="${build.dir}/lib"/>
<property name="build.classes" value="${build.dir}/classes"/>
<property name="build.javadoc" value="${build.dir}/javadoc"/>
<property name="build.sonatype" value="${build.dir}/sonatype"/>
<property name="jar.name" value="jamm-${version}.jar"/>
<property name="jar.src.name" value="jamm-${version}-sources.jar"/>
<property name="jar.javadoc.name" value="jamm-${version}-javadoc.jar"/>
<property name="jar.pom.name" value="jamm-${version}.pom"/>
<property name="test.src" value="${basedir}/test"/>
<property name="test.classes" value="${build.dir}/test/classes"/>
<property name="test.out" value="${build.dir}/test/output"/>
<property name="test.name" value="*Test"/>
<property name="ivy.version" value="2.1.0" />
<property name="ivy.url"
value="http://repo2.maven.org/maven2/org/apache/ivy/ivy" />
<condition property="ivy.jar.exists">
<available file="${build.dir}/ivy-${ivy.version}.jar" />
</condition>
<target name="ivy-download" unless="ivy.jar.exists">
<echo>Downloading Ivy...</echo>
<mkdir dir="${build.dir}" />
<get src="${ivy.url}/${ivy.version}/ivy-${ivy.version}.jar"
dest="${build.dir}/ivy-${ivy.version}.jar" usetimestamp="true" />
</target>
<target name="ivy-init" depends="ivy-download" unless="ivy.initialized">
<mkdir dir="${build.lib}"/>
<taskdef resource="org/apache/ivy/ant/antlib.xml"
uri="antlib:org.apache.ivy.ant"
classpathref="autoivy.classpath"/>
<property name="ivy.initialized" value="true"/>
</target>
<target name="ivy-retrieve-build" depends="ivy-init">
<ivy:retrieve type="jar,source" sync="true"
pattern="${build.lib}/[type]s/[artifact]-[revision].[ext]" />
</target>
<path id="autoivy.classpath">
<fileset dir="${build.lib}">
<include name="**/*.jar" />
</fileset>
<pathelement location="${build.dir}/ivy-${ivy.version}.jar"/>
</path>
<target name="init" depends="ivy-retrieve-build">
<mkdir dir="${build.classes}"/>
<mkdir dir="${test.classes}"/>
</target>
<target name="clean" description="deletes generated artifacts">
<delete dir="${build.dir}"/>
</target>
<target depends="init" name="build">
<echo message="${ant.project.name}: ${ant.file}"/>
<javac source="1.6" target="1.6" debug="true" debuglevel="${debuglevel}" destdir="${build.classes}" includeantruntime="false">
<src path="${build.src}"/>
<compilerarg value="-XDignore.symbol.file"/>
</javac>
</target>
<target name="jar" depends="build" description="generates the jamm jar">
<jar jarfile="${build.dir}/${jar.name}" basedir="${build.classes}">
<manifest>
<!-- see http://download.oracle.com/javase/6/docs/api/java/lang/instrument/package-summary.html -->
<attribute name="Agent-Class" value="org.github.jamm.MemoryMeter"/>
<attribute name="Premain-Class" value="org.github.jamm.MemoryMeter"/>
</manifest>
</jar>
</target>
<target name="build-test" depends="jar" description="Compile test classes">
<javac source="1.6" target="1.6" debug="true" debuglevel="${debuglevel}" destdir="${test.classes}" includeantruntime="false">
<classpath>
<path refid="autoivy.classpath"/>
<pathelement location="${build.classes}"/>
</classpath>
<src path="${test.src}"/>
<compilerarg value="-XDignore.symbol.file"/>
</javac>
</target>
<target name="checkos">
<condition property="isMac">
<os family="mac"/>
</condition>
</target>
<target name="test" depends="build-test, test-mac" description="runs unit tests">
<echo message="running tests"/>
<mkdir dir="${test.out}"/>
<echo message="Testing with default Java"/>
<junit fork="on" failureproperty="testfailed">
<formatter type="xml" usefile="true"/>
<formatter type="brief" usefile="false"/>
<classpath>
<path refid="autoivy.classpath"/>
<pathelement location="${build.classes}"/>
<pathelement location="${test.classes}"/>
</classpath>
<jvmarg value="-ea"/>
<jvmarg value="-javaagent:${build.dir}/${jar.name}"/>
<batchtest todir="${test.out}">
<fileset dir="${test.classes}" includes="**/${test.name}.class" />
</batchtest>
</junit>
<fail if="testfailed" message="Some test(s) failed."/>
</target>
<target name="test-mac" depends="checkos" if="isMac">
<echo message="Testing with modified object alignment"/>
<junit fork="on" failureproperty="testfailed">
<formatter type="xml" usefile="true"/>
<formatter type="brief" usefile="false"/>
<classpath>
<path refid="autoivy.classpath"/>
<pathelement location="${build.classes}"/>
<pathelement location="${test.classes}"/>
</classpath>
<jvmarg value="-ea"/>
<jvmarg value="-XX:ObjectAlignmentInBytes=16"/>
<jvmarg value="-javaagent:${build.dir}/${jar.name}"/>
<batchtest todir="${test.out}">
<fileset dir="${test.classes}" includes="**/${test.name}.class" />
</batchtest>
</junit>
</target>
<target name="javadoc" depends="build" description="build the javadoc for the project">
<javadoc packagenames="*" sourcepath="${build.src}" classpathref="autoivy.classpath" destdir="${build.javadoc}" windowtitle="jamm api">
<doctitle><![CDATA[<h1>jamm javadoc</h1>]]></doctitle>
</javadoc>
</target>
<target name="srcjar" description="builds the source distribution jar file">
<zip destfile="${build.dir}/${jar.src.name}">
<fileset dir="${basedir}">
<include name="**/*.java" />
<include name="**/*.xml" />
<include name="**/*.license" />
<include name="**/*.txt" />
<exclude name="target"/>
</fileset>
</zip>
</target>
<target name="sonatype" depends="jar,srcjar,javadoc" description="builds a sonatype (maven) bundle">
<delete dir="${build.sonatype}"/>
<mkdir dir="${build.sonatype}"/>
<copy todir="${build.sonatype}" file="${build.dir}/${jar.name}"/>
<copy todir="${build.sonatype}" file="${build.dir}/${jar.src.name}"/>
<jar destfile="${build.sonatype}/${jar.javadoc.name}" basedir="${build.dir}" includes="javadoc/**"/>
<copy tofile="${build.sonatype}/${jar.pom.name}" file="${basedir}/pom.xml"/>
<exec executable="gpg">
<arg value="-abi" />
<arg value="${build.sonatype}/${jar.name}" />
</exec>
<exec executable="gpg">
<arg value="-abi" />
<arg value="${build.sonatype}/${jar.src.name}" />
</exec>
<exec executable="gpg">
<arg value="-abi" />
<arg value="${build.sonatype}/${jar.javadoc.name}" />
</exec>
<exec executable="gpg">
<arg value="-abi" />
<arg value="${build.sonatype}/${jar.pom.name}" />
</exec>
<jar destfile="${build.sonatype}/bundle.jar" basedir="${build.sonatype}" includes="jamm*">
</jar>
</target>
<target name="sonatype-help" description="describes steps needed to publish artifact on sonatype">
<echo message="To publish a jar to maven thru the sonatype oss repository do the following" />
<echo message=" Create a gpg key, using, gpg --gen-key" />
<echo message=" Generate an armored text key, using gpg --armor --export {YOUR_PUBLIC_KEY_ID}"/>
<echo message=" Upload this key to http://keyserver.ubuntu.com" />
<echo message="" />
<echo message="Run ant sonatype to create an upload bundle in ${build.sonatype}/bundle.jar"/>
<echo message=" Make sure that the pom.xml is up to date with what you have in ant's build.xml"/>
<echo message="" />
<echo message="upload this jar at https://oss.sonatype.org" />
<echo message="" />
<echo message="see link for details-> https://docs.sonatype.org/display/Repository/Uploading+3rd-party+Artifacts+to+The+Central+Repository" />
<echo message="====================================================================================================================================" />
</target>
</project>