Hi again Szczepan,
I have had some success,
but it has brought me to another (related) point which I have no idea how to
get around..
or at least, I might be able to overcome it,
but I am hoping not to have to do it in such an ugly way;
That is, i've got my code obfuscating, and the jar ends up in the libs
directory,
however, this is a multi-project build i'm doing, and I build up a zip for
distribution,
made up of all the dependent libraries and .jar files from other projects in
the build which will
also be obfuscated,
How do I make gradle take the obfuscated versions rather than the vanilla
versions
(as the vanilla, unobfuscated .jar files are the files that the java plugin
build works with automatically).
I suspect it is because what i've got is a normal build, with an obfuscated
jar task slotted in there as a kind of a side-note.
Whereas, what I really need, is the default jar task (which currently
creates the vanilla jar) to be the one obfuscating,
and have the extra jar task doing a normal unobfuscated build.
In other words, my wished for end result is two files:
Application.jar <---- the obfuscated version, kept track of by the build
process, and included by jar.archivePath
ApplicationNotObfuscated.jar <----- the non-obfuscated version, done
extra by a little extra jar task, not tracked by the build process
Can I customize in this way the default jar task that comes automatically
with inclusion of the java plugin?
below is my current build file,
thanks again for any insight you might still and have provided!
sean
apply plugin: 'java'
sourceSets {
main {
java {
srcDir 'src'
}
resources {
srcDir 'src'
}
}
test {
java {
srcDir 'test'
}
resources {
srcDir 'test'
}
}
}
jar {
manifest {
from("src/META-INF/MANIFEST.MF") // I provide my own manifest, and don't
generate one
}
}
task obfuscate(dependsOn: classes) << {
//some interesting logic that puts obfuscated classes into
"$buildDir/obfuscated-classes"
javaexec {
main = 'ZKM'
classpath = sourceSets.main.runtimeClasspath
args "$projectDir/script.txt"
jvmArgs "-DSaveAllDir=$buildDir/obfuscated-classes"
}
}
task obfuscatedJar(dependsOn: obfuscate, type: Jar) {
baseName = 'obfuscated'
from "$buildDir/obfuscated-classes"
from project.sourceSets.main.resources
manifest.from("src/META-INF/MANIFEST.MF")
}
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')
}
task dist(type: Zip) {
// as per http://www.gradle.org/tutorial_java_projects.html
dependsOn jar
from 'src/dist'
into('libs') {
from jar.archivePath
from configurations.compile
}
}