Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with gradle-build-action v2.11.0 and Gradle 1.12: unable to resolve class PluginManager #1007

Closed
remkop opened this issue Dec 19, 2023 · 5 comments
Milestone

Comments

@remkop
Copy link

remkop commented Dec 19, 2023

Summary

Error with gradle-build-action 2.11.0 and Gradle 1.12:

gradle-build-action.inject-gradle-enterprise.init.gradle': 171: unable to resolve class PluginManager 

Description

My project picocli supports Java 5 and later.
(GitHub Actions only supports Java 6+, so my CI pipeline tests Java 6+)

After upgrading gradle-build-action from 2.8.0 to 2.11.0, I experience the following error:

initialization script '/home/runner/.gradle/init.d/gradle-build-action.inject-gradle-enterprise.init.gradle': 171: unable to resolve class PluginManager 

Not sure why this is happening. Does this need to be a fully qualified class org.gradle.api.plugins.PluginManager? This class was introduced in Gradle 2.3, so I would not expect this error with Gradle 1.12...

Attempted Workaround

I tried to configure as follows with property gradle-enterprise.injection-enabled=false but the error still occurs:

      - name: Build
        uses: gradle/gradle-build-action@8cbcb9948b5892387aed077daf6f90e1f0ba5b27 # v2
        with:
          gradle-version: 1.12
          build-root-directory: picocli-tests-java567/
          arguments: -Pgradle-enterprise.injection-enabled=false clean build --no-daemon

Log Details

Some more context:

2023-12-19T07:32:26.6624570Z ##[group]Run gradle/gradle-build-action@8cbcb9948b5892387aed077daf6f90e1f0ba5b27
2023-12-19T07:32:26.6625555Z with:
2023-12-19T07:32:26.6626023Z   gradle-version: 1.12
2023-12-19T07:32:26.6626764Z   build-root-directory: picocli-tests-java567/
2023-12-19T07:32:26.6627835Z   arguments: -Pgradle-enterprise.injection-enabled=false clean build --no-daemon
2023-12-19T07:32:26.6628817Z   cache-disabled: false
2023-12-19T07:32:26.6629444Z   cache-read-only: true
2023-12-19T07:32:26.6629989Z   cache-write-only: false
2023-12-19T07:32:26.6630572Z   cache-overwrite-existing: false
2023-12-19T07:32:26.6631428Z   gradle-home-cache-includes: caches
notifications

