From 38edd22961a4ca36b59e7d996769e51ce98f3dee Mon Sep 17 00:00:00 2001 From: CyC2018 Date: Sat, 7 Nov 2026 17:10:29 +0800 Subject: [PATCH] =?UTF-8?q?Update=20=E6=9E=84=E5=BB=BA=E5=B7=A5=E5=85=B7.m?= =?UTF-8?q?d?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 示例依赖改为 junit 4.12,补充只加 plugins、不写 repositories 时的报错。 --- notes/构建工具.md | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/notes/构建工具.md b/notes/构建工具.md index 24f2f9ba..58ab12f2 100644 --- a/notes/构建工具.md +++ b/notes/构建工具.md @@ -41,7 +41,7 @@ Gradle 和 Maven 的区别是,Gradle 的构建脚本用基于 Groovy 或 Kotli junit junit - 4.10 + 4.12 test @@ -60,7 +60,7 @@ repositories { } dependencies { - testImplementation "junit:junit:4.10" + testImplementation "junit:junit:4.12" } ``` @@ -155,15 +155,22 @@ demo:a:pom:1.0 只写 dependencies 一段时,脚本求值失败: ```text -> Could not find method testImplementation() for arguments [junit:junit:4.10] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler. +> Could not find method testImplementation() for arguments [junit:junit:4.12] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler. +``` + +只加 plugins、不写 repositories 时,依赖解析失败(命令同下): + +```text +testRuntimeClasspath - Runtime classpath of source set 'test'. +\--- junit:junit:4.12 FAILED ``` 加上 plugins 和 repositories 后,`gradle -q dependencies --configuration testRuntimeClasspath` 的输出: ```text testRuntimeClasspath - Runtime classpath of source set 'test'. -\--- junit:junit:4.10 - \--- org.hamcrest:hamcrest-core:1.1 +\--- junit:junit:4.12 + \--- org.hamcrest:hamcrest-core:1.3 ``` ## 参考资料