-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
194 lines (173 loc) · 7.69 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
<?xml version="1.0" encoding="UTF-8"?>
<!--
- Copyright 2012 Google Inc.
-
- Licensed under the Apache License, Version 2.0 (the "License"); you may not
- use this file except in compliance with the License. You may obtain a copy
- of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- License for the specific language governing permissions and limitations
- under the License.
-->
<project name="gcm-server" default="dist" xmlns:artifact="antlib:org.apache.maven.artifact.ant">
<property name="src" location="src"/>
<property name="test" location="test"/>
<property name="lib" location="lib"/>
<property name="build" location="build"/>
<property name="classes" location="${build}/classes"/>
<property name="test-classes" location="${build}/test-classes"/>
<property name="test-reports" location="${build}/test-reports"/>
<property name="dist" location="dist"/>
<property name="demo-dir" value="${basedir}/../samples/gcm-demo-server"/>
<property name="demo-appengine-dir" value="${basedir}/../samples/gcm-demo-appengine"/>
<!-- define Maven coordinates -->
<property name="groupId" value="com.google.gcm" />
<property name="artifactId" value="gcm-server" />
<property name="version" value="1.0-SNAPSHOT" />
<!-- define artifacts' name, which follows the convention of Maven -->
<property name="jar" value="${dist}/${artifactId}-${version}.jar" />
<property name="javadoc-jar" value="${dist}/${artifactId}-${version}-javadoc.jar"/>
<property name="sources-jar" value="${dist}/${artifactId}-${version}-sources.jar"/>
<!-- defined maven snapshots and staging repository id and url -->
<property name="ossrh-snapshots-repository-url"
value="https://oss.sonatype.org/content/repositories/snapshots" />
<property name="ossrh-staging-repository-url"
value="https://oss.sonatype.org/service/local/staging/deploy/maven2/" />
<!-- there server id in the Maven settings.xml -->
<property name="ossrh-server-id" value="ossrh" />
<path id="compile.classpath">
<fileset dir="${lib}">
<include name="*.jar"/>
</fileset>
</path>
<path id="compile.test.classpath">
<path refid="compile.classpath"/>
<pathelement location="${classes}"/>
</path>
<path id="test.classpath">
<path refid="compile.test.classpath"/>
<pathelement location="${test-classes}"/>
</path>
<target name="clean" description="Clean all artifacts except the dist files.">
<delete dir="${build}"/>
</target>
<target name="full-clean" depends="clean" description="Clean all artifacts including the dist files.">
<delete dir="${dist}"/>
</target>
<target name="init">
<mkdir dir="${classes}"/>
<mkdir dir="${test-classes}"/>
<mkdir dir="${test-reports}"/>
<mkdir dir="${dist}"/>
</target>
<target name="compile" depends="init" description="Compile the Java classes.">
<javac destdir="${classes}" debug="true" srcdir="${src}" target="1.5"
includeantruntime="false">
<classpath refid="compile.classpath"/>
</javac>
</target>
<target name="compile-tests" depends="compile" description="Compile the unit tests.">
<javac destdir="${test-classes}" debug="true" srcdir="${test}" target="1.5"
includeantruntime="false">
<classpath refid="compile.test.classpath"/>
</javac>
</target>
<target name="tests" depends="compile-tests" description="Run the unit tests.">
<junit printsummary="yes" haltonfailure="yes">
<classpath refid="test.classpath"/>
<formatter type="plain"/>
<formatter type="xml"/>
<batchtest fork="yes" todir="${test-reports}">
<fileset dir="${test}">
<include name="**/*Test*.java"/>
</fileset>
</batchtest>
</junit>
</target>
<target name="jar" depends="compile, tests" description="Generate the GCM server library.">
<antcall target="_jar">
<param name="_destfile" value="${jar}"/>
<param name="_basedir" value="${classes}"/>
</antcall>
</target>
<target name="src-jar" description="Generate a JAR with the GCM server library source files.">
<antcall target="_jar">
<param name="_destfile" value="${sources-jar}"/>
<param name="_basedir" value="${src}"/>
</antcall>
</target>
<target name="doc" depends="compile, tests" description="generate documentation">
<javadoc sourcepath="${src}" destdir="${dist}/javadoc">
<classpath>
<fileset dir="${lib}">
<include name="json_simple-1.1.jar"/>
</fileset>
</classpath>
</javadoc>
</target>
<target name="javadoc-jar" depends="doc" description="generate doc jar">
<jar destfile="${javadoc-jar}" basedir="${dist}/javadoc"/>
</target>
<target name="_jar">
<jar destfile="${_destfile}" basedir="${_basedir}">
<manifest>
<attribute name="Implementation-Vendor" value="Google"/>
<attribute name="Implementation-Title"
value="Google Cloud Messaging - server support"/>
<attribute name="Implementation-Version" value="${version}"/>
</manifest>
</jar>
</target>
<target name="dist" depends="jar, src-jar, javadoc-jar" description="Generate all artifacts."/>
<target name="update-demo" depends="jar" description="Generates a new GCM server library JAR and copy it to the demo project.">
<copy file="${jar}" todir="${demo-dir}/WebContent/WEB-INF/lib"/>
<copy file="${jar}" todir="${demo-appengine-dir}/WebContent/WEB-INF/lib"/>
</target>
<target name="stage" depends="dist" description="deploy snapshot version to Maven snapshot repository">
<artifact:mvn>
<arg value="org.apache.maven.plugins:maven-deploy-plugin:2.6:deploy-file" />
<arg value="-Durl=${ossrh-snapshots-repository-url}" />
<arg value="-DrepositoryId=${ossrh-server-id}" />
<arg value="-DpomFile=client-libraries/java/rest-client/pom.xml" />
<arg value="-Dfile=${jar}" />
<arg value="-e" />
</artifact:mvn>
</target>
<!-- before this, update project version (both build.xml and pom.xml) from SNAPSHOT to RELEASE -->
<target name="deploy" depends="dist" description="deploy release version to Maven staging repository">
<!-- sign and deploy the main artifact -->
<artifact:mvn>
<arg value="org.apache.maven.plugins:maven-gpg-plugin:1.3:sign-and-deploy-file" />
<arg value="-Durl=${ossrh-staging-repository-url}" />
<arg value="-DrepositoryId=${ossrh-server-id}" />
<arg value="-DpomFile=client-libraries/java/rest-client/pom.xml" />
<arg value="-Dfile=${jar}" />
<arg value="-Pgpg" />
</artifact:mvn>
<!-- sign and deploy the sources artifact -->
<artifact:mvn>
<arg value="org.apache.maven.plugins:maven-gpg-plugin:1.3:sign-and-deploy-file" />
<arg value="-Durl=${ossrh-staging-repository-url}" />
<arg value="-DrepositoryId=${ossrh-server-id}" />
<arg value="-DpomFile=client-libraries/java/rest-client/pom.xml" />
<arg value="-Dfile=${sources-jar}" />
<arg value="-Dclassifier=sources" />
<arg value="-Pgpg" />
</artifact:mvn>
<!-- sign and deploy the javadoc artifact -->
<artifact:mvn>
<arg value="org.apache.maven.plugins:maven-gpg-plugin:1.3:sign-and-deploy-file" />
<arg value="-Durl=${ossrh-staging-repository-url}" />
<arg value="-DrepositoryId=${ossrh-server-id}" />
<arg value="-DpomFile=client-libraries/java/rest-client/pom.xml" />
<arg value="-Dfile=${javadoc-jar}" />
<arg value="-Dclassifier=javadoc" />
<arg value="-Pgpg" />
</artifact:mvn>
</target>
</project>