gpt4 book ai didi

java - 如何解决 Gradle 中的传递依赖冲突

转载 作者:行者123 更新时间:2023-12-01 19:17:39 26 4
gpt4 key购买 nike

我在 Gradle 构建中遇到了第一次传递依赖冲突,并且不确定众多记录的方法中哪一个最适合我的情况。

我有一个根项目,负责在多个子 Gradle 插件项目上运行功能测试,但除了测试用例之外没有其他代码。我正在使用Manual Classpath Injection方法获取测试类路径中的子项目。

// Write the plugin's classpath to a file to share with the tests
task pluginUnderTestMetadata {
def outputDir = file("${buildDir}/pluginUnderTestMetadata")
def runtimeClasspath = sourceSets.main.runtimeClasspath

outputs.dir(outputDir)
.withPropertyName("outputDir")

inputs.files(runtimeClasspath)
.withPropertyName("runtimeClasspath")
.withNormalizer(ClasspathNormalizer)


doLast {
outputDir.mkdirs()
file("$outputDir/plugin-classpath.txt").text = runtimeClasspath.join("\n")
}
}

dependencies {
implementation localGroovy(),
gradleApi(),
project(':waweb.site.plugin'),
project(':waweb.site.plugin.js'),
project(':waweb.site.plugin.sass'),
project(':waweb.site.plugin.template'),
project(':waweb.site.plugin.war')

testRuntimeOnly files(pluginUnderTestMetadata)
testImplementation gradleTestKit(),
"junit:junit:${JUNIT_VER}",
"org.assertj:assertj-core:${ASSERTJ_VER}",
"org.hamcrest:hamcrest:${HAMCREST_VER}",
"net.serenity-bdd:serenity-core:${SERENITY_VER}",
"net.serenity-bdd:serenity-junit:${SERENITY_VER}",
"net.serenity-bdd:serenity-cucumber:${SERENITY_CUCUMBER_VER}"
}

这一切都很好,直到我将 closure-compiler 添加为子项目之一的依赖项,这会导致运行时错误:

1) Error injecting constructor, java.lang.NoSuchMethodError: com.google.gson.Gson.<init>(Lcom/google/gson/internal/Excluder;Lcom/google/gson/FieldNamingStrategy;Ljava/util/Map;ZZZZZZZLcom/google/gson/LongSerializationPolicy;Ljava/lang/String;IILjava/util/List;Ljava/util/List;Ljava/util/List;)V
at net.thucydides.core.reports.json.gson.GsonJSONConverter.<init>(GsonJSONConverter.java:38)
while locating net.thucydides.core.reports.json.gson.GsonJSONConverter
at net.thucydides.core.guice.ThucydidesModule.configure(ThucydidesModule.java:56)
while locating net.thucydides.core.reports.json.JSONConverter
at net.serenitybdd.core.history.FileSystemTestOutcomeSummaryRecorder.<init>(FileSystemTestOutcomeSummaryRecorder.java:42)
while locating net.serenitybdd.core.history.FileSystemTestOutcomeSummaryRecorder
at net.thucydides.core.guice.ThucydidesModule.configure(ThucydidesModule.java:72)
while locating net.serenitybdd.core.history.TestOutcomeSummaryRecorder
for the 2nd parameter of net.serenitybdd.core.history.HistoricalFlagProvider.<init>(HistoricalFlagProvider.java:28)
while locating net.serenitybdd.core.history.HistoricalFlagProvider
at net.thucydides.core.guice.ThucydidesModule.configure(ThucydidesModule.java:71)
while locating net.thucydides.core.model.flags.FlagProvider

我相信这是由于 gson 版本冲突造成的,如下面的依赖关系报告所示。如果我能够以某种方式分离这些类路径,以便它们都可以毫无问题地使用它们的内部传递依赖项,那将是理想的,但考虑到我不寻常的设置,我不确定如何进行它,或者这是否可能。我是否需要定义一些约束、使用平台、解耦我的构建或完全执行其他操作?

