gradle 找不到参数[根项目..]的方法实现()

2w2cym1i  于 2023-10-19  发布在  其他
关注(0)|答案(1)|浏览(133)

您似乎正在尝试将测试套件从unbroken迁移到Gradle 7.4中引入的新gradle testsuite,但您的多构建设置遇到了一些问题。

testing {
    suites {
        integrationTest(JvmTestSuite) {
            implementation project // ALSO TRIED -> implementation subprojects
            testType = TestSuiteType.INTEGRATION_TEST

        }
        functionalTest(JvmTestSuite) {
            testType = TestSuiteType.FUNCTIONAL_TEST

        }
    }
}

configurations {
    integrationTestImplementation.extendsFrom testImplementation
    integrationTestRuntimeOnly.extendsFrom runtimeOnly
    functionalTestImplementation.extendsFrom integrationTestImplementation
    functionalTestRuntimeOnly.extendsFrom runtimeOnly
}

我希望能够在所有其他模块(如test、integrationTest等)中使用主模块中的类。然而,这似乎只在测试模块中是可能的,而在integrationTest或其他套件中是不可能的。
这种限制是否有具体原因?有没有一种方法可以克服这个问题,并在integrationtest中从主目录访问类?任何见解或指导将不胜感激。谢谢

ijxebb2r

ijxebb2r1#

似乎添加sources可以完成这项工作:/

testing {
    suites {
        integrationTest(JvmTestSuite) {
            testType = TestSuiteType.INTEGRATION_TEST
            sources {
                compileClasspath += sourceSets.main.compileClasspath + sourceSets.main.output
                runtimeClasspath += output + compileClasspath
            }

        }
        functionalTest(JvmTestSuite) {
            testType = TestSuiteType.FUNCTIONAL_TEST

        }
    }
}

configurations {
    integrationTestImplementation.extendsFrom testImplementation
    integrationTestRuntimeOnly.extendsFrom runtimeOnly
    functionalTestImplementation.extendsFrom integrationTestImplementation
    functionalTestRuntimeOnly.extendsFrom runtimeOnly
}
    sources {
        compileClasspath += sourceSets.main.compileClasspath + sourceSets.main.output
        runtimeClasspath += output + compileClasspath
    }

相关问题