当前位置: 首页 > 知识库问答 >
问题:

Gradle:为什么sourcesets.main.output可用,而其他的却不行?

曾绯辞
2023-03-14

好的,我正在使用gradle编译4个源集,一个是main,另外3个是反射加载的其他小段代码,这些代码基于稍后在“服务器”中可用的其他类。

        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'
}
> 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个答案

党博超
2023-03-14

也许可以试试这样的方法:

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

并删除

worldguard613 sourceSets.wg6.output
 类似资料: