Skip to content

refactor: extract shared LinuxPackaging utility to eliminate build script duplication#1407

Merged
gdams merged 1 commit into
adoptium:masterfrom
gdams:refactor
May 19, 2026
Merged

refactor: extract shared LinuxPackaging utility to eliminate build script duplication#1407
gdams merged 1 commit into
adoptium:masterfrom
gdams:refactor

Conversation

@gdams
Copy link
Copy Markdown
Member

@gdams gdams commented May 18, 2026

Summary

Extracts all duplicated Gradle build logic from the 16 platform build.gradle files (jdk/jre × alpine/debian/redhat/suse) in both linux/ and linux_new/ into a shared LinuxPackaging utility class in buildSrc.

Problem

Each platform build file contained ~150-230 lines of nearly identical code:

  • ~60 lines of boilerplate (plugins, repositories, dependencies, sourceSets, test config)
  • ~100 lines of docker build/run/check task logic with only minor parameter differences

This made maintenance painful — any change to the build pattern required updating 16+ files, with inevitable drift and inconsistency.

Solution

A single LinuxPackaging.groovy class in buildSrc provides:

  • applyCommonConfig(project) — sets up all shared Gradle configuration
  • configure(project, config) — creates packaging and check tasks from a declarative config map

Each platform build file is now ~10 lines:

import org.adoptium.LinuxPackaging

LinuxPackaging.configure(project, [
    imageType    : 'jdk',
    distro       : 'RedHat',
    dockerTag    : 'redhat',
    gpgBuild     : true,
    localBuild   : true,
    extraRunEnvs : ['buildVersion', 'buildLocalFlag'],
    microsoftPkg : true,
    gpgCheck     : true,
    archCheck    : true,
])

Changes

  • New: linux/buildSrc/src/main/groovy/org/adoptium/LinuxPackaging.groovy
  • New: linux_new/buildSrc/ with ExecHelper.groovy + LinuxPackaging.groovy
  • Simplified: All 16 platform build.gradle files + ca-certificates/debian/build.gradle
  • Net: -2,967 lines, +207 lines

Compatibility

  • All Gradle task names preserved exactly (packageJdkAlpine, checkJdkRedHat, packageJdkrhel, etc.)
  • Jenkinsfiles and CI pipelines require no changes
  • Verified with ./gradlew tasks on both linux/ and linux_new/

…ript duplication

Move ~60 lines of identical boilerplate (plugins, repositories, dependencies,
sourceSets, test config) and ~100 lines of docker build/run/check task logic
into a shared LinuxPackaging utility class in buildSrc.

Each platform build.gradle (jdk/jre × alpine/debian/redhat/suse) is reduced
from ~150-230 lines to ~10 lines of declarative configuration. The ca-certificates
build is similarly simplified using applyCommonConfig().

All Gradle task names are preserved exactly (packageJdkAlpine, checkJdkRedHat,
packageJdkrhel, etc.) so Jenkinsfiles and CI pipelines require no changes.

Also adds buildSrc to linux_new/ with ExecHelper wrapper for consistent exec
handling across both directories.

Net change: -2,967 lines, +207 lines across 17 modified + 4 new files.
@gdams gdams requested a review from steelhead31 May 18, 2026 12:06
@gdams gdams enabled auto-merge (squash) May 18, 2026 13:01
Copy link
Copy Markdown
Contributor

@steelhead31 steelhead31 left a comment

Choose a reason for hiding this comment

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

Looks good, the code looks much cleaner with this refactor.

Copy link
Copy Markdown
Contributor

@andrew-m-leonard andrew-m-leonard left a comment

Choose a reason for hiding this comment

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

looks good

@gdams gdams merged commit 429d1ee into adoptium:master May 19, 2026
133 of 134 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