Using Ant, how can I set the jars directory?

I have a catalog full of cans (felix bundles). I want to iterate over all these banks and create dex'd versions. I intend to deploy each of these dex'd jars as a standalone apk, as they are links. Feel free to straighten me if I approach this from the wrong direction.

This first part is just trying to create the appropriate .dex file for each jar. However, when I run this, I get a "no resources" error coming from Ant.

Is this correct, or is there a simpler approach to simply enter the jar and display the dex'd version of this jar? $ {File} is valid because it splashes out the file name 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> 
+4
source share
2 answers

Give this move:

  <target name="dexBundles" description="Run dex on all the bundles"> <apply executable="${exec.dx}" dest="${post.dex.dir}/" parallel="false"> <arg value="--dex"/> <arg value="--output="/> <targetfile/> <srcfile/> <fileset dir="${pre.dex.dir}" includes="**/*.jar"/> <mapper type="glob" from="*.jar" to="*.dex"/> </apply> </target> 

It looks like ant to apply the task allows you to iterate over the file set without the need for ant -contrib (in particular, that the page has an example that looks for * .c in the directory, compiles them and renames * .o in the specified directory, which should be directly applicable). Unfortunately, it looks like you will lose the traceability provided by your echo messages.

For the record, I believe that the error message is actually generated directly by dx.bat not ant, but I'm not sure, and I don't know why.

Hope this helps.

+3
source

see the Ant document to apply the task , he said: “ At least one set of files or a list of files is required

therefore, this line "no resources defined" is printed to notify u that to write some set of files or a list of files .....

use "exec" instead.

0
source

Source: https://habr.com/ru/post/1443010/


All Articles