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}-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')
}