Gradle:为什么sourceSets.main.output可用但其他没有?

时间:2018-02-16 15:44:23

标签: java gradle

好的我正在使用gradle编译4个sourceSets,一个是main,另外3个是基于稍后在" server"中提供的其他类反射加载的其他小块代码。

到目前为止,这是有效的

        configurations {
            extralibs
            worldguard5
            worldguard6
            worldguard613
        }
    sourceSets {
        main {
            java {
                srcDir 'src/main/java'
            }
        }
        wg5 {
            compileClasspath = configurations.worldguard5
            java {
                srcDir 'src/worldguard5/java'
            }
        }
        wg6 {
            compileClasspath = configurations.worldguard6
            java {
                srcDir 'src/worldguard6/java'
            }
        }
        wg613 {
            compileClasspath = configurations.worldguard613
            java {
                srcDir 'src/worldguard613/java'
            }
        }
dependencies {
    compile 'mysql:mysql-connector-java:5.1.13'
    compile 'org.xerial:sqlite-jdbc:3.7.2'
    compile 'com.sk89q:worldguard:6.0.0-SNAPSHOT'
    compile 'com.sk89q:worldedit:5.5.9-SNAPSHOT'
    worldguard5 sourceSets.main.output
    worldguard5 'com.sk89q:worldguard:5.9.1-SNAPSHOT'
    worldguard5 'com.sk89q:worldedit:5.5.9-SNAPSHOT'
    worldguard6 sourceSets.main.output
    worldguard6 'com.sk89q:worldguard:6.0.0-SNAPSHOT'
    worldguard6 'com.sk89q:worldedit:5.5.9-SNAPSHOT'
    worldguard613 sourceSets.wg6.output
    worldguard613 'com.sk89q.worldguard:worldguard-legacy:6.1.3-SNAPSHOT'
    worldguard613 'com.sk89q:worldedit:5.5.9-SNAPSHOT'
}

现在除

外都有效

worldguard613 sourceSets.wg6.output

给出错误

> Could not get unknown property 'worldguard6' for SourceSet container.

有什么想法吗?

======================================== 更新它有效。接受的答案有效

dependencies {
    compile fileTree(dir: 'lib', include: '*.jar')
    compile 'org.json:json:20090211'
    compile 'javax.validation:validation-api:1.1.0.Final'
    compile 'mysql:mysql-connector-java:5.1.13'
    compile 'org.xerial:sqlite-jdbc:3.7.2'
    compile 'com.sk89q:worldguard:6.0.0-SNAPSHOT'
    compile 'com.sk89q:worldedit:5.5.9-SNAPSHOT'
    worldguard5 sourceSets.main.output
    worldguard5 'com.sk89q:worldguard:5.9.1-SNAPSHOT'
    worldguard5 'com.sk89q:worldedit:5.5.9-SNAPSHOT'
    worldguard6 sourceSets.main.output
    worldguard6 'com.sk89q:worldguard:6.0.0-SNAPSHOT'
    worldguard6 'com.sk89q:worldedit:5.5.9-SNAPSHOT'
    worldguard613 sourceSets.main.output
    worldguard613 'com.sk89q.worldguard:worldguard-legacy:6.1.3-SNAPSHOT'
    worldguard613 'com.sk89q:worldedit:5.5.9-SNAPSHOT'
    testCompile 'junit:junit:4.12'
}



sourceSets {
    main {
        java {
            srcDir 'src/main/java'
        }
    }
    wg5 {
        compileClasspath = configurations.worldguard5
        java {
            srcDir 'src/worldguard5/java'
        }
    }
    wg6 {
        compileClasspath = configurations.worldguard6
        java {
            srcDir 'src/worldguard6/java'
        }
    }
    wg613 {
        compileClasspath = configurations.worldguard613 + wg6.output
        java {
            srcDir 'src/worldguard613/java'
        }
    }
}

1 个答案:

答案 0 :(得分:1)

也许尝试类似的东西:

wg613 {
    compileClasspath = configurations.worldguard613 + wg6.output
    java {
        srcDir 'src/worldguard613/java'
    }
}

并删除

worldguard613 sourceSets.wg6.output