Intellij seems to know that Gradle API sources (e....
# community-support
a
Intellij seems to know that Gradle API sources (e.g. for
org.gradle.api.tasks.testing.Test
) are in
\.gradle\caches\8.13\transforms\be3b1a1bb33d55c586a2a5188fe96027\transformed\testing-jvm\org\gradle\api\tasks\testing\Test.java
(i.e. not in a sources-jar downloadable from a repository). How does it work this out? Is there a way to query the Gradle API for these source locations? Any
ArtifactResolutionQuery
I do doesn't seem to bring this back. I'd like to be able to work out the Gradle sources for my
buildSrc
projects which implicitly depend on
gradleApi()
and
localGroovy()
a
You can get the source JARs with an artifact view:
Copy code
// buildSrc/build.gradle.kts


val logSrcs by tasks.registering {
  val srcs = configurations.compileClasspath
    .get()
    .incoming
    .artifactView {
      attributes {
        attribute(DocsType.DOCS_TYPE_ATTRIBUTE, objects.named(DocsType.SOURCES))
      }
    }
    .files

  doLast {
    println(srcs.joinToString("\n"))
  }
}
a
I just get the usual jars printed out, not the sources...
Copy code
.gradle\caches\8.13\generated-gradle-jars\gradle-api-8.13.jar
.gradle\wrapper\dists\gradle-8.13-bin\5xuhj0ry160q40clulazy9h7d\gradle-8.13\lib\groovy-3.0.22.jar
.gradle\wrapper\dists\gradle-8.13-bin\5xuhj0ry160q40clulazy9h7d\gradle-8.13\lib\groovy-ant-3.0.22.jar
.gradle\wrapper\dists\gradle-8.13-bin\5xuhj0ry160q40clulazy9h7d\gradle-8.13\lib\groovy-astbuilder-3.0.22.jar
.gradle\wrapper\dists\gradle-8.13-bin\5xuhj0ry160q40clulazy9h7d\gradle-8.13\lib\groovy-console-3.0.22.jar
.gradle\wrapper\dists\gradle-8.13-bin\5xuhj0ry160q40clulazy9h7d\gradle-8.13\lib\groovy-datetime-3.0.22.jar
.gradle\wrapper\dists\gradle-8.13-bin\5xuhj0ry160q40clulazy9h7d\gradle-8.13\lib\groovy-dateutil-3.0.22.jar
.gradle\wrapper\dists\gradle-8.13-bin\5xuhj0ry160q40clulazy9h7d\gradle-8.13\lib\groovy-groovydoc-3.0.22.jar
.gradle\wrapper\dists\gradle-8.13-bin\5xuhj0ry160q40clulazy9h7d\gradle-8.13\lib\groovy-json-3.0.22.jar
.gradle\wrapper\dists\gradle-8.13-bin\5xuhj0ry160q40clulazy9h7d\gradle-8.13\lib\groovy-nio-3.0.22.jar
.gradle\wrapper\dists\gradle-8.13-bin\5xuhj0ry160q40clulazy9h7d\gradle-8.13\lib\groovy-sql-3.0.22.jar
.gradle\wrapper\dists\gradle-8.13-bin\5xuhj0ry160q40clulazy9h7d\gradle-8.13\lib\groovy-templates-3.0.22.jar
.gradle\wrapper\dists\gradle-8.13-bin\5xuhj0ry160q40clulazy9h7d\gradle-8.13\lib\groovy-test-3.0.22.jar
.gradle\wrapper\dists\gradle-8.13-bin\5xuhj0ry160q40clulazy9h7d\gradle-8.13\lib\groovy-xml-3.0.22.jar
.gradle\wrapper\dists\gradle-8.13-bin\5xuhj0ry160q40clulazy9h7d\gradle-8.13\lib\javaparser-core-3.17.0.jar
.gradle\wrapper\dists\gradle-8.13-bin\5xuhj0ry160q40clulazy9h7d\gradle-8.13\lib\kotlin-stdlib-2.0.21.jar
.gradle\wrapper\dists\gradle-8.13-bin\5xuhj0ry160q40clulazy9h7d\gradle-8.13\lib\kotlin-reflect-2.0.21.jar
.gradle\wrapper\dists\gradle-8.13-bin\5xuhj0ry160q40clulazy9h7d\gradle-8.13\lib\gradle-installation-beacon-8.13.jar
This is with a basic Gradle project using the
java-gradle-plugin
plugin
a
sorry you're right, I was confused because I saw some source jars, but they were from plugins
v
Iirc when the IDE uses the tooling API to query information about the project, Gradle tells it this.