Source

vimclojure / build.xml

Full commit
<project name="vimclojure" default="all"
    xmlns:ivy="antlib:org.apache.ivy.ant">

    <property name="src.dir" location="src"/>
    <property name="classes.dir" location="classes"/>
    <property name="build.dir" location="build"/>
    <property name="lib.dir" location="lib"/>

    <property name="jar.file" location="${build.dir}/vimclojure.jar"/>
    <property name="srcjar.file" location="${build.dir}/vimclojure-source.jar"/>

    <property name="current.version" value="2.1"/>

    <property name="ivy.install.version" value="2.1.0-rc1"/>
    <property name="ivy.jar.file" value="${lib.dir}/ivy.jar"/>

    <property file="local.properties"/>

    <target name="init" description="--> create build directories">
        <tstamp/>
        <mkdir dir="${classes.dir}"/>
        <mkdir dir="${build.dir}"/>
        <mkdir dir="${lib.dir}"/>
    </target>

    <condition property="ivy.available">
        <available resource="org/apache/ivy/ant/antlib.xml"/>
    </condition>

    <condition property="ivy.disabled">
        <isset property="clojure.jar"/>
    </condition>

    <condition property="ivy.needed">
        <and>
            <not><istrue value="${ivy.available}"/></not>
            <not><istrue value="${ivy.disabled}"/></not>
        </and>
    </condition>

    <target name="download-ivy" depends="init" if="ivy.needed"
        description="--> download Ivy if necessary">
        <get src="http://repo1.maven.org/maven2/org/apache/ivy/ivy/${ivy.install.version}/ivy-${ivy.install.version}.jar"
            dest="${ivy.jar.file}"
            usetimestamp="true"/>
    </target>

    <target name="install-ivy" depends="download-ivy" if="ivy.needed"
        description="--> install Ivy if necessary">
        <path id="ivy.lib.path">
            <fileset dir="${lib.dir}" includes="*.jar"/>
        </path>
        <taskdef resource="org/apache/ivy/ant/antlib.xml"
            uri="antlib:org.apache.ivy.ant"
            classpathref="ivy.lib.path"/>
    </target>

    <target name="resolve" depends="install-ivy,init" unless="ivy.disabled"
        description="--> resolve dependencies with Ivy">
        <ivy:resolve />
        <ivy:retrieve />
    </target>

    <target name="aot" depends="nailgun-server,resolve,init"
        description="--> AOT compile clojure sources">
        <java classname="clojure.lang.Compile" failonerror="true">
            <classpath>
                <path location="${classes.dir}"/>
                <path location="${src.dir}"/>
                <path location="${clojure.jar}"/>
                <path location="${clojure-contrib.jar}"/>
                <fileset dir="${lib.dir}" includes="**/*.jar"/>
            </classpath>
            <sysproperty key="clojure.compile.path" value="${classes.dir}"/>
            <arg value="de.kotka.vimclojure.gencompletions"/>
            <arg value="de.kotka.vimclojure.util"/>
            <arg value="de.kotka.vimclojure.repl"/>
            <arg value="de.kotka.vimclojure.backend"/>
            <arg value="de.kotka.vimclojure.nails"/>
        </java>
    </target>

    <target name="nailgun-server" depends="resolve,init"
        description="--> compile the nailgun server">
        <javac destdir="${classes.dir}" srcdir="${src.dir}"
            includes="org/apache/**/*.java"/>
        <javac destdir="${classes.dir}" srcdir="${src.dir}"
            includes="com/martiansoftware/**/*.java"/>
        <copy todir="${classes.dir}">
            <fileset dir="${src.dir}" includes="com/martiansoftware/**"
                excludes="com/martiansoftware/**/*.java"/>
        </copy>
    </target>

    <target name="nailgun-client" if="nailgun-client"
        description="--> compile the nailgun client using make">
        <exec executable="make">
            <arg value="${nailgun-client}"/>
        </exec>
    </target>

    <target name="artifacts" depends="aot,nailgun-server"
        description="--> create source and artifact jars">
        <jar jarfile="${jar.file}">
            <path location="README.txt"/>
            <path location="LICENSE.txt"/>
            <fileset dir="${classes.dir}" includes="de/kotka/**"/>
            <fileset dir="${classes.dir}" includes="org/apache/**"/>
            <fileset dir="${classes.dir}" includes="com/martiansoftware/**"/>
            <fileset dir="${classes.dir}" includes="clojure/proxy/**"/>
            <manifest>
                <attribute name="Class-Path" value="."/>
            </manifest>
        </jar>
        <jar jarfile="${srcjar.file}">
            <path location="README.txt"/>
            <path location="LICENSE.txt"/>
            <fileset dir="${src.dir}" includes="**/*"/>
        </jar>
    </target>

    <target name="all" depends="artifacts,nailgun-client"
        description="--> build the whole project"/>

    <target name="clean" description="--> clean generated files">
        <delete dir="${classes.dir}"/>
        <delete dir="${build.dir}"/>
        <delete file="${nailgun-client}"/>
    </target>

    <target name="clean-lib" description="--> clean library files">
        <delete dir="${lib.dir}"/>
    </target>

    <target name="clean-local" depends="install-ivy" unless="ivy.disabled"
        description="--> clean local repository files">
        <ivy:info />
        <delete dir="${ivy.local.default.root}/${ivy.organisation}/${ivy.module}"/>
    </target>

    <target name="clean-all" depends="clean-lib,clean"
        description="--> clean all project files"/>

    <target name="install" if="vimdir"
        description="--> install the vim plugin">
        <mkdir dir="${vimdir}/autoload"/>
        <mkdir dir="${vimdir}/doc"/>
        <mkdir dir="${vimdir}/indent"/>
        <mkdir dir="${vimdir}/syntax"/>
        <mkdir dir="${vimdir}/ftdetect"/>
        <mkdir dir="${vimdir}/ftplugin"/>
        <mkdir dir="${vimdir}/ftplugin/clojure"/>

        <copy todir="${vimdir}/autoload">
            <fileset dir="autoload" includes="vimclojure.vim"/>
        </copy>
        <copy todir="${vimdir}/doc">
            <fileset dir="doc" includes="clojure.txt"/>
        </copy>
        <copy todir="${vimdir}/indent">
            <fileset dir="indent" includes="clojure.vim"/>
        </copy>
        <copy todir="${vimdir}/syntax">
            <fileset dir="syntax" includes="clojure.vim"/>
        </copy>
        <copy todir="${vimdir}/ftdetect">
            <fileset dir="ftdetect" includes="clojure.vim"/>
        </copy>
        <copy todir="${vimdir}/ftplugin">
            <fileset dir="ftplugin" includes="clojure.vim"/>
        </copy>
        <copy todir="${vimdir}/ftplugin/clojure">
            <fileset dir="ftplugin/clojure" includes="*.txt"/>
        </copy>
    </target>

    <target name="publish"
        description="--> publish artifacts in the shared repository">
        <ivy:info />
        <ivy:buildnumber
            organisation="${ivy.organisation}"
            module="${ivy.module}"
            revision="${current.version}"/>
        <ivy:publish
            resolver="shared"
            artifactspattern="${build.dir}/[artifact].[ext]"
            pubrevision="${ivy.new.revision}"
            update="true"
            status="release"/>
    </target>

    <target name="publish-local"
        description="--> publish artifacts in the local repository">
        <tstamp>
            <format property="now" pattern="yyyyMMddHHmmss"/>
        </tstamp>
        <ivy:info />
        <ivy:publish
            resolver="local"
            artifactspattern="${build.dir}/[artifact].[ext]"
            pubrevision="${now}"
            pubdate="${now}"
            status="integration"
            forcedeliver="true"/>
    </target>

</project>