Several configuration files for the ProGuard Ant task

I use the ProGuard ant task, and everything is fine, except that my ProGuard configuration file is huge. In addition, different tasks use different ProGuard configuration files, and there are many copies that I would like to reorganize into separate .pro files.

<taskdef resource="proguard/ant/task.properties" classpath="C:/Program Files/proguard4.7/lib/proguard.jar"/>
<target name="obfuscated_jar" depends="raw_jar">
    <proguard configuration="core.pro lib1.pro lib2.pro">
        <outjar path="prog_obfuscated.jar"/>
    </proguard>
</target>

The above does not work as it treats multiple .pro files as one big file name. I am a famous idiot wrt ant, will I miss something obvious? Thank!

+3
source share
3 answers

You can create one main .pro file containing parameters -includepointing to your actual .pro files.

+5
source

This answer is small, but it works ...

<taskdef resource="proguard/ant/task.properties" classpath="C:/Program Files/proguard4.7/lib/proguard.jar"/>
<target name="obfuscated_jar" depends="raw_jar">
    <concat destfile="proguard_temp.pro">
        <filelist dir="." files="core.pro,lib1.pro,lib2.pro"/>
    </concat>
    <proguard configuration="proguard_temp.pro">
        <outjar path="prog_obfuscated.jar"/>
    </proguard>
    <delete file="proguard_temp.pro"/>
</target>
+1

It appears that only one file is allowed per attribute configuration.
Edited
And attributes are allowed only on the element <proguard>. I have another possible solution. Try merging your configuration files into one with Ant concat-task and passing this temporary file to the <proguard configuration=""> attribute .


It is also possible to modify ProGuardTask-class to accept multiple files as arguments and link them later. And the same result can be achieved with Ant macrodef.

0
source

All Articles