Skip to content

Internal - Gradle 9 Migration#419

Open
cleverchuk wants to merge 1 commit intomainfrom
cc/NH-127206
Open

Internal - Gradle 9 Migration#419
cleverchuk wants to merge 1 commit intomainfrom
cc/NH-127206

Conversation

@cleverchuk
Copy link
Contributor

Summary

Migrates the build system from Gradle 8.10 to Gradle 9.3.1 and updates all related build plugins to their latest compatible versions.

Key Changes

Gradle Version Upgrade

Upgrades from Gradle 8.10 to 9.3.1, bringing performance improvements, better dependency resolution, and support for newer JVM features during build time.

Plugin Updates

Plugin Previous Version New Version
spotless-plugin-gradle 6.25.0 8.2.1
gradle-plugins (otel instrumentation) 2.10.0-alpha 2.24.0-alpha
shadow-gradle-plugin 8.3.5 9.3.1
buildconfig gradle plugin 5.5.1 6.0.7

API Compatibility Fixes

Shadow Plugin Changes:

  • archiveClassifier = null replaced with archiveClassifier.set("") — Gradle 9 deprecates direct property assignment in favor of the Property API
  • mergeServiceFiles { include(...) } replaced with mergeServiceFiles("inst/META-INF/services") — aligns with new Shadow plugin API
  • Added explicit filesMatching("META-INF/services/**") { duplicatesStrategy = DuplicatesStrategy.INCLUDE } blocks since mergeServiceFiles() now requires explicit duplicate handling

Manifest Attributes:

  • Migrated from indexed assignment attributes["key"] = value to attributes(mapOf(...)) syntax for consistency with Gradle 9 conventions

Configuration API:

  • Removed isVisible = false from dependency management configuration — this property is deprecated in Gradle 9

Spotless Plugin:

  • Changed from indentWithSpaces() to leadingTabsToSpaces() to match the new plugin API

Function Return Types:

  • Added explicit : CopySpec return type annotations to isolateClasses() functions for type inference compatibility

Dependency Exclusion Updates

Added exclusions for new transitive dependencies that must not appear in the inst/ directory:

  • io.opentelemetry.semconv:opentelemetry-semconv-incubating
  • io.opentelemetry:opentelemetry-api-incubator

These are bootstrap-level dependencies that need special classloader handling and cannot be bundled with isolated agent classes.

AutoService Annotation Processor Fix

Added -Averify=false compiler argument globally in solarwinds.java-conventions.gradle.kts to disable AutoService verification checks. This resolves a Gradle 9 compatibility issue where @SuppressWarnings("rawtypes") annotations on classes implementing generic service provider interfaces (e.g., ConfigParser<T, R>) are not recognized by the AutoService annotation processor during certain compilation contexts, causing build failures with -Werror.

Affected classes: All ConfigParser implementations in libs/shared that use @AutoService(ConfigParser.class).

Technical Rationale

Gradle 9 introduces stricter type safety and deprecates legacy Groovy-style property assignments. The changes ensure forward compatibility while maintaining identical build output behavior. The Shadow plugin 9.x requires explicit duplicate strategies when using mergeServiceFiles(), preventing silent file overwrites during JAR assembly.

The AutoService -Averify=false workaround is necessary because the annotation processor's element.getAnnotation(SuppressWarnings.class) call fails to find the @SuppressWarnings("rawtypes") annotation in Gradle 9 compilation contexts, despite the annotation being present in source code. This is tracked with a FIXME comment for future refactoring of the generic service provider interface pattern.

Test services data

  1. e-1712644058766987264
  2. e-1712643928659124224
  3. e-1742334541200846848
  4. e-1777406072376840192

@cleverchuk cleverchuk requested review from a team as code owners February 12, 2026 19:22
@cleverchuk cleverchuk requested a review from Copilot February 12, 2026 19:22
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Migrates the build to Gradle 9.3.1 and updates key build plugins, adapting build logic to Gradle 9/Shadow 9 APIs.

Changes:

  • Upgraded Gradle wrapper and buildSrc plugin dependencies (Spotless, Shadow, OTel Gradle plugins, BuildConfig).
  • Updated ShadowJar configuration to use Property API + explicit service file duplicate handling.
  • Adjusted conventions (Spotless formatting, Java compiler args) for Gradle 9 compatibility.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
testing/agent-for-testing/build.gradle.kts Updates ShadowJar/service-file handling and Gradle 9 property API usage in test agent build.
solarwinds-otel-sdk/build.gradle.kts Adjusts ShadowJar classifier configuration for Gradle 9 Property API.
gradle/wrapper/gradle-wrapper.properties Upgrades Gradle wrapper to 9.3.1.
buildSrc/src/main/kotlin/solarwinds.spotless-conventions.gradle.kts Updates Spotless “misc” formatting configuration for newer Spotless API.
buildSrc/src/main/kotlin/solarwinds.shadow-conventions.gradle.kts Adds global service-file merging + duplicate handling for ShadowJar tasks.
buildSrc/src/main/kotlin/solarwinds.java-conventions.gradle.kts Removes deprecated configuration visibility flag; adds global AutoService verify disable flag.
buildSrc/build.gradle.kts Bumps buildSrc plugin dependency versions for Gradle 9 compatibility.
build.sh Splits formatting and build into separate Gradle invocations.
agent/build.gradle.kts Updates ShadowJar service merging/duplicates + Gradle 9 property API; adds exclusions.
agent-lambda/build.gradle.kts Updates ShadowJar service merging/duplicates + Gradle 9 property API; adds exclusions.

Copy link
Contributor

@cheempz cheempz left a comment

Choose a reason for hiding this comment

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

LGTM

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants