summaryrefslogtreecommitdiffstats
path: root/common.xml
blob: 8c2919972d10c652585c527bf957ff9c239b9046 (plain)
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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
<?xml version="1.0" encoding="UTF-8"?>
<project name="common" basedir="." default="" xmlns:ivy="antlib:org.apache.ivy.ant" xmlns:antcontrib="antlib:net.sf.antcontrib" xmlns:cs="antlib:com.puppycrawl.tools.checkstyle">

    <tstamp>
        <format property="build.date" pattern="yyyy-MM-dd" />
    </tstamp>

    <dirname property="vaadin.basedir" file="${ant.file.common}" />
    <property name="gwt.basedir" location="${vaadin.basedir}/../gwt" />
    <property file="${vaadin.basedir}/build.properties" />

    <property name="modules.to.publish.to.maven" value="shared,server,client,client-compiler,client-compiled,themes,push,widgets" />
    <property name="modules.to.publish.to.download" value="${modules.to.publish.to.maven},all" />

    <ivy:settings file="${vaadin.basedir}/ivysettings.xml" />
    <ivy:settings file="${vaadin.basedir}/ivysettings.xml" id="ivysettings" />
    <ivy:resolve log="download-only" file="${vaadin.basedir}/ivy-taskdefs.xml" conf="taskdefs" />
    <ivy:cachepath pathid="taskdefs.classpath" conf="taskdefs" />
    <taskdef uri="antlib:net.sf.antcontrib" resource="net/sf/antcontrib/antlib.xml" classpathref="taskdefs.classpath" />
    <!-- ant contrib for Maven integration -->
    <taskdef resource="org/apache/maven/artifact/ant/antlib.xml" uri="antlib:org.apache.maven.artifact.ant" classpathref="taskdefs.classpath" />

    <!-- FIXME These are not available in other files -->
    <antcontrib:propertyregex property="vaadin.version.major" input="${vaadin.version}" regexp="([^\.]*)\.([^\.]*)\.([^\.]*)" select="\1" />
    <antcontrib:propertyregex property="vaadin.version.minor" input="${vaadin.version}" regexp="([^\.]*)\.([^\.]*)\.([^\.]*)" select="\2" />
    <antcontrib:propertyregex property="vaadin.version.revision" input="${vaadin.version}" regexp="([^\.]*)\.([^\.]*)\.([^\.]*)" select="\3" />
    <filterset begintoken="@" endtoken="@" id="filter-vaadin.version">
        <filter token="version" value="${vaadin.version}" />
    </filterset>

    <union id="empty.reference" />

    <target name="pom.xml" description="Generates a pom.xml based on the Ivy configuration. Either for a snapshot or a release version" depends="pom.xml.release,pom.xml.snapshot">
    </target>

    <property name="common.jarfiles.dir" location="${vaadin.basedir}/buildhelpers/result/WebContent" />

    <target name="pom.xml.release" if="build.release">
        <fail unless="result.dir" message="No result.dir parameter given" />
        <property name="ivy.xml" location="${result.dir}/../ivy.xml" />
        <property name="pom.xml" location="${result.dir}/lib/${module.name}-${vaadin.version}.pom" />
        <property name="conf" value="build, build-provided" />
        <property name="vaadin.maven.version" value="${vaadin.version}" />

        <ivy:makepom templatefile="${vaadin.basedir}/pom-template.xml" ivyfile="${ivy.xml}" pomfile="${pom.xml}" conf="${conf}">
            <mapping conf="build" scope="compile" />
            <mapping conf="build-provided" scope="provided" />
        </ivy:makepom>
    </target>

    <target name="pom.xml.snapshot" unless="build.release">
        <fail unless="result.dir" message="No result.dir parameter given" />
        <property name="ivy.xml" location="${result.dir}/../ivy.xml" />
        <property name="pom.xml" location="${result.dir}/lib/${module.name}-${vaadin.version}.pom" />
        <property name="temp.pom.xml" location="${pom.xml}.temp" />
        <property name="conf" value="build, build-provided" />
        <property name="vaadin.maven.version" value="${vaadin.version.major}.${vaadin.version.minor}-SNAPSHOT" />

        <ivy:makepom templatefile="${vaadin.basedir}/pom-template.xml" ivyfile="${ivy.xml}" pomfile="${temp.pom.xml}" conf="${conf}">
            <mapping conf="build" scope="compile" />
            <mapping conf="build-provided" scope="provided" />
        </ivy:makepom>
        <copy file="${temp.pom.xml}" tofile="${pom.xml}">
            <filterchain>
                <replacestring from="${vaadin.version}" to="${vaadin.maven.version}" />
            </filterchain>
        </copy>
        <delete file="${temp.pom.xml}" />
    </target>


    <target name="sources.jar" depends="compile">
        <fail unless="result.dir" message="No result.dir parameter given" />
        <fail unless="module.name" message="No module.name parameter given" />
        <fail unless="src" message="No src directory parameter given" />

        <property name="sources.jar" location="${result.dir}/lib/${module.name}-${vaadin.version}-sources.jar" />

        <jar file="${sources.jar}" compress="true">
            <fileset dir="${src}">
                <patternset>
                    <include name="**/*.java" />
                    <include name="**/*.properties" />
                </patternset>
            </fileset>
            <fileset dir="${common.jarfiles.dir}" />
            <restrict>
                <union refid="extra.jar.includes" />
                <name name="*.java" />
            </restrict>
        </jar>

    </target>

    <target name="javadoc.jar" depends="dependencies">
        <fail unless="result.dir" message="No result.dir parameter given" />
        <fail unless="module.name" message="No module.name parameter given" />
        <property name="src" location="{$result.dir}/../src" />
        <property name="javadoc.dir" value="${result.dir}/javadoc" />
        <property name="javadoc.jar" location="${result.dir}/lib/${module.name}-${vaadin.version}-javadoc.jar" />

        <antcontrib:if>
            <!--
              Most straight forward way to skip javadocs is to provide
              an empty javadoc.jar. Ivy publish won't allow leaving the file
              out without using conf attribute. Using conf would make internal
              dependency resolution unnecessary complicated.
             -->
            <isset property="nojavadoc" />
            <then>
                <jar file="${javadoc.jar}" compress="true">
                    <fileset dir="${common.jarfiles.dir}" />
                </jar>
            </then>
            <else>
                <javadoc destdir="${javadoc.dir}" author="true" version="true" use="true" windowtitle="${module.name}">
                    <packageset dir="${src}" excludes="${classes.exclude}" />

                    <doctitle>&lt;h1>${module.name}&lt;/h1></doctitle>
                    <!-- <header><![CDATA[<script type="text/javascript" src=".html-style/style.js"></script>]]></header> -->
                    <bottom>${javadoc.bottom}</bottom>
                    <link offline="true" href="http://docs.oracle.com/javase/6/docs/api/" packagelistLoc="build/javadoc/j2se-1.6.0" />
                    <link offline="true" href="http://java.sun.com/j2ee/1.4/docs/api/" packagelistLoc="build/javadoc/j2ee-1.4" />
                    <classpath refid="classpath.compile.dependencies" />
                </javadoc>

                <!-- Create a javadoc jar -->
                <jar file="${javadoc.jar}" compress="true">
                    <fileset dir="${javadoc.dir}" />
                    <fileset dir="${common.jarfiles.dir}" />
                </jar>
            </else>
        </antcontrib:if>
    </target>

    <target name="jar" depends="compile, pom.xml">
        <fail unless="result.dir" message="No result.dir parameter given" />
        <fail unless="module.name" message="No module.name parameter given" />

        <property name="result.jar" location="${result.dir}/lib/${module.name}-${vaadin.version}.jar" />
        <property name="classes" location="{$result.dir}/classes" />
        <property name="src" location="{$result.dir}/../src" />

        <union id="jar.files">
            <fileset dir="${classes}" excludes="${classes.exclude}" erroronmissingdir="false" />
            <fileset dir="${src}" excludes="${jar.exclude}" erroronmissingdir="false" />
            <fileset dir="${common.jarfiles.dir}" />
            <union refid="extra.jar.includes" />
        </union>

        <jar destfile="${result.jar}" duplicate="fail" index="true">
            <manifest>
                <attribute name="Implementation-Vendor" value="${vaadin.vendor}" />
                <attribute name="Implementation-URL" value="${vaadin.url}" />
                <attribute name="Implementation-Version" value="${vaadin.version}" />
            </manifest>
            <union refid="jar.files" />
        </jar>

        <antcall target="common.make-osgi-bundle">
            <param name="jar" value="${result.jar}" />
            <param name="bundle-version" value="${vaadin.version}" />
            <param name="bundle-name" value="${module.name}" />
            <param name="bundle-symbolic" value="${module.symbolic}" />
            <param name="bundle-vendor" value="${vaadin.vendor}" />
        </antcall>

    </target>

    <!-- Add OSGi attributes to the manifest of the given jar -->
    <target name="make-osgi-bundle">
        <fail unless="jar" message="No jar parameter given" />
        <fail unless="bundle-name" message="No bundle-name parameter given" />
        <fail unless="bundle-symbolic" message="No bundle-symbolic parameter given" />
        <fail unless="bundle-version" message="No bundle-version parameter given" />
        <fail unless="bundle-vendor" message="No bundle-vendor parameter given" />

        <property name="bundle-manifestversion" value="2" />

        <jar file="${jar}" update="true">
            <manifest>
                <attribute name="Bundle-Version" value="${bundle-version}" />
                <attribute name="Bundle-ManifestVersion" value="${bundle-manifestversion}" />
                <attribute name="Bundle-Name" value="${bundle-name}" />
                <attribute name="Bundle-SymbolicName" value="${bundle-symbolic}" />
                <attribute name="Bundle-Vendor" value="${bundle-vendor}" />
                <attribute name="Bundle-RequiredExecutionEnvironment" value="JavaSE-${vaadin.java.version}" />
            </manifest>
        </jar>

        <antcontrib:if>
            <isset property="import-package" />
            <then>
                <jar file="${result.jar}" update="true">
                    <manifest>
                        <attribute name="Import-Package" value="${import-package}" />
                    </manifest>
                </jar>
            </then>
        </antcontrib:if>
        <antcontrib:if>
            <isset property="require-bundle" />
            <then>
                <jar file="${result.jar}" update="true">
                    <manifest>
                        <attribute name="Require-Bundle" value="${require-bundle}" />
                    </manifest>
                </jar>
            </then>
        </antcontrib:if>
        <antcontrib:if>
            <isset property="export-package" />
            <then>
                <jar file="${result.jar}" update="true">
                    <manifest>
                        <attribute name="Export-Package" value="${export-package}" />
                    </manifest>
                </jar>
            </then>
        </antcontrib:if>

        <ivy:resolve inline="true" organisation="com.vaadin" module="vaadin-buildhelpers" revision="${vaadin.version}" keep="true" />
        <ivy:cachepath pathid="buildhelpers.classpath" />

        <!-- Generate the Export-Package attribute in the manifest -->
        <java classname="com.vaadin.buildhelpers.GeneratePackageExports" failonerror="true" fork="yes">
            <arg value="${jar}" />
            <arg line="com/vaadin com/google ${osgi.extra.package.prefixes}" />
            <classpath refid="buildhelpers.classpath" />
            <jvmarg value="-Dvaadin.version=${vaadin.version}" />
        </java>
    </target>

    <target name="compile" description="Compiles the module" depends="dependencies, directories" if="src-exists">
        <fail unless="module.name" message="No module name given" />

        <javac srcdir="${src}" destdir="${classes}" source="${vaadin.java.version}" target="${vaadin.java.version}" debug="true" encoding="UTF-8" includeantruntime="false">
            <classpath refid="classpath.compile.dependencies" />
            <classpath refid="classpath.compile.custom" />
        </javac>
        <copy todir="${classes}">
            <fileset dir="${src}" includes="${extra.classes}" />
        </copy>
    </target>

    <target name="directories">
        <property name="result.dir" location="result" />
        <property name="src" location="${result.dir}/../src" />
        <property name="classes" location="${result.dir}/classes" />
        <available file="${src}" type="dir" property="src-exists" />
        <mkdir dir="${classes}" />
    </target>

    <target name="test.run" depends="test.compile">
        <fail unless="module.name" message="No module name given" />

        <property name="result.dir" location="result" />
        <property name="classes" location="${result.dir}/classes" />
        <property name="test.src" location="${result.dir}/../tests/src" />
        <property name="test.classes" location="${result.dir}/tests/classes" />

        <!-- Ensure report dir is empty before running tests -->
        <property name="report.dir" location="${result.dir}/reports" />
        <delete dir="${report.dir}" />
        <mkdir dir="${report.dir}" />

        <junit showoutput="no" printsummary="no" fork="yes">
            <formatter type="xml" />
            <jvmarg value="-ea" />
            <classpath location="${test.classes}" />
            <classpath location="${classes}" />
            <classpath refid="classpath.compile.custom" />
            <classpath refid="classpath.test.dependencies" />

            <batchtest fork="yes" todir="${report.dir}">
                <fileset dir="${test.src}">
                    <include name="**/*Test.java" />
                    <include name="**/*Tests.java" />
                </fileset>
            </batchtest>
        </junit>
    </target>

    <target name="test.compile" description="Compiles tests" depends="compile, dependencies.test">
        <fail unless="module.name" message="No module name given" />
        <property name="result.dir" location="result" />
        <property name="base.dir" location="${result.dir}/.." />
        <property name="test.src" location="${base.dir}/tests/src" />
        <property name="test.resources" location="${base.dir}/tests/resources" />
        <property name="test.classes" location="${result.dir}/tests/classes" />
        <property name="classes" location="${result.dir}/classes" />

        <mkdir dir="${test.classes}" />

        <javac srcdir="${test.src}" destdir="${test.classes}" source="${vaadin.java.version}" target="${vaadin.java.version}" debug="true" encoding="UTF-8" includeantruntime="false">
            <classpath refid="classpath.test.dependencies" />
            <classpath location="${classes}" />
            <classpath refid="classpath.test.custom" />
        </javac>

        <!-- Copy resources -->
        <copy todir="${test.classes}" failonerror="false">
            <fileset dir="${test.resources}" />
            <!-- include html templates used in declarative tests -->
            <fileset dir="${test.src}">
                <include name="**/*.html" />
            </fileset>
        </copy>
    </target>

    <target name="dependencies" description="Resolves dependencies needed by this module">
        <property name='conf' value="build, build-provided" />
        <ivy:resolve log="download-only" resolveid="common" conf="${conf}" />
        <ivy:cachepath pathid="classpath.compile.dependencies" conf="${conf}" />
    </target>

    <target name="dependencies.test" description="Resolves dependencies needed by test">
        <ivy:resolve log="download-only" resolveid="common" conf="test" />
        <ivy:cachepath pathid="classpath.test.dependencies" conf="test" />
    </target>

    <target name="remove-test-reports">
        <fail unless="result.dir" message="No result.dir parameter given" />
        <delete dir="${result.dir}/reports" />
    </target>

    <target name="clean" depends="remove-test-reports">
        <fail unless="result.dir" message="No result.dir parameter given" />
        <delete dir="${result.dir}" />
    </target>

    <target name="publish-local" description="Publishes the given module to the local repository">
        <fail unless="result.dir" message="No result.dir parameter given" />
        <property name="conf" value="*(public)" />

        <ivy:resolve log="download-only" conf="${conf}" />
        <ivy:publish settingsref="ivysettings" conf="${conf}" resolver="build-temp" overwrite="true" forcedeliver="true">
            <!-- <artifacts pattern="${result.dir}/[artifact]-[revision].[ext]" 
                /> -->
            <artifacts pattern="${result.dir}/lib/[artifact]-[revision](-[classifier]).[ext]" />

        </ivy:publish>
    </target>

    <target name="publish.to.local.maven">
        <property name="conf" value="*(public)" />

        <ivy:resolve log="download-only" conf="${conf}" />
        <ivy:publish conf="${conf}" resolver="local-maven" overwrite="true">
        </ivy:publish>
    </target>

    <!-- Checkstyle conf -->
    <property name="cs.dir" location="${vaadin.basedir}/checkstyle" />
    <property name="cs.xml" location="${cs.dir}/vaadin-checkstyle.xml" />
    <property name="cs.header-file" location="${cs.dir}/header" />
    <property name="cs.import-control-file" location="${cs.dir}/import-control.xml" />
    <taskdef resource="checkstyletask.properties" uri="antlib:com.puppycrawl.tools.checkstyle" classpathref="taskdefs.classpath" />

    <target name="checkstyle">
        <fail unless="result.dir" message="No result.dir parameter given" />
        <fail unless="cs.src" message="No cs.src parameter given" />
        <property name="result.dir.full" location="${result.dir}" />
        <mkdir dir="${result.dir}" />
        <echo>##teamcity[importData type='checkstyle' path='${result.dir.full}/checkstyle-errors.xml']</echo>
        <cs:checkstyle config="${cs.xml}" failOnViolation="false">
            <fileset dir="${cs.src}" includes="**/*.java">
                <exclude name="com/vaadin/sass/internal/parser/Parser.java" />
                <exclude name="com/vaadin/sass/internal/parser/ParserConstants.java" />
                <exclude name="com/vaadin/sass/internal/parser/ParserTokenManager.java" />
            </fileset>
            <formatter type="xml" toFile="${result.dir}/checkstyle-errors.xml" />
            <property key="checkstyle.header.file" file="${cs.header-file}" />
            <property key="checkstyle.importControl.file" file="${cs.import-control-file}" />
        </cs:checkstyle>
    </target>
</project>