-
Notifications
You must be signed in to change notification settings - Fork 39
[WIP] Feature: CRD Generation to POJO Classes at Maven Build Time #450
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
[WIP] Feature: CRD Generation to POJO Classes at Maven Build Time #450
Conversation
src/main/java/org/waveywaves/jenkins/plugins/tekton/generator/CrdJavaGenerator.java
Fixed
Show fixed
Hide fixed
42965e9
to
1ea861b
Compare
9a31b26
to
a68e870
Compare
- Resolves JUnit version incompatibility issue - Fixes 'TestEngine with ID junit-jupiter failed to discover tests' error - Aligns JUnit Jupiter Engine with other JUnit components - All 27 tests now pass successfully
- Move exec-maven-plugin from download-binaries profile to main build - Change execution phase from process-classes to generate-sources - Move build-helper-maven-plugin to main build for consistency - Enable CRD generation with simple 'mvn generate-sources' command - Generate 800+ Tekton POJO classes from CRD definitions - Support all Tekton resources: Tasks, Pipelines, TaskRuns, PipelineRuns, CustomRuns, StepActions - Generated classes extend Jenkins BaseStep for pipeline integration - Includes multi-version support: v1, v1beta1, v1alpha1 This improves developer experience by simplifying the code generation workflow.
Fix: Disable equals/hashCode generation to avoid SpotBugs issuesRoot cause: jsonschema2pojo library generates equals() methods with problematic string comparison ( Solution: Disable equals/hashCode generation entirely by setting Explanation on this approach:
|
…EnhancedCrdProcessor.java Co-authored-by: Copilot <[email protected]>
…CrdJavaGenerator.java Co-authored-by: Copilot <[email protected]>
…ld/delete/DeleteRawTest.java Co-authored-by: Copilot <[email protected]>
…EnhancedCrdProcessor.java Co-authored-by: Copilot <[email protected]>
…EnhancedCrdProcessor.java Co-authored-by: Copilot <[email protected]>
- Fix missing method declaration for isIncludeHashcodeAndEquals() - Remove malformed code that caused compilation errors - Restore proper Java syntax
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a comprehensive CRD (Custom Resource Definition) to POJO generation feature for the Tekton Jenkins plugin, automatically generating over 1000 Java classes from Tekton CRD schemas during Maven build time. The feature enables automatic creation of typed Java classes that extend BaseStep for Jenkins pipeline integration.
Key changes include:
- Core CRD processing engine using jsonschema2pojo with enhanced inheritance capabilities
- Maven integration for automatic POJO generation during build time
- Addition of multiple Tekton CRD YAML files (pipeline, task, stepaction, etc.)
Reviewed Changes
Copilot reviewed 13 out of 17 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
src/main/java/org/waveywaves/jenkins/plugins/tekton/generator/EnhancedCrdProcessor.java | Core CRD processing logic that converts YAML schemas to Java POJOs with Jenkins BaseStep inheritance |
src/main/java/org/waveywaves/jenkins/plugins/tekton/generator/CrdJavaGenerator.java | Maven exec plugin entry point for CRD generation with Jenkins-specific configuration |
src/main/resources/crds/*.yaml | Multiple Tekton CRD definition files for pipeline, task, stepaction, and other resources |
pom.xml | Maven configuration updates including new dependencies, exec plugin setup, and build process changes |
src/test/java/org/waveywaves/jenkins/plugins/tekton/client/build/delete/DeleteRawTest.java | Test import addition for DeleteAllBlock inner class |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
src/main/java/org/waveywaves/jenkins/plugins/tekton/generator/EnhancedCrdProcessor.java
Outdated
Show resolved
Hide resolved
- Rename CrdJavaGenerator.java -> TektonPojoGenerator.java - Rename EnhancedCrdProcessor.java -> TektonCrdToJavaProcessor.java - Update all class names and references in code - Update pom.xml mainClass references - More descriptive and comprehensive naming convention
src/main/java/org/waveywaves/jenkins/plugins/tekton/generator/TektonPojoGenerator.java
Fixed
Show resolved
Hide resolved
- Replace all System.exit() calls with appropriate exception throwing - Use IllegalArgumentException for invalid arguments - Use RuntimeException for runtime failures - Addresses Jenkins security scan warning about unsafe method calls - Prevents plugin from terminating entire Jenkins process
src/main/java/org/waveywaves/jenkins/plugins/tekton/generator/TektonPojoGenerator.java
Fixed
Show fixed
Hide fixed
hi @krisstern I have fixed the security warning |
@waveywaves this is the issue i was talking about |
Just an open question here (Maybe this discussion already happend). Any reason to not use https://github.com/fabric8io/kubernetes-client/blob/main/doc/java-generation-from-CRD.md to generate the Java Object from CRDs? This can be used with java-generator-maven-plugin maven plugin and specifying the location of the CRDs Since we already have the https://plugins.jenkins.io/kubernetes-client-api/ it should not be an issue to have such POJO implement interface like (HasMetadata) I used the mentionned approach not so long ago to generate Java classes from Flux CD CRDs (like HelmRelease) and this works like a charm (fabric8io/kubernetes-client#7130) Looking at the config and dependencies added this look fragile to me, but maybe I miss the reason |
Thank you for pointing that out! Your approach definitely looks more efficient. I’m looking into it now and will work on applying it. |
This PR adds a new feature that automatically generates Java POJO classes from Tekton Custom Resource Definitions (CRDs) during Maven build time.
What's Added
Core Components
CrdJavaGenerator
Main entry point for Maven exec plugin integration.EnhancedCrdProcessor
Core logic for processing CRD YAML files and generating Java classes usingjsonschema2pojo
.Maven Profile Integration A new Maven profile
download-binaries
is added for:Generated Output
v1
,v1beta1
,v1alpha1
BaseStep
and include@DataBoundConstructor
for pipeline compatibilityNext Steps
createCustomTaskRun
,pipeline
, etc.BaseStep
Submitter checklist
Architecture Diagram