tags:

views:

52

answers:

2

Hi

im pretty new at Ant and have been looking for alot of examples. I am pretty far now, and was successfull to get a build.xml going. Though i seem to have one thing missing. My application needs a custom Reference Library i am calling that is a jar file. But i dont know how to add it one. Any Tips, reference sites or examples you guys have, i would really appreciate it. Thank you

+1  A: 

To add the library you just need to make sure it is passed as an argument when invoking to the dx tool.

I use something very similar to the dex target in the template Ant build included with the SDK:

<!-- Convert this project's .class files into .dex files. -->
<target name="dex" depends="compile">
  <echo>Converting compiled files and external libraries into ${out-folder}/${dex-file}...</echo>
  <apply executable="${dx}" failonerror="true" parallel="true">
    <arg value="--dex" />
    <arg value="--output=${intermediate-dex-location}" />
    <arg path="${out-classes-location}" />
    <fileset dir="${external-libs-folder}" includes="*.jar"/>
  </apply>
</target>

The <fileset> element provides the library JARs to be included.

If you are using the standard Ant build, it should be sufficient to just put your JARs in the libs directory.

Dan Dyer
Thanx for the quick response, On the fileset tag for the dir, where do i set external-libs-folder to point to where i have my jar files. Also do i need to set out-classes-location or intermediate-dex-location?
robert.z
The code is from the default Ant script, so if you are using that you can just put your JARs in the libs directory and not worry about adding anything to your build.xml. Otherwise, external-libs-folder can be anywhere that you put your JAR files and out-classes-location is wherever the compiler outputs the .class files.
Dan Dyer
Awesome, thanx for you help appreciate it
robert.z
+1  A: 

Put the JAR file in the libs/ directory of your project. There is nothing else you need to do when building via Ant (Eclipse users also have to add the JAR to their build path). Here is a sample project showing the use of a BeanShell JAR.

CommonsWare