java/build.common.xml
author Jan Vrany <jan.vrany@fit.cvut.cz>
Wed, 14 Jan 2015 11:19:03 +0000
changeset 3327 3f9968ddacf8
child 3356 a3ad7164f528
permissions -rw-r--r--
Ant build files refactoring (part 1) Ant build files has been rewritten by hand (as opposed to rely on those generated by Eclipse). This would give us a better control over the Java build process and allow later for integrating build.xml generation to ProjectDefinition to make working with polyglot packages easier.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project xmlns:ivy="antlib:org.apache.ivy.ant">
    <property name="ivy.jar" value="${TOP}/libjava/java/ivy-2.3.0.jar"/>

    <property name="build.src.dir" value="src"/>
    <property name="build.bin.dir" value="bin"/>
    <property name="build.libs.dir" value="libs"/>
    <property name="build.libs-src.dir" value="libs-src"/>
    <property name="ivy.dep.file" value="ivy.xml"/>

    <available file="${ivy.dep.file}" property="ivy.dep.file.present"/>
    <available file="${build.src.dir}" property="build.src.dir.present"/>

    <path id="build.classpath.prereqs">
    </path>

    <path id="build.classpath">
        <path refid="build.classpath.prereqs"/>
        <pathelement path="${build.libs.dir}"/>
        <fileset dir="${build.libs.dir}">            
      	    <include name="*.jar"/>
        </fileset>
    </path>


    <target name="build" depends="compile"/>

    <extension-point name="compile.pre"/>
    <extension-point name="compile.post"/>
    <target name="compile.main" if="${build.src.dir.present}">
        <mkdir dir="${build.bin.dir}"/>
        <javac srcdir="${build.src.dir}"
               destdir="${build.bin.dir}"
               classpathref="build.classpath"/>
    </target>
    <target name="compile" depends="prereqs, compile.pre, compile.main, compile.post"/>

    <target name="dependencies" depends="prereqs"/>

    <extension-point name="prereqs.pre"/>
    <extension-point name="prereqs.post"/>
    <extension-point  name="prereqs.main"/>

    <target name="prereqs" depends="libs, prereqs.pre, prereqs.main, prereqs.post"/>


    <extension-point name="libs.pre"/>
    <extension-point name="libs.post"/>
    <target name="libs.main">
    	<mkdir dir="${build.libs.dir}"/>
    </target>
    <target name="libs.fetch" if="ivy.dep.file.present">
        <taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant" classpath="${ivy.jar}" />
        <ivy:retrieve conf="binaries" pattern="${build.libs.dir}/[artifact]-[revision].[ext]" />
        <ivy:retrieve conf="sources"  pattern="${build.libs-src.dir}/[artifact]-[revision].[ext]" />

    </target>
    <target name="libs" depends="libs.pre, libs.main, libs.fetch, libs.post"/>

    <extension-point name="clean.pre"/>
    <extension-point name="clean.post"/>
    <target name="clean.main">
    <delete dir="${build.bin.dir}" />
    </target>
	<target name="clean" depends="clean.pre, clean.main, clean.post"/>

    <target name="clobber" depends="clean"/>

	<target name="echo.properties">
		<echoproperties/>
	</target>
	<target name="echo.classpath">
		<pathconvert property="build.classpath" refid="build.classpath"/>
		<echo>build.classpath: ${build.classpath}</echo>
	</target>
</project>