Skip to content

Migrated the Liberty Gradle Plugin from Gradle 8 to Gradle 9#1045

Merged
venmanyarun merged 201 commits intoOpenLiberty:mainfrom
sajeerzeji:gradle9_JAN-2026
Feb 12, 2026
Merged

Migrated the Liberty Gradle Plugin from Gradle 8 to Gradle 9#1045
venmanyarun merged 201 commits intoOpenLiberty:mainfrom
sajeerzeji:gradle9_JAN-2026

Conversation

@sajeerzeji
Copy link
Contributor

Migrates the Liberty Gradle Plugin from Gradle 8 to Gradle 9, covering all plugin source changes, test fixes, build infrastructure updates, and CI pipeline improvements. Issue #868

Summary of Changes

Gradle Wrapper Update

  • Updated from Gradle 8.5 --> 9.0.0 --> 9.1.0

Build Configuration (build.gradle)

  • Added java-gradle-plugin plugin; migrated pluginBundle --> gradlePlugin block
  • Updated plugin-publish-plugin from 0.12.0 to 1.0.0
  • Added processResources exclusion for duplicate plugin descriptor
  • Modernized eager task creation to lazy tasks.register()
  • Removed deprecated artifacts { archives ... } block
  • Added failOnNoDiscoveredTests = false for test task
  • Added Java 25 toolchain support; updated dependency syntax to string notation
  • Excluded TestSpringBootApplication20* tests on Gradle 9

Plugin Source Changes

Method Visibility (private --> protected)

Gradle 9 uses Groovy 4, where closures in subclasses can no longer access private methods from parent classes (reference). Changed the following methods from private to protected:

  • DeployTask: installMultipleApps(), installLooseApplication(), addWarEmbeddedLib(), isSupportedType(), installProjectArchive(), hasJavaSourceFiles(), addLibrary(), checkAndLoadInstallExtensionProperties(), buildInstallLibertyMap(), loadLibertyRuntimeProperties()
  • AbstractServerTask: writeJvmOptions(), handleServerEnvFileAndProperties(), setServerEnvWithAppendServerEnvHelper(), setServerEnvPathHelperForAppendServerEnv(), setServerEnvHelper(), mergeSpecialPropsFromInstallServerEnvIfAbsent(), convertServerEnvToProperties(), combineServerEnvProperties(), writeServerEnvProperties(), writeConfigDropinsServerVariables(), makeParentDirectory(), findServerEnvFile(), findJvmOptionsFile(), readConfigFileLines(), populateEnvironmentVariablesMap(), addToolchainEnvToProcessBuilder(), addToolchainEnvToServerTask()
  • AbstractLibertyTask: configureDefaults(), isLibertyInstalledAndValid()
  • AbstractFeatureTask: getServerFeatureUtil()
  • AbstractServerTask: getAppNamesFromServerXml()

Removed Incorrect @Internal Annotations

In Gradle 9, @Internal is only valid on task input/output property getters. Removed from non-getter methods: isLibertyInstalledAndValid(), getServerFeatureUtil(), mergeJvmOptions(), findServerEnvFile(), findJvmOptionsFile(), readConfigFileLines(), populateEnvironmentVariablesMap(), addToolchainEnvToProcessBuilder(), addToolchainEnvToServerTask()

Dependency Resolution (Gradle 9 API Changes)

  • AbstractServerTask: Cannot modify dependencies after configuration resolution. Implemented detached configuration approach, clone dependency, set transitive on clone, resolve via detachedConfiguration().resolve() instead of configuration.files(dep)
  • ProjectDependency API: Replaced deprecated getDependencyProject() with getPath() + findProject() in Liberty.groovy, DeployTask.groovy, DevTaskHelper.groovy

Loose Application: Configuration and Artifact Changes

  • Created explicit custom configurations (warOnly, jarOnly) for EAR/WAR artifact exposure between projects, replacing reliance on archives configuration which changed behavior in Gradle 9 (reference)

Server Stop: Resource Release Verification

  • Enhanced StopTask with verifyServerFullyStopped() and forceCleanupServerResources() to ensure file locks are released before subsequent clean tasks

Refactored writeJvmOptions() --> mergeJvmOptions()

  • Extracted reusable mergeJvmOptions() method from writeJvmOptions() for use in toolchain JAVA_HOME precedence checks

Property Value Parsing Fix

  • Fixed splitNameValue to use split(":", 2) instead of split(":") to correctly handle property values containing colons

Test Fixes

Java Compilation Properties (across ~50+ test build files)

Updated deprecated sourceCompatibility = 1.8 syntax to Gradle 9 compatible block:

java {
    sourceCompatibility = JavaVersion.VERSION_1_8
    targetCompatibility = JavaVersion.VERSION_1_8
}

