Project: Cyberduck
Code Location: http://svn.cyberduck.ch/trunk/trunk
Browse
/
Download File
build.xml
<?xml version="1.0" encoding="UTF-8"?>
<!--
 *	Simple Ant (http://jakarta.apache.org/ant) build script for Cyberduck
 *
 *	$Revision: 12997 $
 *	$Date: 2013-09-18 12:48:58 -0400 (Wed, 18 Sep 2013) $
 *
 *  Copyright (c) 2005-2012 David Kocher. All rights reserved.
 *  http://cyberduck.ch/
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License as published by
 *	the Free Software Foundation; either version 2 of the License, or
 *	(at your option) any later version.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	Bug fixes, suggestions and comments should be sent to:
 *	dkocher@cyberduck.ch
 -->
<project name="Cyberduck" default="build" basedir=".">

    <property file="build.properties"/>
    <property file="tools.properties"/>

    <property environment="env"/>

    <property name="app.name" value="${ant.project.name}"/>
    <property name="debug" value="on"/>
    <property name="home" value="."/>
    <property name="unittests" value="${home}/test"/>
    <property name="build" value="${home}/build"/>
    <property name="configuration" value="Release"/>
    <property name="build.classes" value="${build}/classes"/>
    <property name="build.unittests" value="${build}/test-classes"/>
    <property name="build.unittests.reports" value="${build}/report"/>
    <property name="config" value="${home}/config"/>
    <property name="img" value="${home}/img"/>
    <property name="lib" value="${home}/lib"/>
    <property name="lib.ext" value="${lib}/ext"/>
    <property name="source" value="${home}/source"/>
    <property name="resources" value="${home}/resources"/>
    <property name="doc" value="${home}/doc"/>
    <property name="www" value="${home}/www"/>
    <property name="www.update" value="${www}/update"/>
    <property name="www.help" value="${www}/help"/>

    <property name="sonar.host" value="sonar.cyberduck.ch"/>

    <condition property="platform" value="mac">
        <os family="mac"/>
    </condition>
    <condition property="platform" value="windows">
        <os family="windows"/>
    </condition>

    <import description="Platform specific targets" file="build-${platform}.xml"/>

    <path id="test.classpath">
        <path refid="build.classpath"/>
        <pathelement location="${build.unittests}"/>
        <pathelement location="${build}/${configuration}"/>
        <fileset dir="${build}">
            <include name="*.jar"/>
        </fileset>
        <fileset dir="${lib.ext}">
            <include name="*.jar"/>
        </fileset>
    </path>

    <path id="build.classpath">
        <fileset dir="${lib}">
            <include name="*.jar"/>
        </fileset>
    </path>

    <target name="init">
        <echo message="ant version:	  ${ant.version}"/>
        <echo message="java version:  ${ant.java.version}"/>
        <echo message=""/>
        <echo message="	  ---------------------------------------------------------------"/>
        <echo message="	  project home:		${home}"/>
        <echo message="	  project build:	${build}"/>
        <echo message="	  project source:	${source}"/>
        <echo message="	  ---------------------------------------------------------------"/>
        <echo message=""/>
        <echo message="Building ${app.name}..."/>
        <mkdir dir="${build}"/>
        <mkdir dir="${build.classes}"/>
        <mkdir dir="${build.unittests}"/>
        <mkdir dir="${build.unittests.reports}"/>
        <mkdir dir="${build.unittests.reports}/html"/>
    </target>

    <target name="timestamp">
        <tstamp>
            <format property="touch.time"
                    pattern="dd/MM/yyyy hh:mm aa"
                    timezone="GMT+1"
                    locale="en"/>
        </tstamp>
    </target>

    <target name="revision">
        <echo message="Calculating revision..."/>
        <exec dir="${home}" executable="svnversion" outputproperty="svn.revision" failonerror="true">
            <arg value="."/>
        </exec>
        <property name="svn.revision" value="${svn.revision}"/>
        <echo message="_REVISION_=${svn.revision}"/>
        <buildnumber file="build.number"/>
        <echo message="Build number ${build.number}"/>
    </target>

    <target name="compile" depends="init" description="Compile the source tree">
        <javac fork="true"
               includeantruntime="false"
               debug="${debug}"
               encoding="utf-8"
               srcdir="${source}"
               source="1.6"
               target="1.6"
               deprecation="on"
               listfiles="on"
               extdirs=""
               destdir="${build.classes}">
            <classpath refid="build.classpath"/>
        </javac>
    </target>

    <target name="archive" depends="compile, manifest" description="Create .jar files of the compiled classes">
        <jar jarfile="${build}/cocoa.jar"
             update="yes"
             manifest="${build}/MANIFEST.MF">
            <fileset dir="${build.classes}/">
                <include name="ch/cyberduck/ui/cocoa/**/*.class"/>
                <include name="org/rococoa/**/*.class"/>
                <include name="com/barbarysoftware/**/*.class"/>
                <include name="com/sun/jna/**/*.class"/>
            </fileset>
        </jar>
        <jar jarfile="${build}/ui.jar"
             update="yes"
             manifest="${build}/MANIFEST.MF">
            <fileset dir="${build.classes}/">
                <include name="ch/cyberduck/ui/**/*.class"/>
            </fileset>
        </jar>
        <jar jarfile="${build}/core.jar"
             update="yes"
             manifest="${build}/MANIFEST.MF">
            <fileset dir="${build.classes}">
                <include name="ch/cyberduck/core/**/*.class"/>
                <include name="org/w3c/**/*.class"/>
                <include name="org/kohsuke/putty/**/*.class"/>
                <include name="org/spearce/jgit/**/*.class"/>
            </fileset>
            <fileset dir="${lib}">
                <include name="mime.types"/>
                <include name="log4j-*.xml"/>
            </fileset>
        </jar>
    </target>

    <target name="doc" depends="init" description="Generate Javadoc">
        <mkdir dir="${doc}"/>
        <javadoc packagenames="ch.cyberduck.*,com.*,org.*"
                 sourcepath="${source}"
                 destdir="${doc}"
                 author="true"
                 version="true"
                 use="true"
                 windowtitle="${app.name} API"
                 doctitle="${app.name}"
                 bottom="Copyright (c) 2005-2012 David Kocher. Enjoy ${app.name}!">
            <classpath refid="build.classpath"/>
        </javadoc>
    </target>

    <target name="clean" description="Delete compiled classes, jar files, jni libraries and application bundle">
        <delete dir="${build}"/>
    </target>

    <target name="manifest" depends="revision" description="Create a manifest used in the jar files">
        <manifest file="${build}/MANIFEST.MF">
            <attribute name="Built-By" value="${user.name}"/>
            <attribute name="Specification-Title" value="${app.name}"/>
            <attribute name="Specification-Version" value="${svn.revision}"/>
            <attribute name="Specification-Vendor" value="David Kocher"/>
            <attribute name="Implementation-Version" value="${svn.revision}"/>
        </manifest>
    </target>

    <target name="test-compile" depends="build">
        <javac debug="${debug}"
               encoding="utf-8"
               source="1.6"
               target="1.6"
               deprecation="off"
               srcdir="${unittests}"
               destdir="${build.unittests}"
               includes="**/*.java">
            <classpath refid="test.classpath"/>
        </javac>
    </target>

    <target name="test" depends="test-compile" description="Runs all test cases and generate report">
        <taskdef name="junit" classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask">
            <classpath path="${lib.ext}/junit-4.11.jar"/>
            <classpath path="${lib.ext}/hamcrest-core-1.3.jar"/>
        </taskdef>
        <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
            <classpath path="${lib.ext}/jacocoant.jar"/>
        </taskdef>
        <echo message="${build}/${configuration}"/>
        <jacoco:coverage destfile="${build}/jacoco.exec" xmlns:jacoco="antlib:org.jacoco.ant">
            <junit jvm="${jvm.runtime.bundle.home}/bin/java" fork="yes" forkmode="once" printsummary="on" filtertrace="on" haltonfailure="no" showoutput="yes"
                   dir="${home}">
                <classpath refid="test.classpath"/>
                <formatter type="plain" usefile="false"/>
                <formatter type="xml" extension=".xml" usefile="true"/>
                <batchtest todir="${build.unittests.reports}">
                    <fileset dir="${build.unittests}">
                        <include name="**/*Test.class"/>
                    </fileset>
                </batchtest>
                <sysproperty key="java.library.path" value="${build}/${configuration}"/>
                <sysproperty key="jna.library.path" value="${build}/${configuration}"/>
                <sysproperty key="s3.key" value="${s3.key}"/>
                <sysproperty key="s3.secret" value="${s3.secret}"/>
                <sysproperty key="rackspace.key" value="${rackspace.key}"/>
                <sysproperty key="rackspace.secret" value="${rackspace.secret}"/>
                <sysproperty key="hpcloud.key" value="${hpcloud.key}"/>
                <sysproperty key="hpcloud.secret" value="${hpcloud.secret}"/>
                <sysproperty key="hpcloud.user" value="${hpcloud.user}"/>
                <sysproperty key="hpcloud.password" value="${hpcloud.password}"/>
                <sysproperty key="webdav.user" value="${webdav.user}"/>
                <sysproperty key="webdav.password" value="${webdav.password}"/>
                <sysproperty key="ftp.user" value="${ftp.user}"/>
                <sysproperty key="ftp.password" value="${ftp.password}"/>
                <sysproperty key="sftp.user" value="${sftp.user}"/>
                <sysproperty key="sftp.password" value="${sftp.password}"/>
                <sysproperty key="sftp.key" value="${sftp.key}"/>
                <sysproperty key="google.projectid" value="${google.projectid}"/>
                <sysproperty key="google.accesstoken" value="${google.accesstoken}"/>
                <sysproperty key="google.refreshtoken" value="${google.refreshtoken}"/>
            </junit>
        </jacoco:coverage>
        <junitreport todir="${build.unittests.reports}/html">
            <fileset dir="${build.unittests.reports}">
                <include name="TEST-*.xml"/>
            </fileset>
            <report format="frames" todir="${build.unittests.reports}/html"/>
        </junitreport>
    </target>

    <target name="sonar" depends="test">
        <taskdef uri="antlib:org.sonar.ant" resource="org/sonar/ant/antlib.xml">
            <classpath path="${lib.ext}/sonar-ant-task-2.1.jar"/>
        </taskdef>
        <property name="sonar.projectName" value="${app.name}"/>
        <property name="sonar.projectKey" value="ch.cyberduck:cyberduck"/>
        <property name="sonar.projectVersion" value="${svn.revision}"/>
        <property name="sonar.sources" value="${source}"/>
        <property name="sonar.tests" value="${unittests}"/>
        <property name="sonar.binaries" value="${build.classes}"/>
        <property name="sonar.surefire.reportsPath" value="${build.unittests.reports}"/>
        <pathconvert property="sonar.libraries" refid="build.classpath" pathsep=","/>
        <property name="sonar.host.url" value="https://${sonar.host}"/>
        <property name="sonar.jdbc.url"
                  value="jdbc:mysql://${sonar.host}:3306/sonar?useUnicode=true&amp;characterEncoding=utf8"/>
        <property name="sonar.jdbc.username" value="sonar"/>
        <property name="sonar.jdbc.password" value="sonar"/>
        <property name="sonar.jdbc.driverClassName" value="com.mysql.jdbc.Driver"/>
        <property name="sonar.dynamicAnalysis" value="reuseReports"/>
        <property name="sonar.core.codeCoveragePlugin" value="jacoco"/>
        <property name="sonar.jacoco.reportPath" value="${build}/jacoco.exec"/>
        <property name="sonar.jacoco.antTargets" value="test"/>
        <property name="sonar.links.homepage" value="http://cyberduck.ch"/>
        <property name="sonar.links.ci" value="https://ci.cyberduck.ch"/>
        <property name="sonar.links.issue" value="https://trac.cyberduck.ch"/>
        <property name="sonar.scm.url" value="scm:svn:http://svn.cyberduck.ch/trunk"/>
        <property name="sonar.links.scm" value="https://svn.cyberduck.ch"/>
        <property name="sonar.links.scm_dev" value="https://svn.cyberduck.ch"/>
        <sonar:sonar xmlns:sonar="antlib:org.sonar.ant"/>
    </target>
</project>