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

Upgrade to gradle 8.6 #3056

Closed
wants to merge 4 commits into from
Closed

Upgrade to gradle 8.6 #3056

wants to merge 4 commits into from

Conversation

juherr
Copy link
Member

@juherr juherr commented Feb 5, 2024

Fixes #3054.

Still some gradle warnings:

./gradlew help --warning-mode=all
Type-safe project accessors is an incubating feature.

> Configure project :
The Project.getConvention() method has been deprecated. This is scheduled to be removed in Gradle 9.0. Consult the upgrading guide for further information: https://docs.gradle.org/8.6/userguide/upgrading_version_8.html#deprecated_access_to_conventions
Building testng 7.10.0-SNAPSHOT

> Task :build-logic:publishing:compileKotlin
w: file:///Users/juherr/Projects/Perso/testng/build-logic/publishing/src/main/kotlin/buildlogic/OptionalFeaturesExtension.kt:44:79 'getter for isCurrentBuild: Boolean' is deprecated. Deprecated in Java

> Configure project :testng
The 'ant' feature was created using the main source set. This behavior has been deprecated. This will fail with an error in Gradle 9.0. The main source set is reserved for production code and should not be used for features. Use another source set instead. Consult the upgrading guide for further information: https://docs.gradle.org/8.6/userguide/upgrading_version_8.html#deprecate_register_feature_main_source_set
        at Testng_build_gradle$1$1.execute(testng-build.gradle.kts:17)
        (Run with --stacktrace to get the full stack trace of this deprecation warning.)
        at Testng_build_gradle$1.execute(testng-build.gradle.kts:8)
        (Run with --stacktrace to get the full stack trace of this deprecation warning.)
The 'guice' feature was created using the main source set. This behavior has been deprecated. This will fail with an error in Gradle 9.0. The main source set is reserved for production code and should not be used for features. Use another source set instead. Consult the upgrading guide for further information: https://docs.gradle.org/8.6/userguide/upgrading_version_8.html#deprecate_register_feature_main_source_set
        at Testng_build_gradle$1$1.execute(testng-build.gradle.kts:20)
        (Run with --stacktrace to get the full stack trace of this deprecation warning.)
        at Testng_build_gradle$1.execute(testng-build.gradle.kts:8)
        (Run with --stacktrace to get the full stack trace of this deprecation warning.)
The 'yaml' feature was created using the main source set. This behavior has been deprecated. This will fail with an error in Gradle 9.0. The main source set is reserved for production code and should not be used for features. Use another source set instead. Consult the upgrading guide for further information: https://docs.gradle.org/8.6/userguide/upgrading_version_8.html#deprecate_register_feature_main_source_set
        at Testng_build_gradle$1$1.execute(testng-build.gradle.kts:24)
        (Run with --stacktrace to get the full stack trace of this deprecation warning.)
        at Testng_build_gradle$1.execute(testng-build.gradle.kts:8)
        (Run with --stacktrace to get the full stack trace of this deprecation warning.)

> Configure project :testng-core
The org.gradle.util.WrapUtil type has been deprecated. This is scheduled to be removed in Gradle 9.0. Consult the upgrading guide for further information: https://docs.gradle.org/8.6/userguide/upgrading_version_7.html#org_gradle_util_reports_deprecations
        at Testng_kotlin_library_gradle$1.invoke(testng.kotlin-library.gradle.kts:5)
        (Run with --stacktrace to get the full stack trace of this deprecation warning.)
The org.gradle.api.plugins.Convention type has been deprecated. This is scheduled to be removed in Gradle 9.0. Consult the upgrading guide for further information: https://docs.gradle.org/8.6/userguide/upgrading_version_8.html#deprecated_access_to_conventions
        at Testng_kotlin_library_gradle$1.invoke(testng.kotlin-library.gradle.kts:5)
        (Run with --stacktrace to get the full stack trace of this deprecation warning.)
The org.gradle.api.plugins.JavaPluginConvention type has been deprecated. This is scheduled to be removed in Gradle 9.0. Consult the upgrading guide for further information: https://docs.gradle.org/8.6/userguide/upgrading_version_8.html#java_convention_deprecation
        at Testng_kotlin_library_gradle$1.invoke(testng.kotlin-library.gradle.kts:5)
        (Run with --stacktrace to get the full stack trace of this deprecation warning.)
