rajesh
rajesh

Reputation: 3407

gradle local jar dependency not working

I am pretty new to gradle. This is my project configuration

Project
.
├── build.gradle
├── sub-project-1
│   ├── build.gradle
├── tests
│   ├── rest
│   └── unit
│       ├── build.gradle // Lets call this unit_build.gradle

My unit tests have a dependency on derby.jar, and the unit_build.gradle has the following:

dependencies{
    ..
    testCompile fileTree(dir: "${System.getProperty('java.home')}/../db/lib", include: "derby.jar") 
    testCompile fileTree(dir: "${System.getProperty('java.home')}/../db/lib", include: "derbyclient.jar") 
}

Note: We have our own repository and derby is not included in that. So we use it by adding it from local.

This works fine when I run a gradle build, followed by my test task.

But we also publish the jar to a test server and run it there where it fails with a class not found exception on derby.

What can be the reason? What should be done to fix this?

Gradle version - 1.12

Upvotes: 4

Views: 1456

Answers (1)

Sergei Iakovlev
Sergei Iakovlev

Reputation: 386

this happens because you choose wrong target dependency configuration. I mean testCompile, instead of this you should use: testRuntime or testRuntimeClasspath

Upvotes: 1

Related Questions