forked from parautenbach/TeamCity-HipChat-Notifier
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
180 lines (165 loc) · 7.27 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
<project name="lights-notifier" default="compile" basedir=".">
<description>
TeamCity notifier plugin to send messages to a HipChat room.
</description>
<property environment="env"/>
<property name="src" location="src"/>
<property name="classes" location="classes"/>
<property name="resources" location="src/resources"/>
<property name="build" location="build"/>
<property name="reports" location="reports"/>
<property name="main-class" value="HipChatNotifier"/>
<!-- Default to 0.0.0.0 if no version specified -->
<condition property="version" value="${env.BUILD_NUMBER}" else="0.7.1">
<and>
<isset property="env.BUILD_NUMBER"/>
<not>
<matches string="${env.BUILD_NUMBER}" pattern="^$"/>
</not>
</and>
</condition>
<!-- Default to a final tag if no tag type specified -->
<condition property="tag-type" value="${env.EXECUTE_TAGGING_TYPE}" else="final">
<and>
<isset property="env.EXECUTE_TAGGING_TYPE"/>
<not>
<matches string="${env.EXECUTE_TAGGING_TYPE}" pattern="^$"/>
</not>
</and>
</condition>
<property name="vendor" value="What's That Light?"/>
<!-- Determines whether to include a version etc. in the JAR's filename -->
<condition property="jar" value="${main-class}-${version}-${tag-type}" else="${main-class}">
<matches string="${env.MUST_VERSION_ARTIFACTS}" pattern="^-?true|yes|1$" casesensitive="false"/>
</condition>
<property name="lib" value="lib"/>
<property name="teamcity.home" location="${user.home}/TeamCity"/>
<property name="teamcity.appdir" location="${teamcity.home}/webapps/ROOT/WEB-INF"/>
<property name="junit.home" value="lib/junit"/>
<property name="manifest" value="MANIFEST.MF"/>
<property name="plugin.xml" value="teamcity-plugin.xml"/>
<property name="plugin-bean.xml" value="build-server-plugin-hipchat-notifier.xml"/>
<property name="versiontag" value="<version>${version}</version>"/>
<property name="coverage.dir" value="coverage" />
<property name="testng.dir" value="testng" />
<path id="classpath">
<fileset dir="${lib}">
<include name="**/*.jar"/>
</fileset>
<pathelement location="${classes}"/>
<pathelement location="${teamcity.appdir}/classes"/>
<fileset dir="${teamcity.home}/lib" includes="*.jar"/>
<fileset dir="${teamcity.home}/devPackage/tests" includes="*.jar"/>
<fileset dir="${teamcity.appdir}/lib" includes="*.jar" excludes="${main-class}*.jar"/>
</path>
<manifestclasspath property="manifest.classpath" jarfile="${jar}.jar" maxParentLevels="7">
<classpath refid="classpath" />
</manifestclasspath>
<path id="emma.lib">
<pathelement location="${lib}/emma-2.1.5320/emma.jar" />
<pathelement location="${lib}/emma-2.1.5320/emma_ant.jar" />
</path>
<taskdef resource="emma_ant.properties" classpathref="emma.lib" />
<taskdef name="testng" classname="org.testng.TestNGAntTask">
<classpath refid="classpath" />
</taskdef>
<target name="init">
<echo>
Source: ${src}
Classes: ${classes}
Classpath: ${manifest.classpath}
Resources: ${resources}
Build: ${build}
Reports: ${reports}
Coverage: ${coverage.dir}
Main Class: ${main-class}
Version: ${version}
Version Tag: ${versiontag}
Vendor: ${vendor}
Tag Type: ${tag-type}
Jar Name ${jar}
Library path: ${lib}
JUnit Home: ${junit.home}
TeamCity Home: ${teamcity.home}
TeamCity App: ${teamcity.appdir}
</echo>
</target>
<target name="compile" depends="init" description="Compile the source code" >
<mkdir dir="${classes}"/>
<javac srcdir="${src}" destdir="${classes}" classpathref="classpath" includeAntRuntime="false" debug="on"/>
<!-- Create manifest on disk to make it easy to view during development -->
<!-- Help: http://java.sun.com/developer/Books/javaprogramming/JAR/basics/manifest.html -->
<!-- http://docs.oracle.com/javase/1.4.2/docs/guide/versioning/spec/versioning2.html -->
<manifest file="${manifest}">
<attribute name="Built-By" value="${user.name}" />
<attribute name="Main-Class" value="${main-class}" />
<attribute name="Class-Path" value="${manifest.classpath}"/>
<attribute name="Specification-Title" value="${main-class}" />
<attribute name="Specification-Version" value="${version}" />
<attribute name="Specification-Vendor" value="${vendor}" />
<attribute name="Implementation-Title" value="${main-class}" />
<attribute name="Implementation-Version" value="${version}" />
<attribute name="Implementation-Vendor" value="${vendor}" />
</manifest>
</target>
<!-- http://stackoverflow.com/questions/52984/how-do-i-generate-emma-code-coverage-reports-using-ant -->
<target name="emma" description="turns on EMMA's on-the-fly instrumentation mode" >
<property name="emma.enabled" value="true" />
<property name="emma.filter" value="-com.whatsthatlight.teamcity.hipchat.test.*"/>
</target>
<target name="test" depends="emma,compile" description="Run tests">
<mkdir dir="${coverage.dir}"/>
<emma enabled="${emma.enabled}" verbosity="verbose">
<instr instrpath="${classes}" mode="overwrite" metadatafile="${coverage.dir}/metadata.emma">
<filter value="${emma.filter}"/>
</instr>
</emma>
<testng failureProperty="tests.failed" outputdir="${testng.dir}" haltonfailure="true" >
<classpath refid="classpath">
</classpath>
<xmlfileset dir="." includes="testng.xml"/>
<jvmarg value="-Demma.coverage.out.file=${coverage.dir}/coverage.emma"/>
<jvmarg value="-Demma.coverage.out.merge=false"/>
</testng>
<emma enabled="${emma.enabled}">
<report sourcepath="src" sort="+block,+name,+method,+class,+line" metrics="method:100,block:100,line:100,class:100,line:100">
<fileset dir="${coverage.dir}">
<include name="*.emma"/>
</fileset>
<txt outfile="${coverage.dir}/coverage.txt" depth="package" columns="class,method,block,line,name"/>
<xml outfile="${coverage.dir}/coverage.xml" depth="package"/>
<html outfile="${coverage.dir}/coverage.html" depth="method" columns="name,class,method,block,line"/>
</report>
</emma>
</target>
<target name="release" depends="compile" description="Generate the distribution" >
<replaceregexp file="teamcity-plugin.xml" match="<version>.*?</version>" replace="${versiontag}" />
<mkdir dir="${build}"/>
<copy file="${plugin.xml}" todir="${build}"/>
<jar jarfile="${build}/${jar}.jar" manifest="${manifest}" basedir="${build}">
<metainf dir="${src}/META-INF"/>
<fileset dir="${classes}" excludes="**/test/**"/>
<fileset dir="${resources}"/>
</jar>
<mkdir dir="${build}/${lib}"/>
<copy todir="${build}/${lib}">
<fileset dir="${lib}" includes="**"/>
</copy>
<zip basedir="${build}" destfile="${jar}.zip" includes="${jar}.jar,${plugin.xml},${lib}/**"/>
<move file="${jar}.zip" todir="${build}"/>
<delete file="${build}/${jar}.jar"/>
<delete file="${build}/${plugin.xml}"/>
<delete dir="${build}/${lib}"/>
</target>
<target name="run" depends="release">
<java jar="${build}/${jar}.jar" fork="true" />
</target>
<target name="clean" description="Clean up">
<delete dir="${classes}"/>
<delete dir="${build}"/>
<delete dir="${reports}"/>
<delete dir="${coverage.dir}"/>
<delete dir="${testng.dir}"/>
<delete file="${manifest}"/>
</target>
</project>