On 27/07/10 1:07 AM, richardm wrote:
I have a multiproject build with the following layout.

TopLevelProject
    /SubProjA/src
    /SubProjB/src
    /SubProjC/src
    /tests            -- all unit tests for SubProjects
    /lib                -- JAR files required for compile of SubProjects
    build.gradle
    settings.gradle

How can I specify the classpath for tests to include the compiled classes
(or generated JARS) from the subprojects?

The tests directory contains the src code for junit tests for all of the
subprojects.

I have the subprojects compiling OK, but compiling the unit test classes in
TopLevelProject/tests keeps failing as the compiled classes in the
subprojects aren't on the classpath.

My build.gradle file is shown below.  Thanks.

apply plugin: 'java'

dependsOnChildren()

I'd get rid of dependsOnChildren(), and do something like:

dependencies {
    testCompile subprojects
}

This will include the main classes of each subproject in the compile classpath for the tests.

allprojects {   
        sourceCompatibility = 1.5
        targetCompatibility = 1.5
}

sourceSets {
   test {
         java {
             srcDir 'tests'
         }
         resources {
             srcDir 'tests'
         }              
        }
}

subprojects  {
        apply plugin: 'java'
        sourceSets.main.java.srcDir 'src'       
        dependencies{                           
                //TODO remove hard-coded references to D:/workspace
                compile fileTree(dir: 'D:/workspace/uwm/lib', include: '*.jar'),
fileTree(dir: 'D:/workspace/uwm/build/lib', include: '*.jar')                   
        }
}

project(':SubProjB') {
   dependencies.compile project(':SubProjA')    
}

project(':SubProjC') {
   dependencies.compile project(':SubProjB')    
}




--
Adam Murdoch
Gradle Developer
http://www.gradle.org
CTO, Gradle Inc. - Gradle Training, Support, Consulting
http://www.gradle.biz


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email


Reply via email to