Gradle build unable to find jars added via 'compile FileTree'. Could someone please assist?


(Asif Rahman) #1

Hi,

I have the following dependencies section, but when running gradle build, it errors saying those packages cannot be found : error: package org.jooq does not exist

repositories {

flatDir dirs: ["$projectDir/libs/JOOQ/3.11.4/JOOQ-lib"]
jcenter()
}

dependencies {

compile fileTree(dir: ‘$projectDir/libs/JOOQ/3.11.4/JOOQ-lib’, include: ‘.jar’, exclude: 'jooq-scala-.jar’)
compile(‘org.springframework.boot:spring-boot-starter-actuator’)
compile(‘org.springframework.boot:spring-boot-starter-websocket’)
compile(‘org.springframework.cloud:spring-cloud-starter-aws’)
compile(‘org.springframework.cloud:spring-cloud-stream’)
compile(‘org.springframework.cloud:spring-cloud-stream-binder-kafka’)
compile(‘org.springframework.kafka:spring-kafka’)
compile(‘org.flywaydb:flyway-core:3.2.1’)

testCompile(‘org.springframework.boot:spring-boot-starter-test’)
testCompile(‘org.springframework.cloud:spring-cloud-stream-test-support’)
}

If I print the classpath using the following, it does not appear:

task printClasspath {
doLast {
sourceSets.main.compileClasspath.each { println it }
}
}

I have also tried forcing adding the classpath using
sourceSets {
main {
compileClasspath += fileTree(’${projectDir}/libs/JOOQ/3.11.4/JOOQ-lib’)

}
}

Completely stumped. Could someone please suggest anything I am missing. Seems this should just work.


(Asif Rahman) #2

As the flatDirs entry was there in the repositories section, I was able to resolve the issue by replacing

compile fileTree(dir: ‘$projectDir/libs/JOOQ/3.11.4/JOOQ-lib’, include: ‘.jar’, exclude: 'jooq-scala-.jar’)

with

compile name: 'jooq-3.11.4’

which is very strange, the first entry should work out of the box.


(Chris Doré) #3

Looks like you might have a typo, try include: '*.jar' instead of include: '.jar'?


(Asif Rahman) #4

Shame on me, you are totally right! typo.