I'm working on a custom Gradle plugin. For some reason IntelliJ is unable to find the sources of the gradle-api
artifact and only shows the decompiled.class file. I am already using the -all
distribution of the Gradle Wrapper (which includes some sources, but apparently not the ones I need right here). Clicking Download... results in an error:
Sources not found: Sources for 'gradle-api-6.5.1.jar' not found
How do I correctly attach/choose sources for gradle-api
in IntelliJ?
EDIT:
I have a minimal Gradle plugin with code like that (taken from the official samples ):
plugins {
id 'java-gradle-plugin'
}
repositories {
jcenter()
}
dependencies {
testImplementation 'junit:junit:4.13'
}
gradlePlugin {
// ...
}
According to this excellent manual you should add gradleApi()
as a runtimeOnly
dependency:
dependencies {
//...
runtimeOnly(gradleApi())
I guess that, the default Intellij config use gradle from gradle-wrapper.properties file
will use /gradle/wrapper/gradle-wrapper.jar
, but it doesn't contain source code. what you need is a jar like gradle-wrapper-all.jar
. But I don't know how to let Gradle redownload that. Just setting Wrapper.DistributionType.ALL
is not working.
Wrapper.DistributionType.ALL
wrapper {
jarFile = file(System.getProperty("user.dir") + '/gradle/wrapper/gradle-wrapper.jar')
gradleVersion = '6.7.1'
distributionType = Wrapper.DistributionType.ALL
}
Here is the source code, the version is right and with all
in the name ( gradle-6.7.1-all
):
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.