Gradle - dependencies with because statement

user7294900 :

I'm new to gradle, I found in build.gradle.kts inside dependencies because clauses/statements

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

I didn't find in any Gradle dependencies documentation such because clause

Is it just a custom clause similar to adding java docs and could have been rename to any string as myreason("""my reason is other""")

Or is becasue statement used by Gradle ?

Larusso :

You can find it in the org.gradle.api.artifacts.Dependency internface

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 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=328877&siteId=1