distTar copies my class folder to a wrong place


(Joey Liu) #1

In my project I have a data file folder, which can NOT be put into a JAR file. (Because the way how a library use this folder is not in stream). Here is the layout of my project:

/ROOT

|–src/main/java/

|–src/main/resources/

|–dict/spellChecker/index/*

|–dict/spellChecker/spellIndex/*

As you can see the dict folder is the data folder my just mentioned. My build.gradle has this:

dependencies {

runtime files(“dict”)

}

As now if I run ‘gradle eclipse’ the ‘dict’ folder is in my ‘.classpath’ file as a ‘lib’, I can have my java class read these folders like this:

folder = new FSDirectory(this.getClass().getResource("/spellChecker/index"));

It works all good in both Eclipse and ‘gradle run’ scenario, but when I use distTar or distZip to pack my project, problem jumps in. distTar task will copy the ‘spellChecker’ folder into ‘$TarFile/lib/spellChecker’, but in the OS launch script, it adds ‘$APP_HOME/lib/dict’ to my classpath, that means the target folder miss ‘dict’ in the middle, so I guess the correct target folder should be ‘$TarFile/lib/dict/sepllChecker’.

I don’t know if this is a bug or intention. But in order to fix this I have to un-tar my tar-file, go into the lib folder, manually create a dict foder, and move the spellChecker in to dict every time!


(Benjamin Muschko) #2

Please provide the relevant Gradle build code so we can understand how you are bundling your archive.


(Joey Liu) #3

I have only one build file. the project I’ve mentioned is a sub-project called libicon, this sub-project has a dict folder. /root |–src/main/java/ |–libicon |–|--src/main/java/ |–|--src/main/resources/ |–|--dict/spellChecker/ |–other-sub-projects

allprojects {

apply plugin: ‘eclipse’

apply plugin: ‘java’

group = ‘com.philips.prna’

version = ‘1.0’

repositories {

mavenCentral()

maven {

url “http://svn.code.sf.net/p/bionlp/code/repo

}

maven {

url “http://maven.aksw.org/archiva/repository/internal

}

}

}

apply plugin: ‘application’

mainClassName = “com.philips.prna.client_server.iconServer”

dependencies {

compile “javax.servlet:servlet-api:2.5”

compile “org.apache.uima:uimaj-core:2.5.0”

compile “org.apache.xmlrpc:xmlrpc-client:3.1.3”

compile “org.apache.xmlrpc:xmlrpc-server:3.1.3”

compile “org.swinglabs:swingx:1.6.1”

compile project(path: ‘:libicon’), project(path: ‘:UIMAWrapper’)

}

task cvd(type: JavaExec, dependsOn:[classes]) {

main = “org.apache.uima.tools.cvd.CVD”

classpath = sourceSets.main.runtimeClasspath

}

task client(type: JavaExec, dependsOn:[classes]) {

main = “com.philips.prna.client_server.IconClientUI”

classpath = sourceSets.main.runtimeClasspath

}

project(’:icon-type-system’) {

dependencies {

compile “org.apache.ctakes:ctakes-type-system:3.1.1”

}

}

project(’:libicon’) {

dependencies {

compile “commons-lang:commons-lang:2.6”

compile “edu.stanford.nlp:stanford-parser:3.3.1”

compile “edu.stanford.nlp:stanford-parser:3.3.1:models”

compile “edu.ucdenver.ccp:biolemmatizer-core:1.2”

compile “mysql:mysql-connector-java:5.1.29”

compile “org.apache.jena:apache-jena-libs:2.11.1”

compile “org.apache.lucene:lucene-analyzers-common:4.7.0”

compile “org.apache.lucene:lucene-core:4.7.0”

compile “org.apache.lucene:lucene-queryparser:4.7.0”

compile “org.apache.lucene:lucene-suggest:4.7.0”

compile “org.mongodb.morphia:morphia:0.107”

compile “org.simpleframework:simple-xml:2.7.1”

runtime files(“dict”)

compile project(path: “:icon-type-system”)

testCompile “junit:junit:4.11”

}

apply plugin: ‘application’

mainClassName = “com.philips.prna.libmain.test”

}

project(’:UIMAWrapper’) {

dependencies {

compile “org.antlr:antlrworks:1.5.2”

compile “org.apache.ctakes:ctakes-chunker:3.1.1”

compile “org.apache.ctakes:ctakes-core-res:3.1.1”

compile “org.apache.ctakes:ctakes-core:3.1.1”

compile “org.apache.ctakes:ctakes-pos-tagger:3.1.1”

compile “org.apache.opennlp:opennlp-maxent:3.0.3”

compile “org.apache.opennlp:opennlp-tools:1.5.3”

compile project(path: ‘:libicon’)

testCompile “junit:junit:4.11”, project(’:libicon’)

}

}

project(":heideltime") {

dependencies {

compile project(path: ‘:libicon’), project(path: ‘:UIMAWrapper’)

runtime files(“resources”)

}

}

when I run ‘gradle :libicon:distTar’ the generated tar file has this layout / |–bin/ |–lib/spellChecker/ |–lib/other-*.jar

but I expecting something looks like this: / |–bin/ |–lib/dict/spellChecker/ |–lib/other-*.jar

because in the bash script, we have

CLASSPATH=$APP_HOME/lib/libicon-1.0.jar:$APP_HOME/lib/dict