2023-12-19T07:32:26.6632219Z   gradle-home-cache-cleanup: false
2023-12-19T07:32:26.6632822Z   generate-job-summary: true
2023-12-19T07:32:26.6633525Z   dependency-graph: disabled
2023-12-19T07:32:26.6634159Z   gradle-home-cache-strict-match: false
2023-12-19T07:32:26.6635280Z   workflow-job-context: {
  "java-version": 6,
  "os": "ubuntu-latest"
}
2023-12-19T07:32:26.6636365Z   github-token: ***
2023-12-19T07:32:26.6636879Z env:
2023-12-19T07:32:26.6637592Z   JAVA_HOME: /opt/hostedtoolcache/Java_Zulu_jdk/6.0.119-119/x64
2023-12-19T07:32:26.6638596Z   JAVA_HOME_6_X64: /opt/hostedtoolcache/Java_Zulu_jdk/6.0.119-119/x64
2023-12-19T07:32:26.6639535Z ##[endgroup]
2023-12-19T07:32:26.9980501Z Could not determine user.home from java -version output. Using os.homedir().
2023-12-19T07:32:27.0004442Z Gradle User Home already exists: will not restore from cache.
2023-12-19T07:32:27.0755158Z ##[group]Provision Gradle 1.12
2023-12-19T07:32:27.5229566Z Cache Size: ~40 MB (42059296 B)
2023-12-19T07:32:27.5261575Z [command]/usr/bin/tar -xf /home/runner/work/_temp/88b8f54e-faf3-4501-91ab-6136542cebfd/cache.tzst -P -C /home/runner/work/picocli/picocli --use-compress-program unzstd
2023-12-19T07:32:27.6466311Z Cache restored successfully
2023-12-19T07:32:27.6556752Z Restored Gradle distribution gradle-1.12 from cache to /home/runner/gradle-installations/downloads/gradle-1.12-bin.zip
2023-12-19T07:32:27.6574841Z [command]/usr/bin/unzip -o -q /home/runner/gradle-installations/downloads/gradle-1.12-bin.zip
2023-12-19T07:32:28.0045519Z Extracted Gradle 1.12 to /home/runner/gradle-installations/installs/gradle-1.12
2023-12-19T07:32:28.0049518Z Provisioned Gradle executable /home/runner/gradle-installations/installs/gradle-1.12/bin/gradle
2023-12-19T07:32:28.0051439Z ##[endgroup]
2023-12-19T07:32:28.0062708Z [command]/home/runner/gradle-installations/installs/gradle-1.12/bin/gradle -Pgradle-enterprise.injection-enabled=false clean build --no-daemon
2023-12-19T07:32:28.1910431Z Received 42059296 of 42059296 (100.0%), 40.1 MBs/sec
2023-12-19T07:32:31.1277043Z 
2023-12-19T07:32:31.1278198Z FAILURE: Build failed with an exception.
2023-12-19T07:32:31.1278926Z 
2023-12-19T07:32:31.1279241Z * Where:
2023-12-19T07:32:31.1281516Z Initialization script '/home/runner/.gradle/init.d/gradle-build-action.inject-gradle-enterprise.init.gradle' line: 171
2023-12-19T07:32:31.1282863Z 
2023-12-19T07:32:31.1285890Z * What went wrong:
2023-12-19T07:32:31.1287977Z Could not compile initialization script '/home/runner/.gradle/init.d/gradle-build-action.inject-gradle-enterprise.init.gradle'.
2023-12-19T07:32:31.1289803Z > startup failed:
2023-12-19T07:32:31.1291976Z   initialization script '/home/runner/.gradle/init.d/gradle-build-action.inject-gradle-enterprise.init.gradle': 171: unable to resolve class PluginManager 
2023-12-19T07:32:31.1293899Z    @ line 171, column 28.
2023-12-19T07:32:31.1295192Z      void applyPluginExternally(PluginManager pluginManager, String pluginClassName) {
2023-12-19T07:32:31.1296774Z                                 ^
2023-12-19T07:32:31.1297575Z   
2023-12-19T07:32:31.1298242Z   1 error
@remkop remkop changed the title Error with gradle-version: 1.12: unable to resolve class PluginManager Error with gradle-build-action v2.11.0 and Gradle 1.12: unable to resolve class PluginManager Dec 19, 2023
@bigdaz
Copy link
Member

bigdaz commented Dec 19, 2023

Thanks for the report. I'm quite amazed that gradle-build-action@v2.11 is working correctly with Gradle v1.12! I limit my testing to Gradle 3.x and higher.

Due to the magic of dynamic Groovy, I think simply changing:

void applyPluginExternally(PluginManager pluginManager, String pluginClassName)

to

void applyPluginExternally(def pluginManager, String pluginClassName)

might be enough to avoid failure on Gradle 1.12. The init script should then load correctly, and the code won't be executed unless you are explicitly enabling Gradle Enterprise injection (which I presume you're not).

@bigdaz
Copy link
Member

bigdaz commented Dec 19, 2023

@remkop I've pushed a simple attempt at a fix and it would be great if you could verify that it works.
You can test it out by running with gradle/gradle-build-action@prerelease/v2.11.1. TIA.

remkop added a commit to remkop/picocli that referenced this issue Dec 20, 2023
@remkop
Copy link
Author

remkop commented Dec 20, 2023

@bigdaz That works, thank you!

remkop added a commit to remkop/picocli that referenced this issue Dec 20, 2023
@bigdaz bigdaz added this to the 2.11.1 milestone Dec 20, 2023
@bigdaz
Copy link
Member

bigdaz commented Dec 20, 2023

The fix has been released in v2.11.1. Thanks for the report.

@bigdaz bigdaz closed this as completed Dec 20, 2023
@remkop
Copy link
Author

remkop commented Dec 20, 2023

Amazingly fast turnaround! Many thanks!

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

No branches or pull requests

2 participants