小编Vra*_*ent的帖子

使内部声明对 Kotlin 中的其他模块可见

我有一个使用 Gradle 进行构建/测试的 Kotlin 项目。在 Kotlin 中,您可以将依赖项标记为internal,例如:

internal class MyClass : MyInterface
Run Code Online (Sandbox Code Playgroud)

现在,我还想test在 Gradle 中运行一些与正常任务分开的集成测试,因此我修改了build.gradle,如下所示:

sourceSets {
    testIntegration {
        compileClasspath = files(main.output, project.configurations.testCompileClasspath)
        runtimeClasspath = files(testIntegration.output, main.output, project.configurations.testRuntimeClasspath)
    }
}

task testIntegration(type: Test) {
    group = "Verification"
    description = "Integration tests"

    testClassesDirs = sourceSets.testIntegration.output.classesDirs
    classpath = sourceSets.testIntegration.runtimeClasspath

    useTestNG()
}
Run Code Online (Sandbox Code Playgroud)

它工作正常,除非我想访问内部声明:

sourceSets {
    testIntegration {
        compileClasspath = files(main.output, project.configurations.testCompileClasspath)
        runtimeClasspath = files(testIntegration.output, main.output, project.configurations.testRuntimeClasspath)
    }
}

task testIntegration(type: Test) {
    group = "Verification"
    description = …
Run Code Online (Sandbox Code Playgroud)

testing visibility gradle kotlin

5
推荐指数
0
解决办法
312
查看次数

标签 统计

gradle ×1

kotlin ×1

testing ×1

visibility ×1