build.xml 3.47 KB
<project name="mcmas" xmlns:ivy="antlib:org.apache.ivy.ant" default="build">

	<!-- SETTINGS -->
	
    <!-- Required jar location -->
	<property name="libs.dir" value="lib" />
	
	<!-- Source directory -->
	<property name="src.dir"     value="src" />
	
	<!-- Output directory -->
	<property name="build.dir"   value="build" />
	
	<!-- Classes directory -->
	<property name="classes.dir" value="${build.dir}/classes" />
	
	<!-- Output JAR directory -->
	<property name="jar.dir"     value="${build.dir}/jar" />
	
	<!-- Output JAR name -->
	<property name="jar.name"    value="${ant.project.name}.jar" />
	
	<!-- Output JAR fullpath -->
	<property name="jar.path"    value="${jar.dir}/${jar.name}" />
	
	<!-- Output JAR mainclass -->
	<property name="jar.main"    value="ocl.TestMain" />
	
	<!-- Deployement directory -->
	<property name="dest.dir"    value="/opt" />
	
	<!-- Documentation directory -->
	<property name="doc.dir"     value="doc/api" />
	
	<!-- Classpath -->
	<path id="classpath">
	    <fileset dir="${libs.dir}">
            <include name="*.jar"/>
        </fileset>
	</path>
	
	<!-- Ivy configuration -->
	
	<property name="ivy.install.version" value="2.3.0-rc1"/>
	<property name="ivy.jar.dir" value="${basedir}/ivy"/>
	<property name="ivy.jar.file" value="${ivy.jar.dir}/ivy.jar"/>
	
	<path id="ivy.lib.path">
		<fileset dir="${ivy.jar.dir}" includes="*.jar"/>
	</path>
		
	<taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path"/>
	
	<ivy:settings file="ivysettings.xml"/>
	
	<!-- Ivy integration -->
	
	<target name="download-ivy" unless="skip.download">
		<mkdir dir="${ivy.jar.dir}"/>
		<echo message="installing ivy..."/>
		<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" description="--> install ivy">
		<path id="ivy.lib.path">
			<fileset dir="${ivy.jar.dir}" includes="*.jar"/>
		</path>
	</target>
	
	<target name="resolve" description="--> retrieve dependencies with ivy">
        <ivy:retrieve />
    </target>
	
	<!-- TARGETS -->
	
	<target name="clean" description="Clean generated files">
		<delete dir="${build.dir}"/>
	</target>

	<target name="build" description="Build the library">
		<mkdir dir="${classes.dir}"/>
		<javac includeantruntime="false" debug="true" classpathref="classpath" srcdir="${src.dir}" destdir="${classes.dir}"/>
	</target>

	<target name="jar" depends="build" description="Generate a JAR">
		<mkdir dir="${jar.dir}"/>
		<jar destfile="${jar.path}" basedir="${classes.dir}">
			<!-- <manifest>
				<attribute name="Main-Class" value="${jar.main}"/>
			</manifest> -->
		</jar>
	</target>
	
	<target name="bundle" depends="build" description="Generate an all-in-one JAR including dependencies">
	    <mkdir dir="${jar.dir}"/>
	    <jar destfile="${jar.dir}/${ant.project.name}-all.jar" basedir="${classes.dir}">
	        <zipgroupfileset dir="${libs.dir}" includes="*.jar"/>
	    </jar>
	</target>
	
	<target name="run" description="Run JAR main class">
		<java classpathref="classpath" jar="${jar.path}" fork="true"/>
	</target>

	<target name="deploy" depends="jar" description="Copy JAR for deployement">
		<copy file="${jar.path}" todir="${dest.dir}"/>
	</target>
	
	<target name="doc" description="Generate javadoc">
		<javadoc
		  classpathref="classpath"
		  sourcepath="${src.dir}"
		  defaultexcludes="yes"
		  destdir="${doc.dir}"
		/>
	</target>
	
</project>