简体   繁体   English

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

[英]How to resolve transitive dependency conflict in Gradle

I have encountered my first transitive dependency conflict in a Gradle build, and am not sure which of the many documented methods best applies to my case.我在 Gradle 构建中遇到了我的第一个传递依赖冲突,并且不确定许多记录的方法中的哪一个最适合我的情况。

I have a root project which is responsible for running functional tests on multiple child Gradle Plugin Project, but has no other code besides the test cases.我有一个根项目,负责在多个子 Gradle 插件项目上运行功能测试,但除了测试用例之外没有其他代码。 I am using the Manual Classpath Injection method to get the child projects in the test classpath.我正在使用手动类路径注入方法来获取测试类路径中的子项目。

// 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}"
}

This all works great until I add closure-compiler as a dependency to one of the subprojects, which results in a runtime error:这一切都很好,直到我将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

I believe this is due to confliting gson versions as shown in the dependency report below.我相信这是由于下面的依赖关系报告中显示的 gson 版本冲突造成的。 It would be ideal if I could somehow seperate these classpaths so they could both use thier internal transitive dependencies without issue, but I'm not sure how to go about it given my unusual setup, or if this is even possible.如果我能以某种方式分离这些类路径,以便它们都可以毫无问题地使用它们的内部传递依赖项,那将是理想的,但我不确定如何解决我不寻常的设置,或者这是否可能。 Do I need to define some constraints, use a platform, decouple my builds, or something else entirely?我是否需要定义一些约束、使用平台、分离我的构建,或者完全其他的东西?

Any insight you can give in addition to a working solution will be greatly appreciated.除了有效的解决方案之外,您还可以提供任何见解,我们将不胜感激。

Abridged Dependency Report删节依赖报告

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

I really should wait 24 hours before I post because the answer always pops into my head randomly when I'm thinking of something else.我真的应该等待 24 小时后再发帖,因为当我想到其他事情时,答案总是随机出现在我的脑海中。

Solution:解决方案:

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}"
}

Hopefully this will at least save anyone some time if they wish to set up functional tests on various configurations of plugin projects.希望这至少可以为任何人节省一些时间,如果他们希望对插件项目的各种配置进行功能测试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM