Gradle-具有因为语句的依赖

时间:2019-09-16 04:49:54

标签: java gradle dependency-management

我是新手,我在build.gradle.kts中发现依赖项because clauses/statements

dependencies { 
  implementation("commons-io:commons-io") {
      because("IOUtils")
  }
  implementation("org.apache.commons:commons-text") {
      because("StringEscapeUtils")
  }

我在任何Gradle dependencies documentation中都找不到这样的原因,因为条款

这仅仅是一个类似于添加Java文档的自定义子句,并且可以重命名为任何字符串为myreason("""my reason is other""")

或者becasue语句是Gradle使用的吗?

1 个答案:

答案 0 :(得分:3)

您可以在org.gradle.api.artifacts.Dependency界面上找到它

https://docs.gradle.org/current/javadoc/org/gradle/api/artifacts/Dependency.html#because-java.lang.String-

@Incubating
@Nullable
String getReason()

Returns a reason why this dependency should be used, in particular with regards to its version. The dependency report will use it to explain why a specific dependency was selected, or why a specific dependency version was used.

Returns:
   a reason to use this dependency
Since:
   4.6


@Incubating
void because​(@Nullable
             String reason)

Sets the reason why this dependency should be used.

Since:
    4.6