Skip to content

codegen: extract codegen modules (codegen-core, codegen-roaster, simple-processor, codegen-testing) - #368

Merged
AndreasIgel merged 48 commits into
java-helpers:mainfrom
igel-devin-ai:devin/1792742307-simple-codegen-moves
Nov 9, 2026
Merged

AndreasIgel merged 48 commits into
java-helpers:mainfrom
igel-devin-ai:devin/1792742307-simple-codegen-moves

Conversation

@igel-devin-ai

@igel-devin-ai igel-devin-ai commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Phase 2 of the codegen extraction (#233, subtask #349): after #379 generalized the processor machinery, the generic layer moves out of the processor module (simple-builders' builder domain) into four new Maven artifacts — every move done via git mv (one commit per move) so git log --follow keeps history.

New modules under io.github.java-helpers.codegen (0.7.0-SNAPSHOT):

  • codegen-core — javax-free codegen contract: codegen.model.{type,method,javadoc,imports,core,annotation,integration}, codegen.util.ImportCollector, codegen.enums (mirrors of AccessModifier/OptionState/FormattingMode so codegen carries no simple-builders-core dependency; OptionValueParsers already was the string→enum boundary), the SPI (ClassCodeGenerator, SourceFormatter, GenerationEnvironment, GeneratedSourceFile, GenerationIssueReporter, GenerationPhases, FormatterResolver, CodeGenerationException) and codegen.logging (ProcessingLogger contract, SinkProcessingLogger + MessageSink, PerformanceTracker/ActivePerformanceTracker/NoOpPerformanceTracker, PhaseHierarchy)
  • codegen-roaster — codegen.roaster backend (RoasterCodeGenerator, RoasterMapper, RoasterSourceFormatter, SourceFormatterResolver) plus the bundled eclipse-java-format.xml profile. Depends only on codegen-core — it is the first drop-in generator; a codegen-processor-optimized can follow later
  • simple-processor — the javax-bound generic processor layer: codegen.processing (driver, CodegenTask, ElementCollector/ElementGroups/ElementSelector, ProcessorOptionRegistry, CodegenProcessorConfiguration, AnnotationProcessingContext, AnnotationProcessingOptions, AnnotationProcessingEnvironment, MessagerProcessingLogger), codegen.analysis (JavaLangAnalyser, JavaLangMapper, TypeMappingContext, TypeNameAnalyser, FieldAnnotationExtractor, GeneratedTypes). Wires codegen-roaster directly for now — the driver's createGenerator/createFormatterResolver hooks are where a drop-in mechanism lands later
  • codegen-testing — codegen.testing: ProcessorAsserts, ProcessingEnvironmentStub, CapturingProcessingLogger, FormatterProfileTestUtils (compile-testing re-exported). Depends only on codegen-core

Dependency direction is simple-builder → simple-processor → codegen-roaster → codegen-core (+ codegen-testing as test-scoped leaf): codegen links to nothing in simple-builders — in future it will be the opposite. BuilderScopeResolver, OptionValueParsers, the builder model and all of generators/mapstruct/builder plumbing stay in simple-builder.

Notable wiring:

  • The two javax-bound types that pinned the SPI above the backends were split over the boundary: GenerationEnvironment is now a javax-free interface in codegen-core (logger/tracker/reporter + createSourceFile via the new GeneratedSourceFile handle) with AnnotationProcessingEnvironment as the javax impl; ProcessingLogger is a javax-free interface with the formatting moved to SinkProcessingLogger (MessageSink output) and MessagerProcessingLogger as the Messager impl. Rename commits keep git log --follow lineage on the impl sides (SinkProcessingLogger ← ProcessingLogger, AnnotationProcessingEnvironment ← GenerationEnvironment)
  • Dependency-free unit tests moved with their classes. Tests needing both simple-builder internals and codegen classes stay in the processor test tree under their new org.javahelpers.codegen.* packages (MinimalCodegenProcessorTest, ActivePerformanceTrackerTest, …) — Maven forbids a simple-processor → codegen-testing edge even test-scoped
  • META-INF/services unchanged — RoasterCodeGenerator is wired explicitly via createGenerator/createFormatterResolver defaults; the Generator SPI stays simple-builder's own
  • sonar.*/codecov wiring (pom, sonar-project.properties, maven.yml, fork-sonar.yml) covers all modules; release workflow ships all artifacts in dep order (-pl core,codegen-core,codegen-roaster,simple-processor,codegen-testing,processor)
  • License prerequisites landed separately in ci: extend dependency-review license exemptions for codegen module deps #385 (ECL-2.0 on allow-licenses, purl exemptions for javadoc/site-plugin + compile-scoped junit)

Verification

  • mvn clean install: all 9 modules green
  • Regenerated example/generated-example-builder is byte-identical (git status clean after regen against installed artifacts)

Closes #349. Preparatory work for #363 (own repository), #364 (perf-optimized backend), #365 (shaded consumption), #366 (backend priority).

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Dependency Review

The following issues were found:

  • ✅ 0 vulnerable package(s)
  • ❌ 12 package(s) with incompatible licenses
  • ✅ 0 package(s) with invalid SPDX license definitions
  • ⚠️ 8 package(s) with unknown licenses.

View full job summary

@devin-ai-integration
devin-ai-integration Bot force-pushed the devin/1792742307-simple-codegen-moves branch 2 times, most recently from d75412b to bd7f0c9 Compare October 24, 2026 11:18
@igel-devin-ai igel-devin-ai changed the title codegen: extract simple-codegen + simple-codegen-roaster modules (phase 1) codegen: extract codegen-core + codegen-roaster modules (phase 1) Oct 25, 2026
@igel-devin-ai

Copy link
Copy Markdown
Contributor Author

Heads-up on ordering: this move waits for #378 / PR #379 (the generic AbstractCodegenProcessor driver landing inside processor first). After that merges, this branch gets reworked to carry a third artifact — io.github.java-helpers.codegen:annotation-processing — alongside codegen-core and codegen-roaster, split at the javax.lang.model boundary (context/options/analysis + driver on the JSR-269 side; model/enums/SPI javax-free on the other).

Details on issue #349.

@devin-ai-integration
devin-ai-integration Bot force-pushed the devin/1792742307-simple-codegen-moves branch 2 times, most recently from 5ae4941 to 55e3959 Compare November 1, 2026 14:34
…enums so codegen has no simple-builders dependency
@devin-ai-integration
devin-ai-integration Bot force-pushed the devin/1792742307-simple-codegen-moves branch from 4d0abee to 88c3ff4 Compare November 1, 2026 15:20
@igel-devin-ai igel-devin-ai changed the title codegen: extract codegen-core + codegen-roaster modules (phase 1) codegen: extract codegen modules (codegen-core, codegen-roaster, simple-processor, codegen-testing) Nov 4, 2026
* TypeMappingContext gains shouldSkipAnnotation hook; FieldAnnotationExtractor's
  hardcoded org.javahelpers.simple.builders filter moves to BuilderProcessingContext
* rename record components to domain-neutral names: JacksonModuleEntryDto.builderType
  -> generatedType, TypeInstantiation.PrefillCall.funcForEmptyBuilder -> funcForEmptyInstance
* generic wording in javadoc, package-infos and log/error messages ('target',
  'enhancer', 'generated type'); fix malformed and outdated package-infos
* CONTRIBUTING project tree lists the codegen modules
@codecov

codecov Bot commented Nov 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

devin-ai-integration Bot and others added 18 commits November 4, 2026 22:41
Drop the TypeMappingContext.shouldSkipAnnotation hook again: FieldAnnotationExtractor
keeps only its generic filters, and BuilderDefinitionCreator strips simple-builders
framework annotations when it populates the BuilderFieldDto (parameter annotations
and type-use annotations on the field type). The domain owns its skip list at the
point where domain DTOs are created.
Move the type-annotation strip up to field.setFieldType(fieldType) — the point
where the mapped type's annotations enter the BuilderFieldDto.
… covers all modes

The resolver existed to pick a formatter implementation per mode, but a single RoasterSourceFormatter handles NONE/LIGHTWEIGHT/JDT internally now. The driver caches one formatter per mode directly; createFormatter(mode, profile) stays the domain's extension point. Also drops the dead FormattingMode enum in simple-builders core — codegen-core's enum is the only one still referenced.
Installing only simple-builders-processor no longer satisfies the example's annotationProcessorPaths — the processor now depends on the codegen SNAPSHOTs and the path also lists example-custom-generator. Prescribe -am so the upstream modules land in ~/.m2 too.
…ingBuilder.toString

CompilerArgumentsEnum implements the extracted CompilerOption interface — getOptionName/getCompilerArgument lacked the marker; ConfigToStringBuilder.toString overrides Object.
Four tests declared org.javahelpers.simple.builders.processor.processing while sitting in org/javahelpers/codegen/processing/ — leftover of the codegen moves. They exercise classes of org.javahelpers.codegen.processing, so the declaration follows the directory; also fixes the self-FQCN inside MinimalCodegenProcessorTest's embedded source.
The annotation is commented out pending issue java-helpers#132 — the import was orphaned.
Rename methods in the generic simple-processor analysis layer to remove
builder-specific vocabulary, making the API suitable for reuse by other
code-generation processors (serializers, mappers, proxies, etc.):

- createBuilderTypeName → createDerivedTypeName
- findAllPossibleSettersOfClass → findSetterMethods
- findFieldFunctions → findSingleParameterMethods
- findConstructorForBuilder → findPrimaryConstructor

Update all callers in BuilderScopeResolver, BuilderDefinitionCreator,
and MinimalCodegenProcessorTest. Javadocs rewritten to describe the
generic operations rather than builder-specific use cases.
Add CodegenBackend interface (codegen-core) that pairs a ClassCodeGenerator
with its matching SourceFormatter, enforcing at the type level that the
two are always swapped together.

RoasterBackend (codegen-roaster) implements the interface, bundling
RoasterCodeGenerator and RoasterSourceFormatter with per-mode caching.

CodegenBackendResolver (simple-processor) selects the backend and assembles
the GenerationEnvironment internally — currently returns RoasterBackend
directly; will probe the classpath in a future iteration (java-helpers#366).

AbstractCodegenProcessor has zero Roaster imports and no longer exposes
GenerationEnvironment in its API.
- FormattingMode: replace Roaster-specific toUnformattedString() references
  with backend-neutral formatting descriptions
- OptionState: replace @SimpleBuilder.Options example with domain-neutral
  annotation example
- AnnotationProcessingContext: remove downstream BuilderProcessingContext
  link; use generic verbose option example
- CompilerOption: replace simplebuilder.* prefix with generic domain prefix
- PipelinePhases: replace "builder processing pipeline" with generic
  "code-generation processing pipeline"
- FormattingMode: replace Roaster-specific toUnformattedString() references
  with backend-neutral formatting descriptions
- OptionState: replace @SimpleBuilder.Options example with domain-neutral
  annotation example
- AnnotationProcessingContext: remove downstream BuilderProcessingContext
  link; use generic verbose option example
- CompilerOption: replace simplebuilder.* prefix with generic domain prefix
- PipelinePhases: replace "builder processing pipeline" with generic
  "code-generation processing pipeline"
…ation skips to DTO creation

* new CodegenTestUtils in codegen-testing: createCompiler(Processor...), warning
  assertion, diagnostics/generated-source printing, forSource, loadGeneratedSource,
  createMockAnnotation — domain-agnostic compile-testing machinery
* ProcessorTestUtils shrinks to the simple-builders shim: BuilderProcessor wiring,
  @SimpleBuilder source fixtures and the simplebuilder.verbose flag; everything else
  delegates to CodegenTestUtils
* FieldAnnotationExtractor keeps only generation/compiler-metadata filters
  (@generated, @SuppressWarnings); @deprecated and @Valid move to the domain's
  skip predicate at BuilderFieldDto creation (SKIPPED_COPIED_ANNOTATIONS)
@sonarqubecloud

sonarqubecloud Bot commented Nov 9, 2026

Copy link
Copy Markdown

@AndreasIgel
AndreasIgel merged commit 6221293 into java-helpers:main Nov 9, 2026
6 checks passed
@devin-ai-integration
devin-ai-integration Bot deleted the devin/1792742307-simple-codegen-moves branch November 22, 2026 14:24
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.

Move generic classes into codegen + codegen-roaster modules (phase 1)

3 participants