Jonathing
04/29/2025, 6:14 PMgradle-plugin-development plugin, to only use the Gradle API it offers? Here's a screenshot of my dependencies. IntelliJ is still including my Gradle wrapper's API files in the compile classpath.
I should mention that I'm also applying dev.gradleplugins.groovy-gradle-plugin to the project's plugins.Vampire
04/29/2025, 7:24 PMgradleApi() to your dependencies for your, yesJonathing
04/29/2025, 7:27 PMcom.gradle.plugin-publish if I don't use java-gradle-plugin?Vampire
04/29/2025, 7:28 PMJonathing
04/30/2025, 1:12 AMcom.gradle.plugin-publish also adds the default gradleApi() dependency to the compile classpath. Removing that plugin (even on its own without java-gradle-plugin allows me to use the Nokee republish.
On further inspection I believe this is because com.gradle.plugin-publish is applying the java-gradle-plugin.
It's a little cursed, but right now I'm conditionally applying the plugins by doing this:
plugins {
id 'dev.gradleplugins.groovy-gradle-plugin' apply false
id 'java'
id 'groovy'
alias libs.plugins.plugin.publish apply false
}
// NOTE: Applying the Plugin Publish plugin causes local Gradle dependencies to be used
final inCI = providers.environmentVariable('CI').<boolean>map({ 'true'.equalsIgnoreCase it }).getOrElse(false)
//final inCI = true
apply {
if (!inCI) return
plugin 'dev.gradleplugins.groovy-gradle-plugin'
plugin libs.plugins.plugin.publish.get().pluginId
}
dependencies {
// Gradle API
if (!inCI) {
compileOnly gradleApi(libs.versions.gradle.get())
compileOnly libs.groovy
}
}
And to configure the gradlePlugins {} extension, I am using extensions.findByType(GradlePluginDevelopmentExtension)?.tap {} so I can keep my IDE linting 😛Vampire
04/30/2025, 9:04 AMextensions.findByType(GradlePluginDevelopmentExtension)?.tap {} surely is able nicer. 😄
I recommend you switch to Kotlin DSL. By now it is the default DSL, you immediately get type-safe build scripts, actually helpful error messages if you mess up the syntax, and amazingly better IDE support if you use a good IDE like IntelliJ IDEA or Android Studio.
And the above line could be configure<GradlePluginDevelopmentExtension> { } 🙂Vampire
04/30/2025, 9:05 AMorg.gradle.unsafe.suppress-gradle-api to prevent gradleApi() being added for youJonathing
04/30/2025, 11:58 AMJonathing
04/30/2025, 11:58 AMVampire
04/30/2025, 12:01 PMJonathing
05/01/2025, 4:31 PMorg.gradle.unsafe.suppress-gradle-api property. I tacked the debugger on JavaGradlePluginPlugin#applyDependencies and the property is making it skip adding the Gradle API to the api configuration as intended, but it's still being added in the final dependencies somehow. This even just with only the java-gradle-plugin. I scavenged the sources of Gradle 8.14 and found nothing else that might point to it being added.
I'm adding it like this:
systemProp.org.gradle.unsafe.suppress-gradle-api=true
org.gradle.unsafe.suppress-gradle-api=trueJonathing
05/01/2025, 4:42 PMgradle init and am getting the same problem there with a default setup.Jonathing
05/01/2025, 4:44 PM--- ./deps_no_prop.txt 2025-05-01 12:46:20.702822445 -0400
+++ ./deps_with_prop.txt 2025-05-01 12:46:28.501797627 -0400
@@ -10,7 +10,7 @@
No dependencies
api - API dependencies for the 'main' feature. (n)
-\--- unspecified (n)
+No dependencies
apiElements - API elements for the 'main' feature. (n)
No dependencies
@@ -140,6 +140,6 @@
A web-based, searchable dependency report is available by adding the --scan option.
-BUILD SUCCESSFUL in 409ms
+BUILD SUCCESSFUL in 428ms
1 actionable task: 1 executed
Configuration cache entry stored.Jonathing
05/02/2025, 5:02 PMJonathing
05/02/2025, 11:22 PMgradle-api-8.14.jar was present as an external library. The gradle init project uses it as a dependency for the test and functionalTest suites. Setting the system property does make it disappear from the compile classpath and I get errors in the test class.
So it looks like there's some other issue with the setup I've made for the project I was working on. But thank you for your help so far!Jonathing
05/02/2025, 11:41 PMcom.gradle.plugin-publish is doing the same thing.
PublishTaskShadowAction#manipulateDependencies
private void manipulateDependencies(ConfigurationContainer configurations) {
Dependency gradleApi = project.getDependencies().gradleApi();
Configuration api = configurations.findByName("api");
if (api != null) {
api.getDependencies().remove(gradleApi);
}
Configuration compileOnly = configurations.findByName("compileOnly");
if (compileOnly != null) {
compileOnly.getDependencies().add(gradleApi);
}
}
I'd appreciate it if someone at Gradle could address that internally, since it's a private plugin and all. If I could make a PR, I would! 😛Vampire
05/03/2025, 12:43 AMVampire
05/03/2025, 12:43 AMJonathing
05/03/2025, 12:43 AMJonathing
05/03/2025, 12:43 AMVampire
05/03/2025, 12:44 AMJonathing
05/03/2025, 12:45 AMJonathing
05/03/2025, 12:45 AMcompileOnly.dependencies.remove(dependencies.gradleApi() to get byJonathing
05/03/2025, 2:02 AM