Enable test. Add wait timeout.
[cyberduck.git] / build.xml
blob3fc3a08a396b6f5c6764158271b2a4ebade73a7f
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!--
3  *      Simple Ant (http://jakarta.apache.org/ant) build script for Cyberduck
4  *
5  *      $Revision$
6  *      $Date$
7  *
8  *  Copyright (c) 2005-2012 David Kocher. All rights reserved.
9  *  http://cyberduck.io/
10  *
11  *      This program is free software; you can redistribute it and/or modify
12  *      it under the terms of the GNU General Public License as published by
13  *      the Free Software Foundation; either version 2 of the License, or
14  *      (at your option) any later version.
15  *
16  *      This program is distributed in the hope that it will be useful,
17  *      but WITHOUT ANY WARRANTY; without even the implied warranty of
18  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  *      GNU General Public License for more details.F
20  *
21  *      Bug fixes, suggestions and comments should be sent to:
22  *      dkocher@cyberduck.io
23  -->
24 <project name="Cyberduck" default="build" basedir=".">
26     <property file="build.properties"/>
27     <property file="tools.properties"/>
29     <property environment="env"/>
31     <property name="app.name" value="${ant.project.name}"/>
32     <property name="app.update.feed" value=""/>
34     <property name="debug" value="on"/>
35     <property name="home" location="."/>
36     <property name="unittests" value="${home}/test"/>
37     <property name="build" value="${home}/build"/>
38     <property name="build.compile.target" value="${ant.java.version}"/>
39     <property name="configuration" value="release"/>
40     <property name="build.deploy" location="${build}/${configuration}"/>
41     <property name="build.bundles" value="${build.deploy}/bundles"/>
42     <property name="build.classes" value="${build}/classes"/>
43     <property name="build.unittests" value="${build}/test-classes"/>
44     <property name="build.unittests.include" value="**/*Test.class"/>
45     <property name="build.unittests.reports" value="${build}/report"/>
46     <property name="config" value="${home}/config"/>
47     <property name="img" value="${home}/img"/>
48     <property name="lib" value="${home}/lib"/>
49     <property name="lib.ext" value="${lib}/ext"/>
50     <property name="source" value="${home}/source"/>
51     <property name="resources" value="${home}/resources"/>
52     <property name="doc" value="${home}/doc"/>
53     <property name="www" value="${home}/www"/>
54     <property name="www.update" value="${www}/update"/>
55     <property name="www.help" value="${www}/help"/>
56     <property name="setup" value="${home}/setup"/>
57     <property name="copyright" value="Copyright (c) 2001-2015 David Kocher. Copyright (c) 2011–2015 Yves Langisch"/>
58     <property name="version" value="${cyberduck.version.major}.${cyberduck.version.minor}"/>
60     <property name="sonar.host" value="sonar.cyberduck.io"/>
62     <condition property="platform" value="mac">
63         <os family="mac"/>
64     </condition>
65     <condition property="platform" value="windows">
66         <os family="windows"/>
67     </condition>
68     <condition property="platform" value="linux">
69         <os family="unix"/>
70     </condition>
72     <import description="Platform specific targets" file="build-${platform}.xml"/>
74     <path id="test.classpath">
75         <path refid="build.classpath"/>
76         <pathelement location="${build.unittests}"/>
77         <pathelement location="${build}"/>
78         <fileset dir="${build}">
79             <include name="*.jar"/>
80         </fileset>
81         <fileset dir="${lib.ext}">
82             <include name="*.jar"/>
83         </fileset>
84     </path>
86     <path id="build.classpath">
87         <!-- Include all libraries -->
88         <fileset dir="${lib}">
89             <include name="*.jar"/>
90         </fileset>
91     </path>
93     <target name="init" depends="timestamp">
94         <echo message=""/>
95         <echo message="   ---------------------------------------------------------------"/>
96         <echo message="   Java Version: ${ant.java.version}"/>
97         <echo message="   Project Home:         ${home}"/>
98         <echo message="   Project Build:        ${build}"/>
99         <echo message="   Project Source:       ${source}"/>
100         <echo message="   ---------------------------------------------------------------"/>
101         <echo message=""/>
102         <echo message="Building ${app.name} on ${os.name}/${os.arch} at ${touch.time}..."/>
104         <mkdir dir="${build}"/>
105         <mkdir dir="${build.deploy}"/>
106         <mkdir dir="${build.classes}"/>
107         <mkdir dir="${build.unittests}"/>
108         <mkdir dir="${build.unittests.reports}"/>
109         <mkdir dir="${build.unittests.reports}/html"/>
110     </target>
112     <target name="build" description="Build GUI application"
113             depends="archive, _build"/>
115     <target name="cli" description="Build CLI application"
116             depends="archive, _cli"/>
118     <target name="timestamp">
119         <tstamp>
120             <format property="touch.time"
121                     pattern="dd/MM/yyyy hh:mm aa"
122                     timezone="GMT+1"
123                     locale="en"/>
124         </tstamp>
125     </target>
127     <target name="revision" depends="init">
128         <echo message="Calculating revision..."/>
130         <taskdef resource="net/sf/antcontrib/antcontrib.properties">
131             <classpath path="${lib.ext}/ant-contrib-1.0b3.jar"/>
132         </taskdef>
134         <property environment="env"/>
135         <echo message="env.SVN_REVISION=${env.SVN_REVISION}"/>
137         <!-- Remove any non-digits (e.g. a trailing M) from the current revision -->
138         <propertyregex property="revision"
139                        input="${env.SVN_REVISION}"
140                        regexp="([\d]+).*"
141                        select="\1"/>
142         <property name="revision" value="${revision}"/>
143         <echo message="revision=${revision}"/>
144         <buildnumber file="build.number"/>
145         <echo message="Build number ${build.number}"/>
146     </target>
148     <target name="compile" depends="init" description="Compile the source tree">
149         <javac fork="true"
150                includeantruntime="false"
151                debug="${debug}"
152                encoding="utf-8"
153                srcdir="${source}"
154                target="${build.compile.target}"
155                source="${build.compile.target}"
156                deprecation="on"
157                listfiles="on"
158                extdirs=""
159                destdir="${build.classes}">
160             <classpath refid="build.classpath"/>
161             <compilerarg line="-profile compact3"/>
162         </javac>
163     </target>
165     <target name="archive" depends="compile, manifest" description="Create archives">
166         <jar jarfile="${build}/config-${version}.jar"
167              update="yes"
168              manifest="${build}/MANIFEST.MF">
169             <fileset dir="${lib}">
170                 <include name="mime.types"/>
171                 <include name="log4j-*.xml"/>
172             </fileset>
173         </jar>
174         <jar jarfile="${build}/core-${version}.jar"
175              update="yes"
176              manifest="${build}/MANIFEST.MF">
177             <fileset dir="${build.classes}">
178                 <include name="ch/cyberduck/core/**/*.class"/>
179             </fileset>
180         </jar>
181         <jar jarfile="${build}/fs-${version}.jar"
182              update="yes"
183              manifest="${build}/MANIFEST.MF">
184             <fileset dir="${build.classes}">
185                 <include name="ch/cyberduck/fs/**/*.class"/>
186             </fileset>
187         </jar>
188         <jar jarfile="${build}/ui-${version}.jar"
189              update="yes"
190              manifest="${build}/MANIFEST.MF">
191             <fileset dir="${build.classes}/">
192                 <include name="ch/cyberduck/ui/**/*.class"/>
193                 <exclude name="ch/cyberduck/ui/cocoa/**/*.class"/>
194             </fileset>
195         </jar>
196         <jar jarfile="${build}/binding-${version}.jar"
197              update="yes"
198              manifest="${build}/MANIFEST.MF">
199             <fileset dir="${build.classes}/">
200                 <include name="ch/cyberduck/binding/**/*.class"/>
201             </fileset>
202         </jar>
203         <jar jarfile="${build}/cocoa-${version}.jar"
204              update="yes"
205              manifest="${build}/MANIFEST.MF">
206             <fileset dir="${build.classes}/">
207                 <include name="ch/cyberduck/ui/cocoa/**/*.class"/>
208             </fileset>
209         </jar>
211         <taskdef resource="net/sf/antcontrib/antcontrib.properties">
212             <classpath path="${lib.ext}/ant-contrib-1.0b3.jar"/>
213         </taskdef>
214         <var name="manifest.lib.classpath" unset="true"/>
215         <manifestclasspath property="manifest.lib.classpath"
216                            jarfile="${lib}/cli-${version}.jar">
217             <!-- Convert paths relative to target jarfile -->
218             <classpath refid="build.classpath"/>
219         </manifestclasspath>
220         <var name="manifest.build.classpath" unset="true"/>
221         <manifestclasspath property="manifest.build.classpath"
222                            jarfile="${build}/cli-${version}.jar">
223             <!-- Convert paths relative to target jarfile -->
224             <classpath>
225                 <fileset dir="${build}" includes="*.jar"/>
226             </classpath>
227         </manifestclasspath>
228         <jar jarfile="${build}/cli-${version}.jar"
229              update="yes">
230             <fileset dir="${build.classes}">
231                 <include name="ch/cyberduck/cli/*.class"/>
232             </fileset>
233             <manifest>
234                 <attribute name="Specification-Title" value="${app.name}"/>
235                 <attribute name="Specification-Version" value="${version}"/>
236                 <attribute name="Specification-Vendor" value="${copyright}"/>
237                 <attribute name="Implementation-Version" value="${revision}"/>
238                 <attribute name="Main-Class" value="ch.cyberduck.cli.Terminal"/>
239                 <attribute name="Class-Path" value="${manifest.lib.classpath} ${manifest.build.classpath}"/>
240             </manifest>
241         </jar>
242     </target>
244     <target name="doc" depends="init" description="Generate Javadoc">
245         <mkdir dir="${doc}"/>
246         <javadoc packagenames="ch.cyberduck.*,com.*,org.*"
247                  sourcepath="${source}"
248                  destdir="${doc}"
249                  author="true"
250                  version="true"
251                  use="true"
252                  windowtitle="${app.name} API"
253                  doctitle="${app.name}"
254                  bottom="${copyright}">
255             <classpath refid="build.classpath"/>
256         </javadoc>
257     </target>
259     <target name="clean" description="Delete compiled classes, jar files, jni libraries and application bundle">
260         <delete dir="${build}"/>
261     </target>
263     <target name="manifest" depends="revision" description="Create manifest file">
264         <manifest file="${build}/MANIFEST.MF">
265             <attribute name="Specification-Title" value="${app.name}"/>
266             <attribute name="Specification-Version" value="${version}"/>
267             <attribute name="Specification-Vendor" value="${copyright}"/>
268             <attribute name="Implementation-Version" value="${revision}"/>
269         </manifest>
270     </target>
272     <target name="test-compile" depends="build">
273         <javac fork="true"
274                debug="${debug}"
275                includeantruntime="false"
276                encoding="utf-8"
277                target="${build.compile.target}"
278                source="${build.compile.target}"
279                deprecation="off"
280                srcdir="${unittests}"
281                destdir="${build.unittests}"
282                includes="**/*.java">
283             <classpath refid="test.classpath"/>
284         </javac>
285     </target>
287     <target name="test" depends="test-compile" description="Runs all tests">
288         <taskdef name="junit" classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask">
289             <classpath path="${lib.ext}/junit-4.11.jar"/>
290             <classpath path="${lib.ext}/hamcrest-core-1.3.jar"/>
291         </taskdef>
292         <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
293             <classpath path="${lib.ext}/jacocoant.jar"/>
294         </taskdef>
295         <copy todir="${build}">
296             <fileset dir="${lib}">
297                 <!-- Include libjnidispatch.dylib -->
298                 <include name="*.dylib"/>
299             </fileset>
300         </copy>
301         <echo message="Running tests with ${jvm.runtime.bin}/java"/>
302         <!-- Get all properties available to pass them to test task -->
303         <propertyset id="test.systemproperties">
304             <propertyref builtin="commandline"/>
305         </propertyset>
306         <jacoco:coverage destfile="${build}/jacoco.exec" xmlns:jacoco="antlib:org.jacoco.ant">
307             <junit jvm="${jvm.runtime.bin}/java" fork="yes" forkmode="once"
308                    printsummary="on" filtertrace="on"
309                    haltonfailure="no" failureproperty="test.failed"
310                    showoutput="yes"
311                    dir="${home}">
312                 <classpath refid="test.classpath"/>
313                 <formatter type="plain" usefile="false"/>
314                 <formatter type="xml" extension=".xml" usefile="true"/>
315                 <batchtest todir="${build.unittests.reports}">
316                     <fileset dir="${build.unittests}">
317                         <include name="${build.unittests.include}"/>
318                     </fileset>
319                 </batchtest>
320                 <syspropertyset refid="test.systemproperties"/>
321                 <sysproperty key="java.library.path" value="${build}"/>
322                 <sysproperty key="jna.library.path" value="${build}"/>
323             </junit>
324         </jacoco:coverage>
325         <junitreport todir="${build.unittests.reports}/html">
326             <fileset dir="${build.unittests.reports}">
327                 <include name="TEST-*.xml"/>
328             </fileset>
329             <report format="frames" todir="${build.unittests.reports}/html"/>
330         </junitreport>
331         <!--<fail message="Test failure detected" if="test.failed"/>-->
332     </target>
334     <target name="sonar" depends="test" description="Run Sonar">
335         <taskdef uri="antlib:org.sonar.ant" resource="org/sonar/ant/antlib.xml">
336             <classpath path="${lib.ext}/sonar-ant-task-2.2.jar"/>
337         </taskdef>
338         <property name="sonar.projectName" value="${app.name}"/>
339         <property name="sonar.projectKey" value="ch.cyberduck:cyberduck-${platform}"/>
340         <property name="sonar.projectVersion" value="${revision}"/>
341         <property name="sonar.projectBaseDir" value="${home}"/>
342         <property name="sonar.sources" value="${source}"/>
343         <property name="sonar.exclusions" value="**/binding/**/*.java,**/cocoa/**/*.java"/>
344         <property name="sonar.coverage.exclusions" value="**/binding/**/*.java,**/cocoa/**/*.java"/>
345         <property name="sonar.tests" value="${unittests}"/>
346         <property name="sonar.binaries" value="${build.classes}"/>
347         <property name="sonar.junit.reportsPath" value="${build.unittests.reports}"/>
348         <pathconvert property="sonar.libraries" refid="build.classpath" pathsep=","/>
349         <property name="sonar.host.url" value="https://${sonar.host}"/>
350         <property name="sonar.jdbc.url"
351                   value="jdbc:mysql://${sonar.host}:3306/sonar?useUnicode=true&amp;characterEncoding=utf8"/>
352         <property name="sonar.jdbc.username" value="sonar"/>
353         <property name="sonar.jdbc.password" value="sonar"/>
354         <property name="sonar.jdbc.driverClassName" value="com.mysql.jdbc.Driver"/>
355         <property name="sonar.core.codeCoveragePlugin" value="jacoco"/>
356         <property name="sonar.jacoco.reportPath" value="${build}/jacoco.exec"/>
357         <property name="sonar.jacoco.antTargets" value="test"/>
358         <property name="sonar.links.homepage" value="http://cyberduck.io"/>
359         <property name="sonar.links.ci" value="https://ci.cyberduck.io"/>
360         <property name="sonar.links.issue" value="https://trac.cyberduck.io"/>
361         <property name="sonar.scm.url" value="scm:svn:http://svn.cyberduck.io/trunk"/>
362         <property name="sonar.links.scm" value="https://svn.cyberduck.io"/>
363         <property name="sonar.links.scm_dev" value="https://svn.cyberduck.io"/>
364         <sonar:sonar xmlns:sonar="antlib:org.sonar.ant"/>
365     </target>
366 </project>