Skip to content

ci: streamline enforcer job and update version requirements - #14142

Draft
lqiu96 wants to merge 1 commit into
googleapis:mainfrom
lqiu96:optimize_enforcer_job_runtime
Draft

ci: streamline enforcer job and update version requirements#14142
lqiu96 wants to merge 1 commit into
googleapis:mainfrom
lqiu96:optimize_enforcer_job_runtime

Conversation

@lqiu96

@lqiu96 lqiu96 commented Aug 20, 2026

Copy link
Copy Markdown
Member

Summary

Reduces the CI enforcer job runtime from ~20+ minutes down to ~15 seconds by removing the banDuplicateClasses rule and eliminating the full-repo mvn install step.

Key Changes

  • Remove banDuplicateClasses rule: The banDuplicateClasses rule in java-shared-config required compiled dependency .jar files to exist on disk to inspect bytecode, which forced CI to compile and install all 285+ modules before checking enforcer rules. Removing it allows mvn enforcer:enforce to run purely on POM dependencies in memory.
  • Streamline CI enforcer workflow: In .github/workflows/ci.yaml, removed the Install Maven modules to local Maven repository (JOB_TYPE: install) step, invoking mvn -B -ntp enforcer:enforce@enforce -T 1C directly.
  • Update required versions: Updated requireMavenVersion to [3.9.0,) and requireJavaVersion to [1.8,) in java-shared-config.
  • Skip enforcer on java-samples: Added <enforcer.skip>true</enforcer.skip> to java-samples/pom.xml to match other non-released sample module configurations.

Verification

  • mvn -B -ntp enforcer:enforce@enforce -T 1C executed across all 285 modules cleanly in ~6–15 seconds without requiring any prior installation.

With strict dependency governance policies inside the Java SDK, we ensure that we do not introduce duplicate dependencies or dependencies with overlapping package names. Running banDuplicateClasses with a full mvn install locally is overkill given that we rarely introduce new dependencies.

- Remove banDuplicateClasses enforcer rule in java-shared-config to eliminate need for building and installing all module JARs to local disk
- Remove pre-install step in CI enforcer workflow, allowing direct enforcer execution across all modules in seconds
- Update requireMavenVersion to [3.9.0,) and requireJavaVersion to [1.8,)
- Set enforcer.skip to true for java-samples parent POM
@lqiu96
lqiu96 requested review from a team as code owners August 20, 2026 01:26

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request configures java-samples to skip the enforcer plugin, updates the minimum Maven and Java version requirements in the shared configuration, and removes the banDuplicateClasses rule. The reviewer noted that removing the banDuplicateClasses rule completely exposes downstream projects to classpath conflicts and suggested instead moving it to a separate profile or execution phase to maintain protection without slowing down PR checks.

I am having trouble creating individual review comments. Click here to see my feedback.

java-shared-config/java-shared-config/pom.xml (257-264)

medium

Removing the banDuplicateClasses rule entirely from the shared configuration eliminates protection against classpath conflicts (JAR hell) for all downstream projects inheriting this configuration. While this significantly speeds up the CI enforcer job by avoiding bytecode inspection of compiled dependencies, completely disabling this check increases the risk of duplicate classes causing runtime issues (such as LinkageError or NoSuchMethodError).

Consider keeping this rule but binding it to a separate execution or a profile (e.g., activated only during release or packaging phases) so that it doesn't block fast PR checks but still runs before releases.

@lqiu96
lqiu96 marked this pull request as draft August 20, 2026 01:31
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