Reputation: 8965
I have download an API which has the following structure:
In the folder, there is a source folder and a build.xml file. How would I go about creating a jar out of this?
Upvotes: 11
Views: 42130
Reputation: 22692
If the build.xml file doesn't already have a target that creates a jar file, you can read about the ant jar command here:
However, there's probably a good chance that the build file already does this for you.
You can run the build script by typing ant when you're in the directory that contains the build.xml file (after unpacking the jar).
Just for fun, here is an example of a simple ant target that compiles some code and creates a jar.
This target will compile every .java file in any folder named reports.
As you can see, most of the values are using variables defined elsewhere in the script, but hopefully you get the idea...
<target name="create-funky-jar" depends="some-other-funky-targets">
<javac
srcdir="${src.dir}"
includes="**/reports/*.java"
destdir="${build.classes.dir}"
deprecation="${javac.deprecation}"
source="${javac.source}"
target="${javac.target}"
includeantruntime="false">
<classpath>
<path path="${javac.classpath}:${j2ee.platform.classpath}"/>
</classpath>
</javac>
<jar destfile="${dist.dir}/SomeFunkyJar.jar"
basedir="${build.classes.dir}"
includes="**/reports/*.class"/>
</target>
The above was just created by modifying a build script generated by NetBeans.
You can run the above target by adding it to a build.xml file and typing the following from the command line:
ant create-funky-jar
Note: You'll have to define all the variables for it to actually work.
Upvotes: 13
Reputation: 36229
In the directory where the build.xml-file is, type
ant -p
Maybe you need to install ant first.
If there is a target to create a jar, chose that one, for example
ant jar
Upvotes: 0
Reputation: 7344
build.xml
is a file used by ant and it could contain the procedure Ant should follow to build tha appropiate kind of file (like a jar
).
I'd recommend reading something like this guide (The chapters called Installing and Running). Another option could be use Netbeans since it already has Ant and it has options to create a project from an existing build.xml
.
Upvotes: 0