Reputation: 1
I have a project that generates a client and a server jar file. The client uses an old version of WorldWind (1.5.1) in a set of "do not touch it code", meaning I can't upgrade to a newer WorldWind. This WorldWind, in turn, depends on old versions of jogl (1.1.1a), gluegen (1.0b06), etc... The client and server both use jackson (2.6.3 is latest we have in our Artifactory) to pass JSON messages to each other, with the server using some additional jackson libraries to support another 3rd party library it needs. There is some sort of conflict between the old jogl and the jackson that makes it so that if all these libraries are together in one classpath (lib folder) they stomp on each other and running the client at startup it claims it cannot find jogl.
I had solved this in the past by generating a lib_worldwind folder that would contain only the worldwind jar, a lib_jackson folder that would contain only the server-specific jackson jars, and a lib folder that would contain everything else. I did this via ant. Then I'd tell the client its classpath was lib and lib_worldwind, and I'd tell the server it is lib and lib_jackson.
We recently have converted everything to Gradle, which in the long run will let me actually try and update some of my dependencies to never versions easier and then see what breaks (and I can then fix piecemeal). Nonetheless, it seems Gradle puts everything into one lib folder.
So my question is, how do I replicate the old behavior where stuff ends up in 3 different folders (while makeing sure Gradle also tells Eclipse where it ended up putting the stuff correctly so it can build and run)? I've been trying for a week now (I thought maybe Configurations gets me there but it either does not or I'm not doing it right).
My Gradle scripts: root level build.gradle:
def standalone_distribution = new File(rootProject.projectDir, "standalone-distribution")
def jars_dir = new File(rootProject.projectDir, "jars")
def lib_dir = new File(rootProject.projectDir, "jars/lib")
def lib_client = new File(rootProject.projectDir, "jars/lib_worldwind")
def lib_server = new File(rootProject.projectDir, "jars/lib_jackson")
ant.importBuild 'build.xml'
buildscript {
repositories {
maven { url 'http://mylocalartifactory'}
}
dependencies {
classpath 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.6'
}
}
//irrelevant sonarqube settings
allprojects {
version = 'x'
}
subprojects {
repositories {
maven { url 'http://mylocalartifactory'}
flatDir { //I have to do this since I don't have some of these old libraries in my local artifactory but instead are sitting in a lib folder of specific sub projects
dirs "${projectDir}/lib"
}
}
apply plugin: 'maven'
apply plugin: 'java'
apply plugin: 'eclipse'
sourceSets {
main.java.srcDirs = ['src']
main.resources.srcDirs = ['conf']
test.java.srcDirs = ['test']
test.resources.srcDirs = ['testConf']
}
compileJava {
options.encoding = 'UTF-8'
options.compilerArgs << "-Xilint:all"
}
javadoc.options.encoding = 'UTF-8'
configurations.all {
exclude group: 'javax.media', module: 'jai-core'
exclude group: 'com.sun.media', module: 'jai_imageio'
exclude group: 'com.sun.jdmk', module: 'jmxtools'
exclude group: 'com.sun.jmx', module: 'jmxri'
exclude group: 'ch.qos.logback', module: 'logback-classic'
}
jar { archiveName = project.name + ".jar" }
group = 'client'
group = 'server'
sourceCompatibility = 1.8
targetCompatibility = 1.8
tasks.withType(JavaCompile) {
options.compilerArgs << '-Xlint:-deprecation'
options.compilerArgs << '-Xlint:-unchecked'
options.compilerArgs << '-Xlint:-rawtypes'
options.compilerArgs << '-Xlint:-varargs'
options.compilerArgs << '-Xling:-dep-ann'
}
//unit test stuff
task copyJar (type: Copy) {
from jar
into "$jars_dir"
}
task copyDeps (type: Copy) {
from configurations.runtime
into "$lib_dir"
}
task copyJarsandDeps (type: Copy, dependsOn: [copyJar, copyDeps])
}
The ant script build.xml sets up folder structure for deployment to a folder that would house this, in other words standalone-distribution - the primary project.name.jar jars that are my actual project + the scripts that start them - lib - lib_worldwind - lib_jackson - other folders like Resources, Docs, etc..
Then individual projects have gradle that looks like: client build.gradle:
jar {
from('src') {
include 'resourcefolder'
}
manifest {
attributes 'Implementation-Title': 'Client', 'Implementation-Version': version
}
}
dependencies {
compile project (':some-common-code-project')
compile name: 'jogl-1.1.1a'
compile name: 'worldwind-1.5.1'
//a handful more like this name: because they are old and I don't have them in localartifactory
compile 'org.apache.commons:commons-configurations:1.10'
//a handful more that I do have
}
Then, similarly in server build.gradle:
jar {
manifest {
attributes 'Implementation-Title': 'Server', 'Implementation-Version': version
}
}
dependencies {
compile project (':some-common-code-project')
compile 'thirdpartylibrary' //not used in client, thirdpartylibrary depends on jackson-core, jackson-annotations, and jackso-databind 2.8.7 which are not compatible with WorldWind so I want them in a different directory
//a handful more that I do have in local library
}
Any idea on how to do this "split"?
edit: just inspected that old worldwind-1.5.1.jar and it contains a set of jackson packages in there! So that's probably part of the problem.
edit2: got a (previously uninvolved) coworker to look at this and he suggested trying to exclude jackson from the client build.gradle and that solved it!
Upvotes: 0
Views: 178