Hey Luke,

We're packaging up a utility app as a zip file including a lib directory with 
dependencies. The lib directory contains some of our core code, which needs to 
be obfuscated, but it's including the un-obfuscated classes. I'm assuming these 
are defined due to transitive dependencies. I still don't fully understand how 
it knows which jars it should include. Is it defined in a classpath variable in 
the zip task? If so, should I just modify the classpath somehow?

Thanks,

Jared

________________________________
From: Luke Daley [[email protected]]
Sent: Thursday, September 08, 2011 2:52 AM
To: [email protected]
Subject: Re: [gradle-user] Can't figure out the zip task exclusions and 
inclusions

Hi Jared,

On 07/09/2011, at 7:46 PM, Jared Scott wrote:

Hello Gradle Experts,

Our local Gradle guru is away on a much deserved vacation, leaving us less 
versed devs to do some Gradle build tasks. I'm struggling with excluding some 
jars from a zip task and including some different ones in place. We basically 
generate some obfuscated and un-obfuscated jars. The jars the zip task is 
including are the un-obfuscated jars. I'm wanting to exclude those and add the 
obfuscated ones in place. I've played around with this for a full day now and 
need some insight.

config = copySpec {
    from('assets/config') {
        exclude 'DevIDE.sh'
    }
    from('assets/config') {
        include 'DevIDE.sh'
        fileMode = 0755
    }
    //copying in expected empty directories and log4j config
    from('src/main/resources')
}

dependencies {
    compile project(':model')
    compile("org.apache.axis2:axis2:1.6.0")
    compile("org.apache.axis2:axis2-adb:1.6.0")
    compile("org.apache.axis2:axis2-transport-local:1.6.0")
    compile("org.apache.axis2:axis2-transport-http:1.6.0")
    compile "edu.stanford.ejalbert:browser-launcher:1.0-rc4"
    compile "javax.help:javahelp:2.0.02"
    compile 
files("lib/scriptide-lib/ap-dev-ide-help-1.0/ap-dev-ide-help-1.0.jar")
}

[obfuscate, obfuscateJar]*.enabled = false
distZip.dependsOn ':foundation:obfuscateJar', ':interpreter:obfuscateJar', 
':model:obfuscateJar'
distZip { Zip zip ->
    into(zip.archiveName - ".zip") {
        with config
    }
    ArrayList<String> projects = [':foundation', ':interpreter', ':model']
    List excludeFiles = projects.collect { String projectName ->
        "**/" + project(projectName).jar.archiveName
    }
    exclude(excludeFiles)
}

I have not added the include statement above because I can't even figure this 
out. I basically need to do the above to and then include the obfuscated files 
in place. I've read the docs and checked the gradle source for the zip task, 
but I am missing something. I've tried all kinds of variations: 
zip.exclude(...), putting the exclude into the 'into' closure, not using 
brackets around the excludeFiles, ....

Do you want to create another jar but with the obfuscated jars? I'm not quite 
clear on what you are trying to do.

--
Luke Daley
Principal Engineer, Gradleware
http://gradleware.com

Reply via email to