gradle / gradle

Adaptable, fast automation for all
https://gradle.org
Apache License 2.0
16.8k stars 4.7k forks source link

duck-typing dependent example in JavaDoc of `ArtifactResolutionQuery` #19227

Open Vampire opened 2 years ago

Vampire commented 2 years ago

The example usage in the JavaDoc of ArtifactResolutionQuery (https://docs.gradle.org/7.3.1/javadoc/org/gradle/api/artifacts/query/ArtifactResolutionQuery.html) is a bit unlucky if you are not using Groovy, because it depends on Groovy duck-typing.

In a statically typed language like Java or Kotlin, it.selected and it.file will not work without a down-cast to ResolvedDependencyResult and ResolvedArtifactResult respectively.

Maybe there is some typed API missing to make this possible cleaner in statically typed languages, or at least there should be an example added in Java or Kotlin where you see to what you actually have to down-cast.

ljacomet commented 2 years ago

ArtifactResolutionQuery is on its way out, it is not variant aware and will be replaced by a proper solution. It is no longer part of the dependency management documentation for a while. As such, this will most likely never be fixed before it disappears for good.

Vampire commented 2 years ago

Ah, I see. Is there already some replacement to be used instead?

ljacomet commented 2 years ago

Unfortunately no, if there was, it would be actively deprecated