Hi Sean,
Some additional notes on your dependency / configuration setup:
The obfuscator jar (ZKM5.2.4e.jar) is needed during build time only and
should not be shipped right? You should remove it from your runtime
configuration. The runtime configuration is meant to contain only the
classes(, jars) your application needs to be executed. Furthermore you
should move your junit dependency to "testCompile" since you don't want
junit in your runtime classpath. This is easy to fix:
dependencies{
...
testCompile files('../depends/junit.jar')
...
}
To seperate the ZKM from the runtime configuration you can introduce a
specific configuration:
------------------
configurations{
zkm
}
dependencies{
zkm files('/mnt/data/dev/zelix/ZKM5.2.4e.jar')
}
task obfuscate(dependsOn: classes) << {
javaexec { // as per
http://mrhaki.blogspot.com/2010/09/gradle-goodness-run-java-application.html
main = 'ZKM'
classpath = configurations.zkm.asPath
args "$projectDir/script.txt"
jvmArgs "-DSaveAllDir=$buildDir/obfuscated-classes-extra"
}
}
------------------
Now you should be able to remove the nasty exclude statements in your
dist task.
regards,
René
Am 06.05.11 12:30, schrieb Sean Van Buggenum:
Hi Rene,
thanks again. That 'overwrite' flag did the trick..
So I went with option 1. I had already kind'a done it... albeit in a
very ugly way (a doFirst task component copying and deleting class files).
By being able to overwrite the main jar task, I avoid all that nasty
stuff. Thanks. I didn't know about it.
And to be honest, I still struggle navigating the documentation.
So now my build file looks like this (see below):
Though, I wonder now if strictly mu from clause in the dist task is
wrong, where I write:
from configurations.compile
it was originally : from configurations.runtime
but I wanted to avoid including the zelix library in the distribution
(in the most easy way). While that worked for the single project, as
soon as I turned this into a multi-project build,
it seemed to be included once more, making it necessary for me to
explicitly exclude it.
Additionally, in order for the Zelix obfuscator to work, I include the
library in the dependencies, as a runtime dependency..
runtime files('/mnt/data/dev/zelix/ZKM5.2.4e.jar')
Again, it works, but, as I am kind of guessing my way through this, I
wonder if strictly it is correct, or best.
Anyway, thanks again very much for your help.
-------------
apply plugin: 'java'
// http://www.gradle.org/java_plugin.html
// http://www.gradle.org/multi_project_builds.html
sourceSets { // http://www.gradle.org/java_plugin.html (changing the
project layout)
main {
java {
srcDir 'src'
}
resources {
srcDir 'src'
}
}
test {
java {
srcDir 'test'
}
resources {
srcDir 'test'
}
}
}
task obfuscate(dependsOn: classes) << {
javaexec { // as per
http://mrhaki.blogspot.com/2010/09/gradle-goodness-run-java-application.html
main = 'ZKM'
classpath = sourceSets.main.runtimeClasspath
args "$projectDir/script.txt"
jvmArgs "-DSaveAllDir=$buildDir/obfuscated-classes-extra"
}
}
task jar(dependsOn: obfuscate, type: Jar, overwrite: true){// we
provide our own main jar task
manifest.from("src/META-INF/MANIFEST.MF")// because our main jar
should be obfuscated
from project.sourceSets.main.resources
from "$buildDir/obfuscated-classes-extra"
}
task unobfuscatedJar(dependsOn: classes, type: Jar) {// we also
provide an extra jar task, to provide our unobfuscated jar
baseName = "${project.name <http://project.name>}-unobfuscated"
manifest.from("src/META-INF/MANIFEST.MF")
from "$buildDir/classes/main"
}
task dist(type: Zip) {// as per
http://www.gradle.org/tutorial_java_projects.html
dependsOn jar
into('libs') {
from jar.archivePath
from configurations.compile
exclude '*ZKM*.jar', '*junit*.jar'
}
}
dependencies {
compile project(':path/SimpleSharedProject')
compile files('../depends/junit.jar')
compile files('../depends/shared.jar')
runtime files('/mnt/data/dev/zelix/ZKM5.2.4e.jar')
}
--
-----------------------
regards René
rene groeschke
http://www.breskeby.com
@breskeby