The 'guice' feature was created using the main source set. This behavior has been deprecated. This will fail with an error in Gradle 9.0. The main source set is reserved for production code and should not be used for features. Use another source set instead. Consult the upgrading guide for further information: https://docs.gradle.org/8.6/userguide/upgrading_version_8.html#deprecate_register_feature_main_source_set
        at Testng_core_build_gradle$1.execute(testng-core-build.gradle.kts:12)
        (Run with --stacktrace to get the full stack trace of this deprecation warning.)
The 'yaml' feature was created using the main source set. This behavior has been deprecated. This will fail with an error in Gradle 9.0. The main source set is reserved for production code and should not be used for features. Use another source set instead. Consult the upgrading guide for further information: https://docs.gradle.org/8.6/userguide/upgrading_version_8.html#deprecate_register_feature_main_source_set
        at Testng_core_build_gradle$1.execute(testng-core-build.gradle.kts:16)
        (Run with --stacktrace to get the full stack trace of this deprecation warning.)

> Configure project :testng-core-api
The 'guice' feature was created using the main source set. This behavior has been deprecated. This will fail with an error in Gradle 9.0. The main source set is reserved for production code and should not be used for features. Use another source set instead. Consult the upgrading guide for further information: https://docs.gradle.org/8.6/userguide/upgrading_version_8.html#deprecate_register_feature_main_source_set
        at Testng_core_api_build_gradle$1.execute(testng-core-api-build.gradle.kts:6)
        (Run with --stacktrace to get the full stack trace of this deprecation warning.)

Summary by CodeRabbit

  • Refactor
    • Improved dynamic setting of JVM targets for enhanced compatibility and performance.
    • Enhanced script compliance and handling for better cross-environment support.
    • Improved Gradle distribution configuration for enhanced performance and reliability.
  • Chores
    • Adjusted project settings and dependencies for better integration with external tools and plugins.
  • Bug Fixes
    • Resolved potential null value handling in the OSGI build configuration.

@juherr juherr requested a review from krmahadevan as a code owner February 5, 2024 12:07
Copy link

coderabbitai bot commented Feb 5, 2024

Walkthrough

This update primarily focuses on upgrading the project to Gradle 8.x, enhancing build scripts for better compatibility with newer Java versions, and improving the code quality tools. The changes dynamically set JVM targets to align with the current Java version, update the Gradle wrapper, and refine scripts for better performance and compliance. Additionally, there's an adjustment in dependency management logic and plugin configurations to streamline the build process.

Changes

Files Change Summary
build-logic/.../build.gradle.kts (multiple) Updated autostyle-plugin-gradle to 4.0, dynamically set jvmTarget
gradle.properties Updated for SonarQube plugin version 4.x compatibility
gradle/wrapper/gradle-wrapper.properties Updated to Gradle distribution 8.5
gradlew, gradlew.bat Enhanced script compliance and environment handling
settings.gradle.kts Added foojay-resolver-convention plugin "0.5.0", adjusted feature previews
.../FirstLayerDependencies.kt Improved usageKind calculation
testng-test-osgi/.../build.gradle.kts Enhanced null value handling

Assessment against linked issues

