Skip to content

Test 1 test#4481

Closed
ldetmer wants to merge 20 commits into
masterfrom
test-1-test
Closed

Test 1 test#4481
ldetmer wants to merge 20 commits into
masterfrom
test-1-test

Conversation

@ldetmer
Copy link
Copy Markdown
Contributor

@ldetmer ldetmer commented Feb 3, 2026

Thank you for your interest in contributing! For general guidelines, please refer to
the contributing guide.

Please follow the guidelines below before opening an issue or a PR:

  • Ensure the issue was not already reported.
  • Create a new issue at https://github.com/GoogleContainerTools/jib/issues/new/choose if you are unable to find an existing issue addressing your problem. Make sure to include a title and clear description, as much relevant information as possible, and a code sample or an executable test case demonstrating the expected behavior that is not occurring.
  • Discuss the priority and potential solutions with the maintainers in the issue. The maintainers would review the issue and add a label "Accepting Contributions" once the issue is ready for accepting contributions.
  • Open a PR only if the issue is labeled with "Accepting Contributions", ensure the PR description clearly describes the problem and solution. Note that an open PR without an issues labeled with "Accepting Contributions" will not be accepted.
  • Verify that integration tests and unit tests are passing after the change.
  • Address all checkstyle issues. Refer to the style guide.

Fixes #<issue_number_goes_here> 🛠️

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @ldetmer, 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 significantly improves the project's compatibility with a wider range of Gradle versions, specifically targeting support for Gradle 9.0 and above while maintaining functionality with older versions. It addresses various API changes and deprecations in the Gradle ecosystem by introducing conditional configurations, modernizing build script syntax, and implementing robust dependency resolution mechanisms within the Jib Gradle plugin. These changes ensure the build system remains stable and adaptable to future Gradle updates.

Highlights

  • Gradle Version Compatibility: Implemented conditional logic for Gradle plugin versions and configurations, ensuring compatibility with both older Gradle versions (e.g., 6.x) and newer versions (9.0+). This includes dynamic loading of gradle-release and plugin-publish-plugin.
  • Modern Gradle API Usage: Refactored build scripts to adopt modern Gradle API practices, such as wrapping sourceCompatibility and targetCompatibility within a java { ... } block and updating integration test dependency configurations to use runtimeOnly.
  • Robust Project Dependency Resolution: Enhanced the Jib Gradle plugin's ability to resolve project dependencies across different Gradle versions by introducing a reflection-based utility method (getDependentProject) to handle API changes in Gradle 9+.
  • Improved Null Safety and Error Handling: Added null checks for resource output directories and Jar tasks within the Jib Gradle plugin to prevent potential NullPointerExceptions and improve overall stability.
  • Conditional Guava Workaround: The workaround for Guava update breaking unit tests is now conditionally applied only for Gradle versions prior to 7.0, as newer Gradle versions handle this automatically.

🧠 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.

