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?
The build. xml file contains information that the wsgen Java Ant task uses to assemble Web services into Enterprise Application archive (*. ear) files. The following sections provide an example build.
Create Ant build fileIn the Project tool window, select the directory, where the build file should be created. Right-click the directory and from the context menu, select New | File ( Alt+Insert ). In the New File dialog, specify the name of the new file with the xml extension, for example, build. xml.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With