From users-return-3713-apmail-buildr-users-archive=buildr.apache.org@buildr.apache.org Thu Apr 25 12:02:33 2013 Return-Path: X-Original-To: apmail-buildr-users-archive@www.apache.org Delivered-To: apmail-buildr-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E2DCB10983 for ; Thu, 25 Apr 2013 12:02:33 +0000 (UTC) Received: (qmail 98397 invoked by uid 500); 25 Apr 2013 12:02:33 -0000 Delivered-To: apmail-buildr-users-archive@buildr.apache.org Received: (qmail 98100 invoked by uid 500); 25 Apr 2013 12:02:28 -0000 Mailing-List: contact users-help@buildr.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@buildr.apache.org Delivered-To: mailing list users@buildr.apache.org Received: (qmail 98067 invoked by uid 99); 25 Apr 2013 12:02:27 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 25 Apr 2013 12:02:27 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [79.170.90.124] (HELO server.vaneeckhoudt.net) (79.170.90.124) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 25 Apr 2013 12:02:21 +0000 Received: from [192.168.2.159] (loopback.fw1.luciad.com [91.216.20.1]) by server.vaneeckhoudt.net (Postfix) with ESMTPSA id 6704615110E for ; Thu, 25 Apr 2013 14:01:59 +0200 (CEST) Message-ID: <51791B37.9040005@vaneeckhoudt.net> Date: Thu, 25 Apr 2013 14:01:59 +0200 From: Pepijn Van Eeckhoudt User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130403 Thunderbird/17.0.5 MIME-Version: 1.0 To: users@buildr.apache.org Subject: Re: Proguard and Ant Task References: <516BB21F.1040506@vaneeckhoudt.net> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Checked: Checked by ClamAV on apache.org 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.