除了可行的解决方案之外,您还可以提供任何见解,我们将不胜感激。

精简的依赖关系报告

runtimeClasspath - Runtime classpath of source set 'main'.
+--- project :waweb.site.plugin
| \--- org.codehaus.groovy:groovy-all:2.5.8
[SNIP GROOVY DEPS...]
+--- project :waweb.site.plugin.js
| +--- org.codehaus.groovy:groovy-all:2.5.8 (*)
| +--- com.google.javascript:closure-compiler:v20191111
| | +--- com.google.javascript:closure-compiler-externs:v20191111
| | +--- args4j:args4j:2.0.26
| | +--- com.google.errorprone:error_prone_annotations:2.3.1
| | +--- com.google.guava:guava:25.1-jre
| | | +--- com.google.code.findbugs:jsr305:3.0.2
| | | +--- org.checkerframework:checker-qual:2.0.0
| | | +--- com.google.errorprone:error_prone_annotations:2.1.3 -> 2.3.1
| | | +--- com.google.j2objc:j2objc-annotations:1.1
| | | \--- org.codehaus.mojo:animal-sniffer-annotations:1.14
| | +--- com.google.protobuf:protobuf-java:3.0.2
| | +--- com.google.code.gson:gson:2.7
| | +--- com.google.code.findbugs:jsr305:3.0.1 -> 3.0.2
| | +--- com.google.jsinterop:jsinterop-annotations:1.0.2
| | +--- com.google.jsinterop:base:1.0.0
| | | \--- com.google.jsinterop:jsinterop-annotations:1.0.2
| | +--- com.google.elemental2:elemental2-core:1.0.0-RC1
| | | +--- com.google.jsinterop:jsinterop-annotations:1.0.2
| | | \--- com.google.jsinterop:base:1.0.0-RC1 -> 1.0.0 (*)
| | \--- com.google.re2j:re2j:1.3
| \--- project :waweb.site.plugin (*)

