0

I'm restructuring/refactoring build process for a big(ish) project. Currently it contains over a dozen separate modules built with standalone build scripts each. I want to integrate them all into a single multiproject build in Gradle.

After I integrated all sources into a single tree, fixed build.gradles, I came upon the following problem. Dependencies for many modules contain something like:

dependencies {
    compile group: 'com.company', name: 'Module', version: '1.2.3'
    // ...
    testCompile group: 'com.company', name: 'Module', version: '1.2.3', classifier: 'tests'
}

I want the build to use jars from the subproject, not from a repository. I replaced compile ... with compile project(':Module') and it works fine. However, I cannot find the way to pass 'tests' specifier to the testCompile project... dependency.

Is there a way to pick up the tests jar as a dependency to testCompile?

2
  • Wait ... Do you have test code in project A that depends on test code in project B? That sounds a bit unusual. Assuming that we're talking about unit tests, they would normally be highly local. Commented Jul 4, 2016 at 15:15
  • Well... Yes. I inherited a project in a really sorry state. Project B has some test utilities that unit tests in Project A depend on. Commented Jul 5, 2016 at 0:12

1 Answer 1

1

In the producing project you will need to declare the "Test" JAR as outgoing artifact.

configurations {
    testUtils
}

task testUtilsJar(type: Jar) {
    ...
}

artifacts {
    testUtils testUtilsJar
}

In the consuming project you depend on it as such:

dependencies {
    testCompile project(path: ':Module', configuration: 'testUtils')
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.