Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

proguard as ant task

Tags:

java

proguard

ant

I actually have two related questions:

  1. Can predefined constants be expanded in the task declarations as <injar file="${build}/myjar.jar" />?
  2. How can I reuse the classpath definition in proguard? What I am trying to achieve is not to specify the whole set of required libraries. They are quite a lot and they are already included in ant's classpath with specific id.

Thanks a lot.

Martin

like image 701
Martin Dimitrov Avatar asked Feb 06 '26 07:02

Martin Dimitrov


1 Answers

Of course you can use Ant variables. However from my point of view it is easier to write all command-line options into the body of the proguard task:

<taskdef resource="proguard/ant/task.properties" classpath="lib/proguard.jar" />
<proguard>
    -libraryjars "${java.home}/lib/rt.jar"
    -injars     "${jar.name}"
    -outjars    build/temp.jar
    -keep class test.Main { public static void main(java.lang.String[]); }
    -dontwarn
    -dontoptimize 
    -dontobfuscate
</proguard>

For converting a defined Class path to a string that can be included into the proguard definition you can use the Ant task PathConvert. The first example on the linked page should be what you need.

Update: How to get the quotes around the path entries has been answered here: How to properly quote a path in an ant task?

like image 129
Robert Avatar answered Feb 07 '26 20:02

Robert