Skip to content

Conversation

@hpuac
Copy link
Contributor

@hpuac hpuac commented Jan 9, 2026

Description

Address issue #4469 where the _jibSkaffoldFilesV2 task fails on Gradle 9.0+ due to the removal of the ProjectDependency.getDependencyProject() API.

Changes

  • Version-Aware Project Resolution: Introduced getDependentProject() to handle project dependency resolution across versions. It uses the original API for Gradle < 9.0 and falls back to path-based resolution via reflection for Gradle 9.0+.
  • Refactored Version Checks: Centralized version logic into a descriptive isBeforeGradle9() helper method for better readability.
  • Documentation: Added Javadoc to explain the compatibility strategy and potential exceptions.
  • Verification Test: Added a new test case in FilesTaskV2Test.java that explicitly runs against Gradle 9.0 using TestKit to verify the fix.

Testing Verified

  • Passed testFilesTask_multiProjectComplexService_gradle9 on Java 17.
  • Verified backward compatibility with Gradle 5.1 on Java 11.

Fixes #4469


Note

Local verification of all tests requires switching between Java 11 (for legacy Gradle) and Java 17 (for Gradle 9.0). CI should handle this matrix automatically.

hpuac added 3 commits January 9, 2026 19:51
Address the removal of ProjectDependency.getDependencyProject() in Gradle 9
by introducing a version-aware resolution strategy.

Fixes GoogleContainerTools#4469
Add a new test case testFilesTask_multiProjectComplexService_gradle9 to
FilesTaskV2Test that explicitly runs against Gradle 9.0 using Gradle
TestKit. This ensures that the reflection-based project resolution
logic introduced for Gradle 9+ compatibility is verified.

Verifies GoogleContainerTools#4469
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @hpuac, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves a critical compatibility issue with Gradle 9.0+ where the _jibSkaffoldFilesV2 task was failing due to an API removal. The changes ensure that the Jib Gradle plugin can correctly identify and process project dependencies across different Gradle versions, maintaining backward compatibility while adapting to newer Gradle releases. The primary impact is enhanced stability and future-proofing of the plugin for users migrating to Gradle 9 and beyond.

Highlights

  • Gradle 9 Compatibility: Introduced a version-aware getDependentProject() method to resolve project dependencies, using the original API for Gradle < 9.0 and reflection-based path resolution for Gradle 9.0+ to address the removal of ProjectDependency.getDependencyProject().
  • Code Readability and Maintainability: Centralized Gradle version checks into a new isBeforeGradle9() helper method for improved clarity and easier future updates.
  • Documentation: Added Javadoc to explain the compatibility strategy and potential exceptions for the new getDependentProject() method.
  • Verification Test: A new test case, testFilesTask_multiProjectComplexService_gradle9, was added to FilesTaskV2Test.java to explicitly verify the fix against Gradle 9.0 using TestKit.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request effectively addresses the compatibility issue with Gradle 9.0 by introducing a version-aware mechanism for project dependency resolution using reflection. The changes are well-structured, with helper methods like getDependentProject() and isBeforeGradle9() improving code readability and maintainability. The inclusion of a new test case specifically for Gradle 9.0 is a great addition that ensures the fix is properly verified. I have one suggestion to make the exception handling more precise.

String path =
(String) projectDependency.getClass().getMethod("getPath").invoke(projectDependency);
return getProject().project(path);
} catch (Exception ex) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Catching the generic Exception is a bit too broad and can hide other potential runtime issues. It's better to catch the more specific ReflectiveOperationException, which is the superclass for exceptions thrown by reflective operations. This makes the error handling more robust and specific to the reflection calls being made.

Suggested change
} catch (Exception ex) {
} catch (ReflectiveOperationException ex) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I applied your suggestion. Please verify that is solved and resolve this conversation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, apparently gemini code assist does not react to conversations the same way coderabbit does 😁

@hpuac hpuac marked this pull request as ready for review January 12, 2026 10:36
@dtwwolinski
Copy link

