Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle - dependencies with because statement

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 ?

like image 408
user7294900 Avatar asked Oct 20 '25 23:10

user7294900


1 Answers

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 
like image 135
Larusso Avatar answered Oct 22 '25 13:10

Larusso



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!