Created
April 22, 2009 15:50
-
-
Save kaikousa/99869 to your computer and use it in GitHub Desktop.
General ant-build for packaging a project to a .jar-file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project name="" default="jar"> | |
<description> | |
A general Ant-build file so I don't have to write it again from memory. | |
Project-layout: | |
-project | |
-src | |
-tests | |
-lib | |
build.xml | |
</description> | |
<property name="build.dir" value="build" /> | |
<property name="classes.dir" value="${build.dir}/classes" /> | |
<property name="dist.dir" value="${build.dir}/dist" /> | |
<property name="src.dir" value="src" /> | |
<property name="lib.repo" value="lib" /> | |
<pathconvert property="class.path"> | |
<path> | |
<fileset dir="${lib.repo}"> | |
<include name="**/*.jar"/> | |
</fileset> | |
</path> | |
</pathconvert> | |
<target name="createDirs"> | |
<mkdir dir="${build.dir}"/> | |
<mkdir dir="${classes.dir}"/> | |
<mkdir dir="${dist.dir}"/> | |
</target> | |
<target name="compile" depends="createDirs"> | |
<javac srcdir="${src.dir}" | |
destdir="${classes.dir}" | |
classpath="${class.path}" | |
/> | |
</target> | |
<pathconvert property="libs.project" pathsep=" "> | |
<mapper> | |
<chainedmapper> | |
<flattenmapper /> | |
<globmapper from="*" to="lib/*" /> | |
</chainedmapper> | |
</mapper> | |
<path> | |
<fileset dir="${lib.repo}"> | |
<include name="**/*.jar" /> | |
</fileset> | |
</path> | |
</pathconvert> | |
<target name="jar" depends="compile" description="description"> | |
<jar destfile="${dist.dir}/${ant.project.name}.jar" basedir="${classes.dir}"> | |
<manifest> | |
<attribute name="Main-Class" value=""/> | |
<attribute name="Class-Path" value="${libs.project}" /> | |
</manifest> | |
</jar> | |
</target> | |
</project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment