buildr-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pepijn Van Eeckhoudt <pep...@vaneeckhoudt.net>
Subject Re: Proguard and Ant Task
Date Thu, 25 Apr 2013 12:01:59 GMT
Hi Khristian,

Here's a snippet from our buildfile. The main reason I added 
configuration via Ruby objects is to allow configuration to be generated 
in the build script. In the example below this is used to generate 
'keep' directives for every file in a specific directory.

Pepijn

jar = package(:type => :obfuscatedjar).tap do |p|
   p.with :note => false,
          :warn => false,
          :renamesourcefileattribute => package_id,
          :keepparameternames => true,
          :configuration => _('baseconfig.pro'),
          :printmapping => _(:target, "mapping"),
          :printconfiguration => _(:target, package_id + "config")
   p.dependencies.clear
   p.use android.platform_jar

   p.keep :attributes
   p.keep :packagenames
   # Generate a keep entry for each class in the public API tree
   glob(src, "**/*.java").map { |f| f[0..-6].gsub('/', '.') }.each do 
|class_name|
     [class_name, class_name + '$*'].each do |class_pattern|
       p.keep({:access => 'public',
               :name => class_pattern,
               :field => {:access => 'public protected'},
               :method => {:access => 'public protected'},
               :constructor => {:access => 'public protected'}})
     end
   end

   # Keep all classes with native methods.
   p.keep(:classeswithmembers, {:type => 'class', :method => {:access => 
'native'}})

   p.keep(:classmembers, {:type => 'enum', :method => {:access => 
'public static', :name => 'values'}})
   p.keep(:classmembers, {:type => 'enum', :method => {:access => 
'public static', :name => 'valueOf'}})
   p.keep(:classmembernames, {:type => 'class', :method => {:name => 
'class$*'}})
end

On 25-04-13 11:16, Khristian Schönrock wrote:
> Thanks for the tips, Pepijn and Alex!
>
> I didn't manage to get your Proguard task working as it is, so I made a few
> modifications until it worked:
> - Proguard version: updated to 4.8 (internal requirement);
> - Proguard dependency: changed groupId to net.sf.proguard;
> - rt.jar inclusion: substituted it with the version from Alex's script;
> - obfuscate() method: since I keep my Proguard configurations in a separate
> file, I only provided the :configuration option. The " {'keep' => @keep,
> 'whyareyoukeeping' => @whykeeping}..." part of the function didn't seem to
> like it so much, so I removed it. Could you perhaps provide an example of
> how you use your task?
>
> Other than that, it now behaves as expected, and my build runs all the way
> to the end.


Mime
View raw message