Objective Addressed Explanation
Upgrade to gradle 8.x (#3054)

Poem

In the code's garden, under the moon's bright gleam,
The diligent rabbits toiled, fulfilling the dream.
With Gradle 8's magic and Java's keen flair,
They crafted a build, as light as the air. 🌟🐇💻

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

@juherr
Copy link
Member Author

juherr commented Feb 5, 2024

@vlsi Please, could you review?

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 4af6e94 and b8b71d1.
Files ignored due to path filters (1)
  • gradle/wrapper/gradle-wrapper.jar is excluded by: !**/*.jar
Files selected for processing (12)
  • build-logic/code-quality/build.gradle.kts (1 hunks)
  • build-logic/jvm/build.gradle.kts (1 hunks)
  • build-logic/jvm/src/main/kotlin/testng.java.gradle.kts (1 hunks)
  • build-logic/jvm/src/main/kotlin/testng.kotlin-library.gradle.kts (1 hunks)
  • build-logic/publishing/build.gradle.kts (1 hunks)
  • build-logic/publishing/src/main/kotlin/buildlogic/FirstLayerDependencies.kt (2 hunks)
  • gradle.properties (2 hunks)
  • gradle/wrapper/gradle-wrapper.properties (1 hunks)
  • gradlew (4 hunks)
  • gradlew.bat (4 hunks)
  • settings.gradle.kts (2 hunks)
  • testng-test-osgi/testng-test-osgi-build.gradle.kts (2 hunks)
Files skipped from review due to trivial changes (1)
  • build-logic/jvm/src/main/kotlin/testng.kotlin-library.gradle.kts
Additional comments: 20
gradle/wrapper/gradle-wrapper.properties (3)
  • 2-2: Ensure the new distributionPath setting aligns with the project's directory structure and Gradle's conventions.
  • 3-3: The update to distributionUrl for Gradle 8.5 is correct and follows the standard format for Gradle distribution URLs.
  • 4-4: Adding networkTimeout=10000 is a good practice to avoid build failures due to network issues. Verify that this timeout value suits the project's needs.
build-logic/code-quality/build.gradle.kts (2)
  • 13-13: Updating autostyle-plugin-gradle to version 4.0 should be verified for compatibility with the project's code style configurations.
  • 18-18: Dynamically setting jvmTarget to match the current Java version is a good practice for ensuring compatibility.
build-logic/jvm/build.gradle.kts (1)
  • 20-20: Dynamically setting jvmTarget to the current Java version's major version is a good practice.
build-logic/publishing/build.gradle.kts (1)
  • 20-20: Consistent use of dynamic jvmTarget setting across modules is a good practice for Java version compatibility.
gradle.properties (1)
  • 24-26: Adding systemProp.sonar.gradle.skipCompile=true to address a Gradle warning with SonarQube plugin version 4.x is a targeted fix. Ensure this property is compatible with the project's SonarQube integration.
settings.gradle.kts (2)
  • 10-10: Adding the org.gradle.toolchains.foojay-resolver-convention plugin at version "0.5.0" could enhance Java toolchain resolution. Verify its integration and benefits for the project.
  • 10-10: Ensure the removal of enableFeaturePreview("VERSION_CATALOGS") aligns with Gradle 8.5's capabilities and the project's dependency management strategy.
build-logic/jvm/src/main/kotlin/testng.java.gradle.kts (1)
  • 12-14: Dynamically setting the Java toolchain language version to the current Java version's major version is a good practice for ensuring compatibility.
gradlew.bat (3)
  • 17-17: Adjusting the handling of the %DEBUG% environment variable with @echo off conditionally improves script readability and debugging experience.
  • 28-29: Setting DIRNAME to . if it's empty ensures a fallback directory is always defined, improving the script's reliability in various execution contexts.
  • 44-44: The check for java.exe in the PATH and the subsequent error message if not found are crucial for early detection of configuration issues. Ensure the error messaging is clear and actionable.
testng-test-osgi/testng-test-osgi-build.gradle.kts (1)
  • 52-52: Handling potential null values for the type field in the generateDependenciesProperties task improves the script's robustness.
build-logic/publishing/src/main/kotlin/buildlogic/FirstLayerDependencies.kt (1)
  • 61-62: Refining usageKind calculation using replaceFirstChar improves clarity and correctness. Verify this change aligns with the project's dependency resolution strategy.
gradlew (4)
  • 1-1: Adding a shebang line #!/bin/sh at the beginning of the script ensures it is executed with a POSIX-compliant shell, enhancing portability and compliance.
  • 68-80: Improving symlink handling with a loop ensures that the script correctly resolves the actual path of the script file, enhancing reliability in environments where symlinks are common.
  • 170-175: Adjusting paths to Windows format for Cygwin or MSYS environments ensures compatibility and correct behavior of the script in Windows-based POSIX environments.
  • 237-242: Using eval and xargs to parse environment variables and construct the Java command arguments list is a robust approach to handling complex argument structures. Ensure this method does not introduce security vulnerabilities.

}

tasks.withType<KotlinCompile>().configureEach {
kotlinOptions {
jvmTarget = "11"
jvmTarget = JavaVersion.current().majorVersion
Copy link
Contributor

Choose a reason for hiding this comment

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

That binds the resulting binaries to the Java you use for launching Gradle.

It would be better to use a fixed target like target=11 or target=17 to avoid issues like "new testng is not compatible with Java 17 because Java 21 was used when building it"

Copy link
Member Author

Choose a reason for hiding this comment

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

It was intentional: I supposed that the release pipeline will use the appropriate jvm version.
I suppose what you did on jmeter is a better approach but I need to understand how to manage a version everywhere it is needed.

Copy link
Contributor

Choose a reason for hiding this comment

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

For JMeter, we manage it here: https://github.com/apache/jmeter/blob/master/build-logic/build-parameters/build.gradle.kts#L40-L49

In a nutshell, we ask Gradle to use specific JDK for building the code, and use a fixed "JVM target" release.

@juherr juherr changed the title Upgrade to gradle 8.5 Upgrade to gradle 8.6 Feb 5, 2024
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between b8b71d1 and fcfd1a7.
Files ignored due to path filters (1)
  • gradle/wrapper/gradle-wrapper.jar is excluded by: !**/*.jar
Files selected for processing (2)
  • gradle/wrapper/gradle-wrapper.properties (1 hunks)
  • gradlew (4 hunks)
Files skipped from review as they are similar to previous changes (1)
  • gradle/wrapper/gradle-wrapper.properties
Additional comments: 8
gradlew (8)
  • 25-38: Ensure POSIX compliance by verifying that all POSIX shell features used are correctly implemented and necessary for the script's functionality. This includes functions, expansions, compound commands, and built-in commands.
  • 68-80: The symlink resolution logic appears correct but test extensively across different environments to ensure it handles all types of symlinks, especially daisy-chained ones, without issues.
  • 87-87: Verify that APP_HOME is correctly determined in environments with complex directory structures or when the script is invoked from various locations.
  • 108-112: The OS-specific flags (cygwin, msys, darwin, nonstop) are set based on the output of uname. Confirm that these flags are used appropriately throughout the script to handle OS-specific behavior.
  • 130-249: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [121-140]

Ensure that the Java command determination logic correctly handles different JAVA_HOME configurations and provides clear error messages when Java is not found. This is crucial for user experience and script robustness.

  • 144-159: The logic to increase the maximum file descriptors is important for performance. Verify that it works as expected across different Unix-like systems, especially given the POSIX shell's limitations.
  • 171-197: The path conversion for Cygwin or MSYS environments is complex. Ensure that it correctly handles all argument types, including options and file paths, without introducing bugs or security issues.
  • 202-247: The argument parsing and JVM option handling using xargs and sed are intricate. Verify that this approach correctly handles all edge cases, especially concerning special characters and whitespace in JVM options.

gradlew Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between fcfd1a7 and e0bf624.
Files selected for processing (8)
  • build-logic/basics/build.gradle.kts (1 hunks)
  • build-logic/code-quality/build.gradle.kts (1 hunks)
  • build-logic/jvm/build.gradle.kts (1 hunks)
  • build-logic/jvm/src/main/kotlin/testng.java.gradle.kts (1 hunks)
  • build-logic/jvm/src/main/kotlin/testng.kotlin-library.gradle.kts (1 hunks)
  • build-logic/publishing/build.gradle.kts (1 hunks)
  • gradle.properties (2 hunks)
  • settings.gradle.kts (2 hunks)
Files skipped from review as they are similar to previous changes (7)
  • build-logic/code-quality/build.gradle.kts
  • build-logic/jvm/build.gradle.kts
  • build-logic/jvm/src/main/kotlin/testng.java.gradle.kts
  • build-logic/jvm/src/main/kotlin/testng.kotlin-library.gradle.kts
  • build-logic/publishing/build.gradle.kts
  • gradle.properties
  • settings.gradle.kts

Comment on lines +5 to +7
tasks.withType<JavaCompile>().configureEach {
options.release.set((project.property("targetJavaVersion") as String).toInt())
}
Copy link

Choose a reason for hiding this comment

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

Ensure that the "targetJavaVersion" project property is always defined and valid. If it's missing or not a valid integer, this code will throw an exception at runtime.

Consider adding error handling or a default value for "targetJavaVersion" to prevent build failures.

@juherr
Copy link
Member Author

juherr commented Feb 6, 2024

@vlsi I tried to update according to your recommendations. Please, review.

Now, I'm stuck with the issue:

An exception occurred applying plugin request [id: 'testng.java-library']
> Failed to apply plugin 'testng.java'.
   > Could not get unknown property 'jdkBuildVersion' for project ':build-logic:publishing:generatePrecompiledScriptPluginAccessors:accessors15374587191934751214' of type org.gradle.api.Project.

The property is declared in gradle.properties as systemProp.org.gradle.project.jdkBuildVersion=17.
Do you have any idea why the property is not found here?

@juherr juherr closed this Feb 16, 2024
@juherr juherr deleted the feature/upgrade-gradle branch February 16, 2024 11:42
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.

Upgrade to gradle 8.x
2 participants