Using Ant how can I dex a directory of jars?

Posted by cbeaudin on Stack Overflow See other posts from Stack Overflow or by cbeaudin
Published on 2012-10-30T14:50:05Z Indexed on 2012/10/31 17:00 UTC
Read the original article Hit count: 271

Filed under:
|

I have a directory full of jars (felix bundles). I want to iterate through all of these jars and create dex'd versions. My intent is to deploy each of these dex'd jars as standalone apk's since they are bundles. Feel free to straighten me out if I am approaching this from the wrong direction.

This first part is just to try and create a corresponding .dex file for each jar. However when I run this I am getting a "no resources specified" error coming out of Ant.

Is this the right approach, or is there a simpler approach to just input a jar and output a dex'd version of that jar? The ${file} is valid as it is spitting out the name of the file in the echo command.

<target name="dexBundles" description="Run dex on all the bundles">
    <taskdef resource="net/sf/antcontrib/antlib.xml" classpath="${basedir}/libs/ant-contrib.jar" />
    <echo>Starting</echo>
    <for param="file">
        <path>
            <fileset dir="${pre.dex.dir}">
                <include name="**/*.jar" />
            </fileset>
        </path>
        <sequential>
            <echo message="@{file}" />
            <echo>Converting jar file @{file} into ${post.dex.dir}/@{file}.class...</echo>
              <apply executable="${dx}" failonerror="true" parallel="true" verbose="true">
                <arg value="--dex" />
                <arg value="--output=${post.dex.dir}/${file}.dex" />
                <arg path="@{file}" />
              </apply>
        </sequential>
    </for>
    <echo>Finished</echo>
</target>

© Stack Overflow or respective owner

Related posts about android

Related posts about ant