Changelog
  • build.gradle
    • Implemented conditional loading of gradle-release and plugin-publish-plugin based on Gradle version (9.0+ vs. older).
    • Wrapped sourceCompatibility and targetCompatibility in a java { ... } block.
    • Made the Guava workaround for unit tests conditional, applying it only for Gradle versions less than 7.0.
    • Standardized test report output location to "${project.buildDir}/reports/${name}".
    • Updated integration test configuration to use integrationTestRuntimeOnly.extendsFrom testRuntimeOnly.
    • Modified project dependency removal logic to handle dependencyProject (Gradle 6.9.2) and path (Gradle 9+) properties.
  • jib-gradle-plugin/build.gradle
    • Added import org.gradle.util.GradleVersion.
    • Updated release tag template to v$version-gradle-plugin.
    • Made pluginBundle configuration conditional for Gradle versions less than 9.0, and moved website, vcsUrl, and tags directly into gradlePlugin.plugins.jibPlugin for Gradle 9.0+.
  • jib-gradle-plugin/src/main/java/com/google/cloud/tools/jib/gradle/GradleProjectProperties.java
    • Added null checks for resourcesOutputDirectory and jarTask to prevent NullPointerExceptions.
    • Refactored resourcesOutputDirectory retrieval to handle cases where getResourcesDir() might return null.
  • jib-gradle-plugin/src/main/java/com/google/cloud/tools/jib/gradle/skaffold/FilesTaskV2.java
    • Introduced getDependentProject utility method using reflection to resolve ProjectDependency for Gradle 6 and 9+ compatibility.
    • Updated listFiles and findProjectDependencies to use the new getDependentProject method.
    • Modified settings.gradle resolution to use reflection for getSettingsFile() to support different Gradle versions.
  • jib-gradle-plugin/src/test/java/com/google/cloud/tools/jib/gradle/skaffold/FilesTaskV2Test.java
    • Added imports for GradleVersion and Assume.
  • jib-gradle-plugin/src/test/resources/gradle/projects/multi-service/build.gradle
    • Updated sourceCompatibility and targetCompatibility to use the java { ... } block.
  • jib-gradle-plugin/src/test/resources/gradle/projects/multi-service/complex-service/build.gradle
    • Updated sourceCompatibility and targetCompatibility to use the java { ... } block.
  • jib-gradle-plugin/src/test/resources/gradle/projects/multi-service/lib/build.gradle
    • Updated sourceCompatibility and targetCompatibility to use the java { ... } block.
  • jib-gradle-plugin/src/test/resources/gradle/projects/multi-service/simple-service/build.gradle
    • Updated sourceCompatibility and targetCompatibility to use the java { ... } block.
Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/unit-tests.yml
Activity
  • No specific activity (comments, reviews, etc.) has been recorded for this pull request yet.
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
Copy Markdown
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 updates the Gradle build configuration to ensure compatibility with Gradle 9, while maintaining support for older versions. The changes primarily involve conditional logic for plugin versions and API usage based on the Gradle version. Key changes include updating plugin configurations in build.gradle and jib-gradle-plugin/build.gradle, and using reflection in FilesTaskV2.java to handle deprecated/removed APIs in Gradle 9. The changes are well-implemented, but I have one suggestion to improve code clarity and reduce duplication in FilesTaskV2.java.

Comment on lines +147 to 162
try {
Object startParameter = project.getGradle().getStartParameter();
java.lang.reflect.Method getSettingsFileMethod =
startParameter.getClass().getMethod("getSettingsFile");
File settingsFile = (File) getSettingsFileMethod.invoke(startParameter);
if (settingsFile != null) {
skaffoldFilesOutput.addBuild(settingsFile.toPath());
} else if (Files.exists(projectPath.resolve(Settings.DEFAULT_SETTINGS_FILE))) {
skaffoldFilesOutput.addBuild(projectPath.resolve(Settings.DEFAULT_SETTINGS_FILE));
}
} catch (ReflectiveOperationException e) {
// Fall back to default settings file location if reflection fails
if (Files.exists(projectPath.resolve(Settings.DEFAULT_SETTINGS_FILE))) {
skaffoldFilesOutput.addBuild(projectPath.resolve(Settings.DEFAULT_SETTINGS_FILE));
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

This block has some duplicated logic for handling the fallback to the default settings.gradle file. It can be refactored to be more concise and avoid repetition, which improves maintainability.

    File settingsFile = null;
    try {
      Object startParameter = project.getGradle().getStartParameter();
      java.lang.reflect.Method getSettingsFileMethod =
          startParameter.getClass().getMethod("getSettingsFile");
      settingsFile = (File) getSettingsFileMethod.invoke(startParameter);
    } catch (ReflectiveOperationException e) {
      // Method doesn't exist on Gradle 9+, or other reflection issue.
      // Fall back to checking default location.
    }

    if (settingsFile != null) {
      skaffoldFilesOutput.addBuild(settingsFile.toPath());
    } else {
      Path defaultSettingsFile = projectPath.resolve(Settings.DEFAULT_SETTINGS_FILE);
      if (Files.exists(defaultSettingsFile)) {
        skaffoldFilesOutput.addBuild(defaultSettingsFile);
      }
    }

@ldetmer ldetmer closed this Feb 5, 2026
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.

1 participant