mirror of
https://github.com/CyC2018/Interview-Notebook.git
synced 2026-11-19 12:43:46 +00:00
Update 构建工具.md
示例依赖改为 junit 4.12,补充只加 plugins、不写 repositories 时的报错。
This commit is contained in:
+12
-5
@@ -41,7 +41,7 @@ Gradle 和 Maven 的区别是,Gradle 的构建脚本用基于 Groovy 或 Kotli
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.10</version>
|
||||
<version>4.12</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
@@ -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
|
||||
```
|
||||
|
||||
## 参考资料
|
||||
|
||||
Reference in New Issue
Block a user