build.xml 5.85 KB
Newer Older
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
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project basedir="." default="build" name="TULIP">

    <property environment="env"/>
    <property name="ECLIPSE_HOME" value="../../../../../Eclipse x64 Luna/"/>
    <property name="Climate_Change.location" value="../Climate Change"/>
    <property name="junit.output.dir" value="junit"/>
    <property name="debuglevel" value="source,lines,vars"/>
    <property name="target" value="1.7"/>
    <property name="source" value="1.7"/>
	<property name='build' location='bin' />
	<property name='dist' location='dist' />
	<property name='application.version' value='1.0'/>
	<property name='application.name' value='TULIP'/>
	<property name='distribution' value='${application.name}-${application.version}'/>
	<tstamp><format property='build.time' pattern='yyyy-MM-dd HH:mm:ss'/></tstamp>
	
    <path id="JUnit 4.libraryclasspath">
        <pathelement location="${ECLIPSE_HOME}plugins/org.junit_4.11.0.v201303080030/junit.jar"/>
        <pathelement location="${ECLIPSE_HOME}plugins/org.hamcrest.core_1.3.0.v201303031735.jar"/>
    </path>
	
    <path id="TULIP.classpath">
        <pathelement location="${build}"/>
        <path refid="JUnit 4.libraryclasspath"/>
        <pathelement location="libs/jdom-2.0.5.jar"/>
        <pathelement location="libs/guava-15.0.jar"/>
        <pathelement location="libs/tuio-1.4.jar"/>
        <pathelement location="libs/dbc.annotation.jar"/>
    </path>
	
	<path id="jar.classpath">
        <pathelement location="jdom-2.0.5.jar"/>
        <pathelement location="guava-15.0.jar"/>
        <pathelement location="tuio-1.4.jar"/>
        <pathelement location="dbc.annotation.jar"/>
	</path>
	
	<condition property='jdk.javadoc.visible' value='true' else='false'> 
		<http url='http://java.sun.com/javase/8/docs/api/' />
	</condition>
	
    <target name="init" depends="clean">
    	<echo>
		    Application: ${application.name} ${application.version}
		    Build File : ${ant.file} 
		    Run Date   : ${build.time}
		    Run by     : ${user.name}
		    Build Dir  : ${dist}
		    Base Dir   : ${basedir}
		    Java Home  : ${java.home}
		    Connected to the web   : ${jdk.javadoc.visible}
		</echo>
		<mkdir dir="${dist}"/>
		<mkdir dir="${build}"/>
    </target>
	
	<target name='clean' description="Delete all build artifacts." >
		<delete includeEmptyDirs="true">
			<fileset dir='${dist}'/>
		</delete>
		<delete includeEmptyDirs="true">
			<fileset dir='bin'/>
		</delete>
		<mkdir dir="${build}"/>
		<mkdir dir="${dist}"/>
		<mkdir dir="${dist}/javadoc"/>
		<mkdir dir="${dist}/assets"/>
	</target>
    	
    <target name="build" depends="build-project,jar,source-and-doc,distribution,build-refprojects"/>
	<target name="build-no-ref" depends="build-project,jar,source-and-doc,distribution"/>	
	
    <target name="build-project" depends="init">
        <javac debug="true" debuglevel="${debuglevel}" destdir="bin" includeantruntime="false" source="${source}" target="${target}">
            <src path="src"/>
            <!--<src path="test"/>-->
            <classpath refid="TULIP.classpath"/>
        </javac>
    </target>
	
    <target name="build-refprojects" description="Build all projects which reference this project.">
        <ant antfile="build.xml" dir="${Climate_Change.location}" inheritAll="false" target="build-no-sub">
            <propertyset>
                <propertyref name="build.compiler"/>
            </propertyset>
        </ant>
    	<copy file="${dist}/${distribution}.jar" todir="${Climate_Change.location}/dist/"/>
    	<copy todir="${Climate_Change.location}/dist/">
    		<fileset dir="libs"/>
    	</copy>
    </target>

	<target name='jar' description='Create a jar file for distribution.'>
		<pathconvert property="manifest.classpath" pathsep=" ">
	         <path refid="jar.classpath" />
	         <flattenmapper />
	    </pathconvert>
		<echo>TULIP classpath: ${manifest.classpath}</echo>
	    <jar destfile='${dist}/${distribution}.jar'>
	    	<fileset dir="bin"/>
	    	<!--<zipgroupfileset dir="libs" includes="*.jar"/>-->
	    	<manifest>	    		
	    		<attribute name="Class-Path" value="${manifest.classpath}"/>
	    	</manifest>
	    </jar>
		<copy todir="${dist}/">
			<fileset dir="libs">
				<exclude name="sources.jar,javadoc.jar,test.jar"/>
			</fileset>
		</copy>
	</target>
	
	<target name="source-and-doc" description="Bundle sources and javadoc in a jar!" depends="javadoc">
		<jar compress="${jar.compress}" basedir="src" jarfile="${dist}/${distribution}-sources.jar" />
		<jar compress="${jar.compress}" basedir="${dist}/javadoc/" jarfile="${dist}/${distribution}-javadoc.jar" />
		<copy file="calibration.xml" todir="${dist}/"/>
		<copy file="properties.properties" todir="${dist}/"/>
		<copy todir="${dist}/assets">
		    <fileset dir="assets"/>
		</copy>
		<jar compress="${jar.compress}" basedir="test" jarfile="${dist}/${distribution}-test.jar" />	
	</target>
	
	<target name='javadoc' description='Generate javadoc.' >
	    <javadoc  
	      use='true' author='true'  version='true'
	      access='package' 
	      sourcepath='src'
	      packagenames='*.*' 
	      destdir='${dist}/javadoc'
	      windowtitle='${application.name} ${application.version}'
	      noqualifier='java.*:javax.*:com.sun.*'   
	      linksource='true' >
	    <tag name="invariant" scope="all" description="Invariant:"/>
	    <tag name="post" scope="all" description="Postcondition:"/>
	    <tag name="pre" scope="all" description="Precondition:"/>
	    <classpath refid='TULIP.classpath'/>
	    <link href='http://java.sun.com/javase/8/docs/api/'/>      
	    <header><![CDATA[<h1>${application.name} ${application.version}</h1>]]></header>
	    </javadoc>
	</target>
	  
	<target name='distribution' description='Create zip file with project code and resources.'>
	    <zip destfile='${dist}/${distribution}.zip'>
	    	<zipfileset dir='${dist}'>
	    		<exclude name="${dist}/${distribution}.zip"/>
	    	</zipfileset>
		</zip>
	</target>	
</project>