testCompileClasspath - Compile classpath for source set 'test'.
+--- project :waweb.site.plugin
+--- project :waweb.site.plugin.js
+--- project :waweb.site.plugin.sass
+--- project :waweb.site.plugin.template
+--- project :waweb.site.plugin.war
+--- junit:junit:4.12
| \--- org.hamcrest:hamcrest-core:1.3
+--- org.assertj:assertj-core:3.14.0
+--- org.hamcrest:hamcrest:2.2
+--- net.serenity-bdd:serenity-core:2.0.90
| +--- net.bytebuddy:byte-buddy:1.10.1
| +--- net.bytebuddy:byte-buddy-agent:1.10.1
| +--- com.google.guava:guava:25.0-jre
| | +--- com.google.code.findbugs:jsr305:1.3.9
| | +--- org.checkerframework:checker-compat-qual:2.0.0
| | +--- com.google.errorprone:error_prone_annotations:2.1.3
| | +--- com.google.j2objc:j2objc-annotations:1.1
| | \--- org.codehaus.mojo:animal-sniffer-annotations:1.14
| +--- com.google.inject:guice:4.2.2
| | +--- javax.inject:javax.inject:1
| | \--- aopalliance:aopalliance:1.0
| +--- org.ow2.asm:asm:7.2
| +--- commons-codec:commons-codec:1.10
| +--- org.objenesis:objenesis:3.0.1
| +--- org.slf4j:slf4j-api:1.7.26
| +--- xml-apis:xml-apis:1.4.01
| +--- io.cucumber:cucumber-core:2.4.0
| | +--- info.cukes:cucumber-html:0.2.6
| | +--- io.cucumber:cucumber-jvm-deps:1.0.6
| | +--- io.cucumber:gherkin:5.0.0
| | \--- io.cucumber:tag-expressions:1.1.1
| +--- commons-logging:commons-logging:1.2
| +--- io.vavr:vavr:0.9.0
| | \--- io.vavr:vavr-match:0.9.0
| +--- javax.xml.bind:jaxb-api:2.2.12
| +--- com.sun.xml.bind:jaxb-core:2.3.0.1
| +--- com.sun.xml.bind:jaxb-impl:2.3.0.1
| +--- javax.activation:activation:1.1.1
| +--- org.mockito:mockito-core:3.1.0
| +--- net.serenity-bdd:serenity-report-resources:2.0.90
| | +--- net.bytebuddy:byte-buddy:1.10.1
| | +--- net.bytebuddy:byte-buddy-agent:1.10.1
| | +--- com.google.guava:guava:25.0-jre (*)
| | +--- com.google.inject:guice:4.2.2 (*)
| | +--- org.ow2.asm:asm:7.2
| | +--- commons-codec:commons-codec:1.10
| | +--- org.objenesis:objenesis:3.0.1
| | +--- org.slf4j:slf4j-api:1.7.26
| | +--- xml-apis:xml-apis:1.4.01
| | +--- io.cucumber:cucumber-core:2.4.0 (*)
| | +--- commons-logging:commons-logging:1.2
| | +--- io.vavr:vavr:0.9.0 (*)
| | +--- javax.xml.bind:jaxb-api:2.2.12
| | +--- com.sun.xml.bind:jaxb-core:2.3.0.1
| | +--- com.sun.xml.bind:jaxb-impl:2.3.0.1
| | +--- javax.activation:activation:1.1.1
| | \--- org.mockito:mockito-core:3.1.0
| +--- net.serenity-bdd:serenity-model:2.0.90
| | +--- net.bytebuddy:byte-buddy:1.10.1
| | +--- net.bytebuddy:byte-buddy-agent:1.10.1
| | +--- com.google.guava:guava:25.0-jre (*)
| | +--- com.google.inject:guice:4.2.2 (*)
| | +--- org.ow2.asm:asm:7.2
| | +--- commons-codec:commons-codec:1.10
| | +--- org.objenesis:objenesis:3.0.1
| | +--- org.slf4j:slf4j-api:1.7.26
| | +--- xml-apis:xml-apis:1.4.01
| | +--- io.cucumber:cucumber-core:2.4.0 (*)
| | +--- commons-logging:commons-logging:1.2
| | +--- io.vavr:vavr:0.9.0 (*)
| | +--- javax.xml.bind:jaxb-api:2.2.12
| | +--- com.sun.xml.bind:jaxb-core:2.3.0.1
| | +--- com.sun.xml.bind:jaxb-impl:2.3.0.1
| | +--- javax.activation:activation:1.1.1
| | +--- org.mockito:mockito-core:3.1.0
| | +--- net.serenity-bdd:serenity-report-resources:2.0.90 (*)
| | +--- org.apache.commons:commons-lang3:3.8.1
| | +--- commons-net:commons-net:3.6
| | +--- com.typesafe:config:1.3.1
| | +--- org.jsoup:jsoup:1.10.3
| | +--- joda-time:joda-time:2.7
| | +--- commons-collections:commons-collections:3.2.2
| | +--- commons-io:commons-io:2.6
| | +--- org.apache.commons:commons-text:1.6 -> 1.7
| | +--- commons-beanutils:commons-beanutils-core:1.8.3
| | +--- net.sf.opencsv:opencsv:2.0
| | +--- com.google.code.gson:gson:2.8.4
| | +--- org.imgscalr:imgscalr-lib:4.2
| | +--- com.thoughtworks.xstream:xstream:1.4.9
| | | +--- xmlpull:xmlpull:1.1.3.1
| | | \--- xpp3:xpp3_min:1.1.4c
| | +--- org.codehaus.groovy:groovy:2.5.5
| | +--- net.sourceforge.jexcelapi:jxl:2.6.12
| | +--- org.awaitility:awaitility:4.0.1
| | | \--- org.hamcrest:hamcrest:2.1 -> 2.2
| | +--- org.asciidoctor:asciidoctorj:1.5.6
| | +--- org.freemarker:freemarker:2.3.28
| | +--- com.vladsch.flexmark:flexmark-all:0.34.30
[SNIP FLEXMARK DEPS...]
| | \--- es.nitaur.markdown:txtmark:0.16
| +--- net.serenity-bdd:serenity-reports:2.0.90
| | +--- net.bytebuddy:byte-buddy:1.10.1
| | +--- net.bytebuddy:byte-buddy-agent:1.10.1
| | +--- com.google.guava:guava:25.0-jre (*)
| | +--- com.google.inject:guice:4.2.2 (*)
| | +--- org.ow2.asm:asm:7.2
| | +--- commons-codec:commons-codec:1.10
| | +--- org.objenesis:objenesis:3.0.1
| | +--- org.slf4j:slf4j-api:1.7.26
| | +--- xml-apis:xml-apis:1.4.01
| | +--- io.cucumber:cucumber-core:2.4.0 (*)
| | +--- commons-logging:commons-logging:1.2
| | +--- io.vavr:vavr:0.9.0 (*)
| | +--- javax.xml.bind:jaxb-api:2.2.12
| | +--- com.sun.xml.bind:jaxb-core:2.3.0.1
| | +--- com.sun.xml.bind:jaxb-impl:2.3.0.1
| | +--- javax.activation:activation:1.1.1
| | +--- org.mockito:mockito-core:3.1.0
| | +--- net.serenity-bdd:serenity-model:2.0.90 (*)
| | \--- net.serenity-bdd:serenity-stats:2.0.90
| | +--- net.bytebuddy:byte-buddy:1.10.1
| | +--- net.bytebuddy:byte-buddy-agent:1.10.1
| | +--- com.google.guava:guava:25.0-jre (*)
| | +--- com.google.inject:guice:4.2.2 (*)
| | +--- org.ow2.asm:asm:7.2
| | +--- commons-codec:commons-codec:1.10
| | +--- org.objenesis:objenesis:3.0.1
| | +--- org.slf4j:slf4j-api:1.7.26
| | +--- xml-apis:xml-apis:1.4.01
| | +--- io.cucumber:cucumber-core:2.4.0 (*)
| | +--- commons-logging:commons-logging:1.2
| | +--- io.vavr:vavr:0.9.0 (*)
| | +--- javax.xml.bind:jaxb-api:2.2.12
| | +--- com.sun.xml.bind:jaxb-core:2.3.0.1
| | +--- com.sun.xml.bind:jaxb-impl:2.3.0.1
| | +--- javax.activation:activation:1.1.1
| | +--- org.mockito:mockito-core:3.1.0
| | +--- net.serenity-bdd:serenity-model:2.0.90 (*)
| | \--- org.jetbrains.kotlin:kotlin-stdlib:1.3.31
| | +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.31
| | \--- org.jetbrains:annotations:13.0
| +--- com.google.code.gson:gson:2.8.4
| +--- commons-io:commons-io:2.6
| +--- org.seleniumhq.selenium:selenium-server:3.141.59
[SNIP SELENIUM DEPS]
| +--- com.paulhammant:ngwebdriver:1.1.4
| +--- com.codeborne:phantomjsdriver:1.4.4
| +--- org.seleniumhq.selenium:htmlunit-driver:2.36.0
| | \--- net.sourceforge.htmlunit:htmlunit:2.36.0
| | +--- xalan:xalan:2.7.2
| | | \--- xalan:serializer:2.7.2
| | | \--- xml-apis:xml-apis:1.3.04 -> 1.4.01
| | +--- org.apache.commons:commons-text:1.7
| | +--- org.apache.httpcomponents:httpmime:4.5.9
| | | \--- org.apache.httpcomponents:httpclient:4.5.9
| | | +--- org.apache.httpcomponents:httpcore:4.4.11
| | | \--- commons-logging:commons-logging:1.2
| | +--- net.sourceforge.htmlunit:htmlunit-core-js:2.36.0
| | +--- net.sourceforge.htmlunit:neko-htmlunit:2.36.0
| | | \--- xerces:xercesImpl:2.12.0
| | | \--- xml-apis:xml-apis:1.4.01
| | +--- net.sourceforge.htmlunit:htmlunit-cssparser:1.5.0
| | +--- commons-io:commons-io:2.6
| | +--- commons-logging:commons-logging:1.2
| | +--- commons-net:commons-net:3.6
| | +--- org.brotli:dec:0.1.2
| | \--- org.eclipse.jetty.websocket:websocket-client:9.4.20.v20190813
| | +--- org.eclipse.jetty:jetty-client:9.4.20.v20190813
| | | +--- org.eclipse.jetty:jetty-http:9.4.20.v20190813
| | | | +--- org.eclipse.jetty:jetty-util:9.4.20.v20190813
| | | | \--- org.eclipse.jetty:jetty-io:9.4.20.v20190813
| | | | \--- org.eclipse.jetty:jetty-util:9.4.20.v20190813
| | | \--- org.eclipse.jetty:jetty-io:9.4.20.v20190813 (*)
| | +--- org.eclipse.jetty:jetty-xml:9.4.20.v20190813
| | | \--- org.eclipse.jetty:jetty-util:9.4.20.v20190813
| | +--- org.eclipse.jetty:jetty-util:9.4.20.v20190813
| | +--- org.eclipse.jetty:jetty-io:9.4.20.v20190813 (*)
| | \--- org.eclipse.jetty.websocket:websocket-common:9.4.20.v20190813
| | +--- org.eclipse.jetty.websocket:websocket-api:9.4.20.v20190813
| | +--- org.eclipse.jetty:jetty-util:9.4.20.v20190813
| | \--- org.eclipse.jetty:jetty-io:9.4.20.v20190813 (*)
| +--- io.appium:java-client:7.2.0
| | +--- commons-validator:commons-validator:1.6
| | | +--- commons-beanutils:commons-beanutils:1.9.2
| | | | \--- commons-collections:commons-collections:3.2.1 -> 3.2.2
| | | +--- commons-digester:commons-digester:1.8.1
| | | \--- commons-collections:commons-collections:3.2.2
| | +--- org.aspectj:aspectjweaver:1.9.4
| | \--- org.slf4j:slf4j-api:1.7.26
| +--- org.springframework:spring-context-support:5.1.2.RELEASE
| | +--- org.springframework:spring-beans:5.1.2.RELEASE
| | | \--- org.springframework:spring-core:5.1.2.RELEASE
| | | \--- org.springframework:spring-jcl:5.1.2.RELEASE
| | +--- org.springframework:spring-context:5.1.2.RELEASE
| | | +--- org.springframework:spring-aop:5.1.2.RELEASE
| | | | +--- org.springframework:spring-beans:5.1.2.RELEASE (*)
| | | | \--- org.springframework:spring-core:5.1.2.RELEASE (*)
| | | +--- org.springframework:spring-beans:5.1.2.RELEASE (*)
| | | +--- org.springframework:spring-core:5.1.2.RELEASE (*)
| | | \--- org.springframework:spring-expression:5.1.2.RELEASE
| | | \--- org.springframework:spring-core:5.1.2.RELEASE (*)
| | \--- org.springframework:spring-core:5.1.2.RELEASE (*)
| +--- org.codehaus.groovy:groovy:2.5.5
| +--- net.sf.opencsv:opencsv:2.0
| +--- commons-beanutils:commons-beanutils-core:1.8.3
| +--- joda-time:joda-time:2.7
| +--- com.thoughtworks.xstream:xstream:1.4.9 (*)
| +--- org.apache.commons:commons-lang3:3.8.1
| +--- commons-collections:commons-collections:3.2.2
| +--- org.freemarker:freemarker:2.3.28
| +--- net.sourceforge.jexcelapi:jxl:2.6.12
| +--- org.hamcrest:hamcrest-core:1.3
| +--- org.hamcrest:hamcrest-library:1.3
| | \--- org.hamcrest:hamcrest-core:1.3
| +--- net.sourceforge.htmlunit:htmlunit:2.36.0 (*)
| +--- org.apache.httpcomponents:httpclient:4.5.5 -> 4.5.9 (*)
| +--- org.apache.httpcomponents:httpmime:4.5.5 -> 4.5.9 (*)
| +--- org.fluentlenium:fluentlenium-core:0.10.2
| +--- com.jhlabs:filters:2.0.235
| +--- org.asciidoctor:asciidoctorj:1.5.6
| +--- org.imgscalr:imgscalr-lib:4.2
| +--- javax.el:javax.el-api:2.2.4
| +--- org.glassfish.web:javax.el:2.2.4
| | \--- javax.el:javax.el-api:2.2.4
| +--- xalan:xalan:2.7.2 (*)
| +--- xalan:serializer:2.7.2 (*)
| +--- org.awaitility:awaitility:4.0.1 (*)
| +--- com.typesafe:config:1.3.1
| +--- org.jsoup:jsoup:1.10.3
| +--- com.google.jimfs:jimfs:1.1
| \--- com.vladsch.flexmark:flexmark-all:0.34.30 (*)
+--- net.serenity-bdd:serenity-junit:2.0.90
| +--- net.bytebuddy:byte-buddy:1.10.1
| +--- net.bytebuddy:byte-buddy-agent:1.10.1
| +--- com.google.guava:guava:25.0-jre (*)
| +--- com.google.inject:guice:4.2.2 (*)
| +--- org.ow2.asm:asm:7.2
| +--- commons-codec:commons-codec:1.10
| +--- org.objenesis:objenesis:3.0.1
| +--- org.slf4j:slf4j-api:1.7.26
| +--- xml-apis:xml-apis:1.4.01
| +--- io.cucumber:cucumber-core:2.4.0 (*)
| +--- commons-logging:commons-logging:1.2
| +--- io.vavr:vavr:0.9.0 (*)
| +--- javax.xml.bind:jaxb-api:2.2.12
| +--- com.sun.xml.bind:jaxb-core:2.3.0.1
| +--- com.sun.xml.bind:jaxb-impl:2.3.0.1
| +--- javax.activation:activation:1.1.1
| +--- org.mockito:mockito-core:3.1.0
| +--- net.serenity-bdd:serenity-model:2.0.90 (*)
| +--- net.serenity-bdd:serenity-core:2.0.90 (*)
| +--- junit:junit:4.12 (*)
| \--- org.hamcrest:hamcrest-core:1.3
\--- net.serenity-bdd:serenity-cucumber:1.9.49
+--- net.serenity-bdd:serenity-core:2.0.90 (*)
+--- net.serenity-bdd:serenity-screenplay:2.0.90
| +--- net.bytebuddy:byte-buddy:1.10.1
| +--- net.bytebuddy:byte-buddy-agent:1.10.1
| +--- com.google.guava:guava:25.0-jre (*)
| +--- com.google.inject:guice:4.2.2 (*)
| +--- org.ow2.asm:asm:7.2
| +--- commons-codec:commons-codec:1.10
| +--- org.objenesis:objenesis:3.0.1
| +--- org.slf4j:slf4j-api:1.7.26
| +--- xml-apis:xml-apis:1.4.01
| +--- io.cucumber:cucumber-core:2.4.0 (*)
| +--- commons-logging:commons-logging:1.2
| +--- io.vavr:vavr:0.9.0 (*)
| +--- javax.xml.bind:jaxb-api:2.2.12
| +--- com.sun.xml.bind:jaxb-core:2.3.0.1
| +--- com.sun.xml.bind:jaxb-impl:2.3.0.1
| +--- javax.activation:activation:1.1.1
| +--- org.mockito:mockito-core:3.1.0
| \--- net.serenity-bdd:serenity-core:2.0.90 (*)
+--- net.serenity-bdd:serenity-screenplay-webdriver:2.0.90
| +--- net.bytebuddy:byte-buddy:1.10.1
| +--- net.bytebuddy:byte-buddy-agent:1.10.1
| +--- com.google.guava:guava:25.0-jre (*)
| +--- com.google.inject:guice:4.2.2 (*)
| +--- org.ow2.asm:asm:7.2
| +--- commons-codec:commons-codec:1.10
| +--- org.objenesis:objenesis:3.0.1
| +--- org.slf4j:slf4j-api:1.7.26
| +--- xml-apis:xml-apis:1.4.01
| +--- io.cucumber:cucumber-core:2.4.0 (*)
| +--- commons-logging:commons-logging:1.2
| +--- io.vavr:vavr:0.9.0 (*)
| +--- javax.xml.bind:jaxb-api:2.2.12
| +--- com.sun.xml.bind:jaxb-core:2.3.0.1
| +--- com.sun.xml.bind:jaxb-impl:2.3.0.1
| +--- javax.activation:activation:1.1.1
| +--- org.mockito:mockito-core:3.1.0
| +--- net.serenity-bdd:serenity-core:2.0.90 (*)
| \--- net.serenity-bdd:serenity-screenplay:2.0.90 (*)
+--- io.cucumber:cucumber-java:2.4.0
| \--- io.cucumber:cucumber-core:2.4.0 (*)
+--- io.cucumber:cucumber-junit:2.4.0
| \--- io.cucumber:cucumber-core:2.4.0 (*)
+--- commons-logging:commons-logging:1.2
+--- org.apache.commons:commons-csv:1.5
+--- junit:junit:4.12 (*)
\--- com.google.code.gson:gson:2.8.4

