Skip to content

Complete Groovy to Java 25 migration and modernize with Lombok and Records - #541

Open
DerDaehne wants to merge 90 commits into
developfrom
feature/migrate-to-java
Open

Complete Groovy to Java 25 migration and modernize with Lombok and Records#541
DerDaehne wants to merge 90 commits into
developfrom
feature/migrate-to-java

Conversation

@DerDaehne

Copy link
Copy Markdown
Contributor

Overview

This pull request completes the migration of the remaining core application components from Groovy to Java 17. The changes focus on reducing boilerplate code and improving
readability by implementing Lombok, Java 17 Records, and modern Java syntax features.


Key Changes

  1. Boilerplate Reduction with Lombok
  • Lombok Integration: Configured the Lombok dependency and annotation processor inside pom.xml.
  • Config.java Refactoring: Applied @Getter and @Setter to the outer class and all 28 nested static schema classes. Standard trivial getters and setters were removed, resulting
    in a net reduction of 1,352 lines of code (~63% reduction). All custom validation logic and constructors initializing helm defaults were preserved.
  • Credentials.java and ScmCentralSchema.java: Refactored with @Getter, @Setter, and @tostring(exclude = "password") to eliminate more than 160 lines of boilerplate while
    ensuring sensitive passwords are never written to application logs.
  1. Adoption of Java 17 Records
  • Role.java and Permission.java: Converted to native Records to enforce immutability and replace repetitive class structures. Compact constructors were implemented for input
    validation.
  • FreeMarker Compatibility: Kept DockerImageParser.Image as a standard class but annotated it with Lombok @Getter instead of converting it to a Record. This avoids template
    parsing issues caused by the custom AllowListFreemarkerObjectWrapper requiring standard JavaBean getter methods (i.e. getRegistry()).
  • Test Updates: Updated property-style accesses in Groovy Spock tests (ScmManagerProviderTest.groovy) to use record-style method accessors (e.g. p.groupPermission()).
  1. Modern Java 17 Features
  • Pattern Matching for instanceof: Modernized K8sClient.java inside extractPhase(HasMetadata) to eliminate manual casting when checking for Pod instances.
  • Switch Expressions: Refactored visibility and access level mapping in GitlabProvider.java using switch expressions with arrow syntax (->) and multi-label cases (MAINTAIN,
    ADMIN ->).
  • Text Blocks: Converted inline Groovy script strings in PrometheusConfigurator.java into Java 17 Text Blocks ("""), removing raw newline string concatenations.
  1. Test Suite and Build Validation
  • Helm Version Fix: Corrected a version mismatch in GitopsPlaygroundCliTest.groovy by raising the expected Helm version to 3.11.10 to match the default configuration in
    ScmTenantSchema.java.
  • Test Executions: All 527 unit and integration tests are passing.

DerDaehne and others added 30 commits July 14, 2026 13:34
Migrate 'ReturnCode' enum and 'MapUtils' helper class from Groovy to Java.
This is the first step of the Groovy-to-Java migration, proving
the joint compilation setup works perfectly.

Co-authored-by: Gemini <gemini@google.com>
Migrate 'DockerImageParser' and its nested 'Image' class from Groovy to Java.
Use modern Java Records for intermediate Tuple representation.

Co-authored-by: Gemini <gemini@google.com>
Migrate 'NetworkingUtils' class from Groovy to Java.
Implement method overloading to replace Groovy default parameters, and
replace dynamic property accesses with standard Java getters.

Co-authored-by: Gemini <gemini@google.com>
…er to Java

Migrate 'CommandExecutor' and 'InsecureCredentialProvider' from Groovy to Java.
Implement necessary Groovy-interoperable method overloads for
process-execution and environmental variable mapping.

Co-authored-by: Gemini <gemini@google.com>
Migrate 'AirGappedUtils' class from Groovy to Java.
Adjust visibility of GitRepo.NAMESPACE_3RD_PARTY_DEPENDENCIES constant to
public so it is exposed to the Java compiler in joint compilation.

Co-authored-by: Gemini <gemini@google.com>
Migrate 'ClusterResourcesCopyFilter' utility from Groovy to Java.
Implement streams and lambdas to replace Groovy collections and closures.

Co-authored-by: Gemini <gemini@google.com>
Migrate 'AllowListFreemarkerObjectWrapper' from Groovy to Java.
Use standard Java anonymous classes to represent the filtered TemplateHashModel.

Co-authored-by: Gemini <gemini@google.com>
Migrate 'TemplatingEngine' from Groovy to Java.
Implement overloads to replace Groovy default parameters and use
try-with-resources to safely close Files.walk streams.

Co-authored-by: Gemini <gemini@google.com>
Migrate 'FileSystemUtils' from Groovy to Java.
Use Files.readString and Files.writeString instead of Groovy extensions.
Implement try-with-resources for file walks to prevent stream resource leaks.

Co-authored-by: Gemini <gemini@google.com>
Migrate 'ScmProviderType' enum and 'ConfigConstants' interface from Groovy to Java.

Co-authored-by: Gemini <gemini@google.com>
Migrate 'Credentials' configuration model class from Groovy to Java.
Implement standard Java getters and setters and override toString.

Co-authored-by: Gemini <gemini@google.com>
Migrate 'GitlabConfig' and 'ScmManagerConfig' interfaces from Groovy to Java.

Co-authored-by: Gemini <gemini@google.com>
Migrate 'JsonSchemaGenerator' and 'JsonSchemaValidator' from Groovy to Java.
Use standard streams and list representation for schema validation messages.

Co-authored-by: Gemini <gemini@google.com>
Migrate 'MultiTenantSchema', 'ScmCentralSchema', and 'ScmTenantSchema' from Groovy to Java.
Use standard Java nested static classes and bean properties for Picocli option parsing.

Co-authored-by: Gemini <gemini@google.com>
Fix GString cast issue in CommandExecutorForTest by using standard java String list.
Let TemplatingEngine propagate raw Freemarker exceptions so that
AllowlistFreemarkerObjectWrapperTest asserts the correct exception type.

Co-authored-by: Gemini <gemini@google.com>
Migrate the central 'Config' class from Groovy to Java.
Implement nested static configuration schemas and explicit bean getters/setters.
Integrate modern Java SecureRandom password generator and lambda-based Jackson serialization modifiers.

Co-authored-by: Gemini <gemini@google.com>
Migrate 'Role', 'RoleBinding', and 'ServiceAccountRef' from Groovy to Java.
Implement nested enum Variant in Role and standard constructor logic.

Co-authored-by: Gemini <gemini@google.com>
Migrate 'RbacDefinition' logic from Groovy to Java.

Co-authored-by: Gemini <gemini@google.com>
Migrate 'HelmClient' utility from Groovy to Java.
Implement method overloads to replace Groovy default parameter values.
Delete empty 'HelmClientTest.groovy' placeholder.

Co-authored-by: Gemini <gemini@google.com>
Migrate the central 'K8sClient' from Groovy to Java.
Implement composition and delegation by splitting off private stateless helpers
into a package-private 'K8sClientHelper' class.
Expose mutable 'client' and 'gopConfig' fields for mock test injections.

Co-authored-by: Gemini <gemini@google.com>
Migrate 'GitRepo' and 'GitRepoFactory' from Groovy to Java.
Adjust AirGappedUtils.java to properly wrap checked JGit GitAPIExceptions/IOExceptions in RuntimeExceptions.

Co-authored-by: Gemini <gemini@google.com>
Migrate 'ScmManagerApiClient', 'ScmManagerApi', 'RepositoryApi', 'UsersApi', and 'PluginApi' from Groovy to Java.
Adjust ScmManagerSetupTest Mockito stubbing for getGitProvider() to support Java getters.

Co-authored-by: Gemini <gemini@google.com>
Migrate 'JenkinsApiClient', 'UserManager', 'JobManager', and 'GlobalPropertyManager' from Groovy to Java.
Use Java Text Blocks and precise string placeholders/replacements to match multiline Groovy string test assertions exactly.
Use LinkedHashMap to preserve exact JSON map insertion order in credential serialization.

Co-authored-by: Gemini <gemini@google.com>
Migrate 'Tool', 'CommonToolConfig', and 'ImagePullSecretCreator' from Groovy to Java.
Use private logger visibility in Tool.java to prevent name collisions with Groovy subclasses annotated with @slf4j.
Implement robust Java reflection fallback to support subclass dynamic 'namespace' property lookups.

Co-authored-by: Gemini <gemini@google.com>
Migrate 'Ingress', 'Registry', 'CertManager', and 'ExternalSecretsOperator' from Groovy to Java.
All migrated classes inherit from the new Java 'Tool' base class.

Co-authored-by: Gemini <gemini@google.com>
Migrate 'ArgoCD' and 'ScmManager' from Groovy to Java.
Keep standard annotations, DI wiring and orders intact.

Co-authored-by: Gemini <gemini@google.com>
Migrate 'Jenkins', 'Vault', and 'Monitoring' from Groovy to Java.
Wrap checked IOException and TemplateException thrown by TemplatingEngine.replaceTemplate
in Vault.java and convert etc/group gid lookup to use pure Java parsing.

Co-authored-by: Gemini <gemini@google.com>
Migrate all core Application components, Workspace classes, ContentLoader
and CLI classes from Groovy to Java 17.
Ensure proper type checking for nested RepoCoordinate in ContentLoaderTest.

Co-authored-by: Gemini <gemini@google.com>
- Wrap JGit checked exceptions in Tool.java and ArgoCD.java.
- Implement robust raw Map type check and Groovy-compatible map printing in ArgoCD.java's postConfigInit.
- Propagate raw RuntimeExceptions in AirGappedUtils.java.
- Use a mutable HashMap for service registry helm values to support deep merging.

Co-authored-by: Gemini <gemini@google.com>
@avetgit
avetgit requested a review from Copilot August 4, 2026 09:36

Copilot AI 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.

Copilot wasn't able to review this pull request because it exceeds the maximum number of lines (20,000). Try reducing the number of changed lines and requesting a review from Copilot again.

@FelixWende99 FelixWende99 changed the title Complete Groovy to Java 17 migration and modernize with Lombok and Records Complete Groovy to Java 25 migration and modernize with Lombok and Records Aug 6, 2026
@mdroll
mdroll dismissed their stale review August 7, 2026 07:26

All comments should be resolved

Create SCM-Manager repositories without the automatic initial commit and handle empty remote repositories during GOP bootstrap.

When a repository has no existing origin/main branch, GOP now prepares a local main branch and creates the first commit itself. This removes the SCM-Manager-generated "initialize repository" commit from the repository history and makes the initial repository state fully owned by GOP.
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.

6 participants