Gradle Task for Proguard

Posted: September 3, 2009 in AndCooper, Android, Java, Mobile
Tags: , ,

I use proguard settings specific to Android Java applications so change to fit your needs before using:

task generateProguardConfigFile << { logger.info('Creating andcooper.pro file for obfsucate task') /** * andcooper.pro must have the following text * (the variables are replaced as the fiel is created): * -libraryjars androidJar: externalLibsFolder * -injars outClassesLocation * -outjars obfuscateLocation/classes.min.jar * -keep public class * extends android.app.Activity * -optimizations !code/simplification/cast * -allowaccessmodification * * '\n' goes at end of each line */ andcooperProguardConfig = new file('andcooper.pro') andcooperProguardConfig.withWriter{ writer ->
writer << ‘-libraryjars ’ + androidJar + '; ' + externalLibsFolder + '\n' writer << ‘-injars ' + outClassesLocation + '\n' writer << '-outjars ' + obfuscateLocation + '/classes.min.jar' + '\n' writer << '-keep public class * extends android.app.Activity' + '\n' writer << '-optimizations !code/simplification/cast' + '\n' writer << '-allowaccessmodification' + '\n' } } task obfuscate << { ant.taskdef(resource: 'proguard/ant/task.properties', classpath: configurations.runtime.asPath ) ant.proguard(configuration: 'andcooper.pro') } [/sourcecode] Notice all I am doing is creating the proguard.pro file on-the-fly and than using that in my taskdef via the ANTBuilder.

Reblog this post [with Zemanta]
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s