最佳答案

我真的应该等 24 小时再发帖,因为当我在想其他事情时,答案总是会随机地出现在我的脑海中。

解决方案:

configurations {
pluginsUnderTest
}

task pluginUnderTestMetadata {
def outputDir = file("${buildDir}/pluginUnderTestMetadata")
def runtimeClasspath = configurations.pluginsUnderTest

outputs.dir(outputDir)
.withPropertyName("outputDir")

inputs.files(runtimeClasspath)
.withPropertyName("runtimeClasspath")
.withNormalizer(ClasspathNormalizer)


doLast {
outputDir.mkdirs()
file("$outputDir/plugin-classpath.txt").text = runtimeClasspath.join("\n")
}
}

dependencies {
pluginsUnderTest localGroovy(),
gradleApi(),
project(':waweb.site.plugin'),
project(':waweb.site.plugin.js'),
project(':waweb.site.plugin.sass'),
project(':waweb.site.plugin.template'),
project(':waweb.site.plugin.war')

testRuntimeOnly files(pluginUnderTestMetadata)
testImplementation gradleTestKit(),
"junit:junit:${JUNIT_VER}",
"org.assertj:assertj-core:${ASSERTJ_VER}",
"org.hamcrest:hamcrest:${HAMCREST_VER}",
"net.serenity-bdd:serenity-core:${SERENITY_VER}",
"net.serenity-bdd:serenity-junit:${SERENITY_VER}",
"net.serenity-bdd:serenity-cucumber:${SERENITY_CUCUMBER_VER}"
}

希望如果任何人希望对插件项目的各种配置进行功能测试,这至少可以节省一些时间。

关于java - 如何解决 Gradle 中的传递依赖冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59400795/

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