I have created a J2ME project after referring to this article J2MEUsingAntwithJ2ME. Now I am having problems in adding resources (such as images) and libraries (such as jar and zip files).
I have copied the resources in the res
folder as shown in this article but when I extract the .jar
file, it does not have any resources.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
From the sample:
<jar basedir="${build}/preverifiedobf"
jarfile="${build}/bin/${program_name}.jar"
manifest="bin/MANIFEST.MF">
<fileset dir="${top}/${res}">
<include name="${package_name}/*.png"/>
</fileset>
</jar>
This will only include *.png
files which are in /res
folder. If you want to include more types, add more <include>
lines or include "${package_name}/**"
.
If you want to include the content of existing .jar files, you can unjar them like this:
<mkdir dir="${build}/libs"/>
<unjar src="yourlibrary.jar" dest="${build}/libs" />
Then you can jar them up again:
<jar basedir="${build}/preverifiedobf"
jarfile="${build}/bin/${program_name}.jar"
manifest="bin/MANIFEST.MF">
<fileset dir="${top}/${res}">
<include name="${package_name}/*.png"/>
</fileset>
<fileset dir="${build}/libs">
<include name="**/*"/>
</fileset>
</jar>
The Apache Ant manual contains a lot of examples for all the supported tags.