@hpuac Thanks for the fix. Do you know who we should ping to move the review forward?

@hpuac
Copy link
Contributor Author

hpuac commented Jan 20, 2026

@hpuac Thanks for the fix. Do you know who we should ping to move the review forward?

I'm also just an individual user blocked by the Gradle 9 incompatibility in JIB. I was hoping this to appear on some maintainers radar and be picked up 😅

@diegomarquezp
Copy link
Contributor

diegomarquezp commented Jan 22, 2026

Hi @hpuac, thanks for your contribution.

Units on Java 8 and 11 are failing because gradle 9 requires Java 17+ (see workflow file).

Is there a way to test this piece without using Gradle 9 runtime?

com.google.cloud.tools.jib.gradle.skaffold.FilesTaskV2Test > testFilesTask_multiProjectComplexService_gradle9 FAILED
    java.lang.IllegalStateException: An error occurred executing build with args ':complex-service:_jibSkaffoldFilesV2 -q -D_TARGET_IMAGE=ignored' in directory '/tmp/junit6976635944475712182/junit6027384212435506239'
        at org.gradle.testkit.runner.internal.ToolingApiGradleExecutor.run(ToolingApiGradleExecutor.java:162)
        at org.gradle.testkit.runner.internal.DefaultGradleRunner.run(DefaultGradleRunner.java:310)
        at org.gradle.testkit.runner.internal.DefaultGradleRunner.build(DefaultGradleRunner.java:251)
        at com.google.cloud.tools.jib.gradle.TestProject.build(TestProject.java:93)
        at com.google.cloud.tools.jib.gradle.skaffold.FilesTaskV2Test.verifyTaskSuccess(FilesTaskV2Test.java:67)
        at com.google.cloud.tools.jib.gradle.skaffold.FilesTaskV2Test.testFilesTask_multiProjectComplexService_gradle9(FilesTaskV2Test.java:202)

        Caused by:
        org.gradle.tooling.GradleConnectionException: Could not execute build using connection to Gradle distribution 'https://services.gradle.org/distributions/gradle-9.0-bin.zip'.
            at org.gradle.tooling.internal.consumer.ExceptionTransformer.transform(ExceptionTransformer.java:55)
            at org.gradle.tooling.internal.consumer.ExceptionTransformer.transform(ExceptionTransformer.java:29)
            at org.gradle.tooling.internal.consumer.ResultHandlerAdapter.onFailure(ResultHandlerAdapter.java:43)
            at org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsumerActionExecutor.java:69)
            at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
            at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
            at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
            at java.lang.Thread.run(Thread.java:750)
            at org.gradle.tooling.internal.consumer.BlockingResultHandler.getResult(BlockingResultHandler.java:46)
            at org.gradle.tooling.internal.consumer.DefaultBuildLauncher.run(DefaultBuildLauncher.java:83)
            at org.gradle.testkit.runner.internal.ToolingApiGradleExecutor.run(ToolingApiGradleExecutor.java:138)
            ... 5 more

            Caused by:
            org.gradle.internal.jvm.UnsupportedJavaRuntimeException: Gradle requires JVM 17 or later to run. Your build is currently configured to use JVM 8.

@hpuac
Copy link
Contributor Author

hpuac commented Jan 23, 2026

Hi @hpuac, thanks for your contribution.

Units on Java 8 and 11 are failing because gradle 9 requires Java 17+ (see workflow file).

Is there a way to test this piece without using Gradle 9 runtime?

@diegomarquezp I see two potential ways:

  1. The first thing that comes to my mind is that I could check since what Gradle version this new getPath method exists and adjust the code to already utilize that method from that Gradle version on where it was introduced. Hoping that that version does not require Java 17+.
  2. Alternatively the tests could simply be disabled. But that of course comes with some risk upon further code changes.

What do you think makes sense? Is there maybe a third alternative?

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.

Jib dependency refresh fails in gradle 9 multi module project when including dependency on other module

3 participants