Skip to content

Instantly share code, notes, and snippets.

@crussell52
Created June 18, 2011 02:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save crussell52/1032740 to your computer and use it in GitHub Desktop.
Save crussell52/1032740 to your computer and use it in GitHub Desktop.
Ant file described.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project default="export" name="Create Jar for Project PointsOfInterest">
<property name="jar.name" value="PointsOfInterest.jar"/>
<property name="proj.dir" value="D:/Development/bukkit/BukkitPlugins/PointsOfInterest/"/>
<property name="jar.dest" value="${proj.dir}build/${jar.name}"/>
<property name="classes.dir" value="${proj.dir}target/classes/" />
<property name="api.jar" value="D:/Development/bukkit/PointsOfInterestAPI.jar"/>
<property name="export.dir" value="D:/minecraft/bukkit/plugins/"/>
<target name="jar">
<delete file="${jar.dest}"/>
<jar destfile="${jar.dest}" filesetmanifest="mergewithoutmain">
<manifest>
<attribute name="Class-Path" value="."/>
</manifest>
<fileset dir="${classes.dir}"/>
<file file="${proj.dir}plugin.yml"/>
<zipfileset excludes="META-INF/*.SF" src="${api.jar}"/>
</jar>
</target>
<target name="export" depends="jar">
<copy file="${jar.dest}" todir="${export.dir}" />
</target>
</project>
@crussell52
Copy link
Author

Line 1:

name is arbitrary... use whatever you want.
default specifies which target to execute if none is specified during execution.

Line 4-9: Creates ${var.name} for use elsewhere.

line 11: This target is all about creating the jar file.

Line 12: delete the last export -- the jar command doesn't seem to overwrite existing jars automatically.

line 13: create the jar file -- I got this from somehwere else, I don't full understand it yet.

line 14-16: this has something to do with creating the manifest for the jar file. (again, from somewhere else)

line 17: includes the projects classes -- this should point to your projects output folder.

line 18: this rolls the contents of PointsOfInterestAPI.jar into PointsOfInterest.jar. This is the magic which makes sure that any server running my plugin also has the API classes available.

Line 23: this is the target to execute if you want to copy the jar somewhere else too. (which is why it is my default target). the depends attribute makes sure the jar action runs first.

line 24: does just what it looks like it does... copies the jar to another folder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment