gpt4 book ai didi

java - Gradle在testRunTime期间排除本地jar

转载 作者:行者123 更新时间:2023-12-03 05:21:09 26 4
gpt4 key购买 nike

我在这里遇到以下情况...我的Gradle jar目标需要javaee-api-*.jar作为compile时间

dependencies {

compile fileTree(dir: '../lib', include: ['/**/javaee-api-*.jar'])

}
但是,在执行 Gradle test时,我需要如下所示的 dependencies ...
dependencies {

compileOnly fileTree(dir: '../lib', include: ['/**/javaee-api-*.jar'])

}
testRunTime期间应如何排除 jar ?

最佳答案

我从javaee-api-*.jar过滤掉project.sourceSets.test.runtimeClasspath.filter添加了javaee-api-*.jar作为编译依赖项

dependencies {

compile fileTree(dir: '../lib', include: ['/**/javaee-api-*.jar'])

}
   sourceSets {

....

test {
runtimeClasspath = project.sourceSets.test.runtimeClasspath.filter {
!it.path.endsWith('oraclejavaee/javaee-api-6.0.jar')
}
java.srcDir project(':test-framework').file("src")
resources.srcDirs project(':test-framework').file("config")
}
}

并在其中添加 dependOn
test {
dependsOn(testClasses)
useTestNG() { //Tells Gradle to use TestNG
useDefaultListeners = true // Tells TestNG to execute its default reporting structure
suites 'test/testng.xml' //location of our suite.xml
}
}

关于java - Gradle在testRunTime期间排除本地jar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63447283/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com