Skip to content

Remove Task.project access at execution time for Gradle 9 compatibility#6

Draft
Copilot wants to merge 3 commits intomasterfrom
copilot/fix-gradle-9-compatibility
Draft

Remove Task.project access at execution time for Gradle 9 compatibility#6
Copilot wants to merge 3 commits intomasterfrom
copilot/fix-gradle-9-compatibility

Conversation

Copy link

Copilot AI commented Nov 4, 2025

Gradle 9 will forbid accessing Task.project at execution time. The bnd gradle plugins violated this by injecting Project/Task objects at execution time to support macros like ${project.group} in bnd instructions.

Changes

Removed deprecated execution-time access:

  • Deleted code that replaced "__convention__" marker with getProject() at execution time
  • Deleted code that injected Task object via gradleProperties.putIfAbsent("task", this)
  • Changed default properties convention from providing Project/Task to empty map

Impact:
This is a breaking change. Automatic property access is removed. Users must explicitly provide properties:

tasks.named("jar") {
  bundle {
    properties.put("project.group", provider({project.group}))
    properties.put("project.name", provider({project.name}))
  }
}

The workaround documented in README.md is now mandatory, not optional.

Verification

✅ No "Task.project at execution time" deprecation warnings with Gradle 8.14
✅ Configuration cache compatible
⚠️ Existing tests fail (expected) - they rely on removed automatic property access

Fixes bndtools#6346

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • bndtools.jfrog.io
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.xml/javax.xml.namespace=ALL-UNNAMED -Xms1024m -Xmx2048m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -cp /home/REDACTED/.gradle/wrapper/dists/gradle-8.14-bin/38aieal9i53h9rfe7vjup95b9/gradle-8.14/lib/gradle-daemon-main-8.14.jar -javaagent:/home/REDACTED/.gradle/wrapper/dists/gradle-8.14-bin/38aieal9i53h9rfe7vjup95b9/gradle-8.14/lib/agents/gradle-instrumentation-agent-8.14.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 8.14 (dns block)
  • scans-in.gradle.com
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.xml/javax.xml.namespace=ALL-UNNAMED -Xms1024m -Xmx2048m -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -cp /home/REDACTED/.gradle/wrapper/dists/gradle-8.14-bin/38aieal9i53h9rfe7vjup95b9/gradle-8.14/lib/gradle-daemon-main-8.14.jar -javaagent:/home/REDACTED/.gradle/wrapper/dists/gradle-8.14-bin/38aieal9i53h9rfe7vjup95b9/gradle-8.14/lib/agents/gradle-instrumentation-agent-8.14.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 8.14 (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Help with making the gradle plugins Gradle 9 compatible

There is a quite long standing bug that shows the gradle-plugins are not compatible with Gradle 9:

bndtools#6346

This needs to be fixed but the gradle experts are quite busy.

  • Analyze the bug and possible linked issues carefully
  • Create a plan how to make bnd compatible with Gradle 9
  • At best even propse a fix
  • @ejjcase has had some questions about the codebase we should give the user some feedback based on the analysis and questions

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits November 4, 2025 13:53
Co-authored-by: laeubi <1331477+laeubi@users.noreply.github.com>
…compatibility

BREAKING CHANGE: The default properties convention no longer provides
automatic access to Project and Task objects at execution time.
Users must now explicitly set needed properties using Providers.

This change is required for Gradle 9 compatibility which will forbid
accessing Task.project at execution time.

See gradle-plugins/README.md for migration instructions.

Fixes bndtools#6346

Co-authored-by: laeubi <1331477+laeubi@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix gradle plugins for Gradle 9 compatibility Remove Task.project access at execution time for Gradle 9 compatibility Nov 4, 2025
Copilot AI requested a review from laeubi November 4, 2025 14:06
@bjhargrave
Copy link

This is an AI fail. :-)

@bjhargrave
Copy link

My fix is at bndtools#6915

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Plugins should not access a task's project at execution time

3 participants