gpt4 book ai didi

Gradle 6、Gradle TestKit 和 DuplicatesStrategy.INCLUDE 警告

转载 作者:行者123 更新时间:2023-12-03 03:25:54 31 4
gpt4 key购买 nike

自从将 Gradle 升级到版本 6 后,我注意到与我使用 TestKit 实现的功能测试相关的新警告。我很清楚如何摆脱它们。不清楚的是它们为什么首先出现,以及它们在功能测试的上下文中有何相关性。

这是我能想到的重现该问题的最小项目:

https://github.com/automatictester/gradle-issure-repro

相关build.gradle:

plugins {
id 'java'
id 'java-gradle-plugin'
}

sourceSets {
functionalTest {
java {
srcDir file('src/functionalTest/java')
}
resources {
srcDir file('src/functionalTest/resources')
}
compileClasspath += sourceSets.main.output + configurations.testRuntimeClasspath
runtimeClasspath += output + compileClasspath
}
}

task functionalTest(type: Test) {
testClassesDirs = sourceSets.functionalTest.output.classesDirs
classpath = sourceSets.functionalTest.runtimeClasspath
}

check.dependsOn functionalTest

gradlePlugin {
testSourceSets sourceSets.functionalTest
}

group 'org.example'
version '1.0-SNAPSHOT'

sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
mavenCentral()
jcenter()
}

dependencies {
testImplementation gradleTestKit()
testImplementation 'org.testng:testng:7.1.1'
}

// uncomment to get rid of warnings
//processFunctionalTestResources {
// duplicatesStrategy = DuplicatesStrategy.INCLUDE
//}

您可以通过以下方式重现该问题:

./gradlew clean functionalTest --warning-mode all

输出:

Copying or archiving duplicate paths with the default duplicates strategy has been deprecated. This is scheduled to be removed in Gradle 7.0. Duplicate path: "build.gradle". Explicitly set the duplicates strategy to 'DuplicatesStrategy.INCLUDE' if you want to allow duplicate paths. Consult the upgrading guide for further information: https://docs.gradle.org/6.2.1/userguide/upgrading_version_5.html#implicit_duplicate_strategy_for_copy_or_archive_tasks_has_been_deprecated
Copying or archiving duplicate paths with the default duplicates strategy has been deprecated. This is scheduled to be removed in Gradle 7.0. Duplicate path: "settings.gradle". Explicitly set the duplicates strategy to 'DuplicatesStrategy.INCLUDE' if you want to allow duplicate paths. Consult the upgrading guide for further information: https://docs.gradle.org/6.2.1/userguide/upgrading_version_5.html#implicit_duplicate_strategy_for_copy_or_archive_tasks_has_been_deprecated

BUILD SUCCESSFUL in 1s
6 actionable tasks: 6 executed

它基本上是为在 src/functionalTest/resources 中找到的每个文件打印一条警告。

有人可以帮助我了解此警告试图保护我免受的风险是什么,以及为什么与复制或存档任务相关的内容会出现在根据官方指南设置的功能测试配置中?

https://docs.gradle.org/6.2.1/userguide/test_kit.html

最佳答案

您的(派生的)任务 processFunctionalTestResources is of type Copy ,它具有 DuplicatesStrategy 属性。 Starting at Gradle 6 ,如果未明确定义,它会显示警告。

我现在自己在执行 warear 任务时遇到这种情况。

来自second link :

Archive tasks Tar and Zip by default allow multiple entries for the same path to exist in the created archive. This can cause "grossly invalid zip files" that can trigger zip bomb detection.

关于Gradle 6、Gradle TestKit 和 DuplicatesStrategy.INCLUDE 警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60420846/

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