Test Areas Fixed

  • core infrastructure: AbstractIntegrationTest, LibertyTest
  • development mode: BaseDevTest, DevTest, DevRecompileTest, PollingDevTest
  • feature installation: DevSkipInstallFeatureTest, DevSkipInstallFeatureConfigTest
  • liberty installation: InstallLiberty_installDir_full_lifecycle_Test
  • application configuration: LibertyApplicationConfigurationTest, TestAppConfig, TestAppListsWithObjects, TestGetAppNames
  • server environment: server env append/merge tests
  • packaging: LibertyPackage_looseApplication_Test
  • server creation: testCreateLibertyFiles, testCreateLibertyInlineProperties, testCreateLibertyDefaultConfigDir
  • jsp compilation: TestCompileJSP, TestCompileJSPSource17 (updated expected Java source level from 8 to 17)
  • verification: verifyTimeoutSuccess* tests
  • feature generation: GenerateFeaturesTest, BaseGenerateFeaturesTest
  • eclipse integration: ProjectDependency resolution in loose EAR packaging
  • loose application: loose-ear-test, loose-ear-earlibs-test, loose-war-with-loose-jar
  • arquillian: ConfigureArquillianTest (pinned to Gradle 8.5 for Spring dependency management plugin compatibility; updated Spring dependency management plugin from 1.0.4.RELEASE to 1.1.7)
  • liberty runtime url: InstallLiberty_runtimeUrl_upToDate_Test (updated URLs from 21.0.0.1 -> 21.0.0.4)
  • spring boot 3.0: all 10 test_spring_boot_*_30.gradle files (Java 17 compatibility, Spring Boot 3.1.2 -> 3.4.1)
  • toolchain tests: toolchain warning test build files updated for Gradle 9 syntax

Other Test Fixes

  • LibertyTest: Added explicit libertyStop before clean to prevent file lock errors
  • GenerateFeaturesTest: Updated assertions to check key parts of messages instead of exact strings; increased process timeout from 20s to 50s
  • InstallLiberty_installDir_full_lifecycle_Test: Renamed server from 'test' to specific name to prevent pid matching killing the Gradle test process
  • TestLooseApplicationWithToolchain: Fixed assertions for merged toolchain implementation
  • Foojay toolchain resolver plugin upgraded from 0.8.0 to 1.0.0 in all test settings.gradle files

CI Pipeline (gradle.yml)

  • Java matrix: [21, 17, 25]; distribution changed from adopt to temurin
  • Liberty runtime version updated to 25.0.0.10
  • Updated test exclusions for Windows (toolchain tests, Spring Boot tests)

Sajeer and others added 30 commits July 23, 2025 17:37
…ssues (AbstractIntegrationTest.groovy, LibertyTest.groovy)
…e/utils/, Moved all the server verification and cleanup methods from StopTask to ServerUtils, Updated StopTask to use the methods from ServerUtils
…tempts from 10 to 5 and lowered the maximum wait time from 5000ms to 4000ms
… a new class has been added for Process/Resource operations.
…address if the .liberty_plugin_force_stopped file is not delete or .liberty_plugin_force_stopped is not available
…utils and re-used it from StartTask.groovy and StopTask.groovy
…he closequitely method from ProcessUtils.groovy
…on_migration

Gradle version migration and Core Infrastructure Tests fixes
…s, private methods were having visibility issues within the groovy class
…ly and newly fixed test files. build.gradle updates to support gradle 9 character encoding and java toolchain language version
Copy link
Member

@cherylking cherylking left a comment

Choose a reason for hiding this comment

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

see one remaining comment...approving so you won't be held up on merging...but please modify the support statements in the readme.

You lost some important info about which Java version is supported with which plugin version. Your new bullets on Gradle version support are good, except the second bullet also supports Java 21 I believe.

@cherylking
Copy link
Member

@sajeerzeji Please add back the paragraph on Java support in the readme. You lost key info when you created your two new bullets on Gradle version support.

The Liberty Gradle Plugin is tested with Long-Term-Support (LTS) releases of Java. The plugin, as of release 3.8, supports Java 8, 11, 17 and 21. Versions 3.5 to 3.7.x support Java 8, 11 and 17. Prior to version 3.5, the plugin is supported on Java 8 and 11.

You just need to add another sentence saying that as of release 4.0.0, we support Java 17, 21 and 25. And probably mention to check out our toolchain support for running their applications on older versions of Java.

@sajeerzeji
Copy link
Contributor Author

@sajeerzeji Please add back the paragraph on Java support in the readme. You lost key info when you created your two new bullets on Gradle version support.

The Liberty Gradle Plugin is tested with Long-Term-Support (LTS) releases of Java. The plugin, as of release 3.8, supports Java 8, 11, 17 and 21. Versions 3.5 to 3.7.x support Java 8, 11 and 17. Prior to version 3.5, the plugin is supported on Java 8 and 11.

You just need to add another sentence saying that as of release 4.0.0, we support Java 17, 21 and 25. And probably mention to check out our toolchain support for running their applications on older versions of Java.

I have updated the README as suggested

@venmanyarun venmanyarun merged commit de2e591 into OpenLiberty:main Feb 12, 2026
12 checks passed
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.

3 participants