开发者

Java Ant - how to pass a ProGuard task arguments and use them inside a configuration file?

I have this in my build.xml:

<target depends="build-jar" name="proguard">
    <taskdef resource="proguard/ant/task.properties" classpath="tools/proguard4.6/lib/proguard.jar" />
    <proguard configuration="ant/proguard.conf" />
</target>

It works fine.

Inside the configuration file (i.e "ant/proguard.conf") I'm trying to access properties defined in this build.xml file but I'm always getting this kind of error:

Value of system property 'jar.final_name' is undefined in '<jar.final_name>' in line 1 of file '.......\ant\proguard.conf'

The error is clear. Question is how I do what I'm trying to?

If I'd do it the "Embedded ProGuard configuration options" way I could use these properties like any other开发者_StackOverflow中文版 property in build.xml, but I'm trying to keep the files separate.

How do I do that then?


By default, Ant doesn't provide a way to set java system properties for its tasks. You can only specify -D options in the ANT_OPTS system variable when starting Ant itself.

I'll consider supporting the use of Ant properties in referenced ProGuard configurations (being the developer of ProGuard).

For the time being, an acceptable solution might be to specify input and output jars in Ant's XML-style:

<proguard configuration="ant/proguard.conf">
  <injar      name="${injar}" />
  <outjar     name="${outjar}" />
  <libraryjar name="${java.home}/lib/rt.jar" />
</proguard>

This part of the configuration is more closely tied to the Ant script anyway.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