Repository navigation
codegen: extract codegen modules (codegen-core, codegen-roaster, simple-processor, codegen-testing) - #368
Conversation
Dependency ReviewThe following issues were found:
|
d75412b to
bd7f0c9
Compare
|
Heads-up on ordering: this move waits for #378 / PR #379 (the generic Details on issue #349. |
5ae4941 to
55e3959
Compare
…n-testing module skeletons
…enums so codegen has no simple-builders dependency
…ocessor (BuilderScopeResolver stays)
4d0abee to
88c3ff4
Compare
* 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 Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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"
…b.com/igel-devin-ai/simple-builders-devin-fork into devin/1792742307-simple-codegen-moves
…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)
|



Summary
Phase 2 of the codegen extraction (#233, subtask #349): after #379 generalized the processor machinery, the generic layer moves out of the
processormodule (simple-builders' builder domain) into four new Maven artifacts — every move done viagit mv(one commit per move) sogit log --followkeeps 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 ofAccessModifier/OptionState/FormattingModeso codegen carries nosimple-builders-coredependency;OptionValueParsersalready was the string→enum boundary), the SPI (ClassCodeGenerator,SourceFormatter,GenerationEnvironment,GeneratedSourceFile,GenerationIssueReporter,GenerationPhases,FormatterResolver,CodeGenerationException) andcodegen.logging(ProcessingLoggercontract,SinkProcessingLogger+MessageSink,PerformanceTracker/ActivePerformanceTracker/NoOpPerformanceTracker,PhaseHierarchy)codegen-roaster—codegen.roasterbackend (RoasterCodeGenerator,RoasterMapper,RoasterSourceFormatter,SourceFormatterResolver) plus the bundledeclipse-java-format.xmlprofile. Depends only oncodegen-core— it is the first drop-in generator; acodegen-processor-optimizedcan follow latersimple-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). Wirescodegen-roasterdirectly for now — the driver'screateGenerator/createFormatterResolverhooks are where a drop-in mechanism lands latercodegen-testing—codegen.testing:ProcessorAsserts,ProcessingEnvironmentStub,CapturingProcessingLogger,FormatterProfileTestUtils(compile-testingre-exported). Depends only oncodegen-coreDependency direction is
simple-builder → simple-processor → codegen-roaster → codegen-core(+codegen-testingas test-scoped leaf): codegen links to nothing in simple-builders — in future it will be the opposite.BuilderScopeResolver,OptionValueParsers, the builder model and all ofgenerators/mapstruct/builder plumbing stay in simple-builder.Notable wiring:
GenerationEnvironmentis now a javax-free interface incodegen-core(logger/tracker/reporter +createSourceFilevia the newGeneratedSourceFilehandle) withAnnotationProcessingEnvironmentas the javax impl;ProcessingLoggeris a javax-free interface with the formatting moved toSinkProcessingLogger(MessageSinkoutput) andMessagerProcessingLoggeras the Messager impl. Rename commits keepgit log --followlineage on the impl sides (SinkProcessingLogger←ProcessingLogger,AnnotationProcessingEnvironment←GenerationEnvironment)processortest tree under their neworg.javahelpers.codegen.*packages (MinimalCodegenProcessorTest,ActivePerformanceTrackerTest, …) — Maven forbids asimple-processor → codegen-testingedge even test-scopedMETA-INF/servicesunchanged —RoasterCodeGeneratoris wired explicitly viacreateGenerator/createFormatterResolverdefaults; theGeneratorSPI stays simple-builder's ownsonar.*/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)ECL-2.0onallow-licenses, purl exemptions for javadoc/site-plugin + compile-scoped junit)Verification
mvn clean install: all 9 modules greenexample/generated-example-builderis byte-identical (git statusclean after regen against installed artifacts)Closes #349. Preparatory work for #363 (own repository), #364 (perf-optimized backend), #365 (shaded consumption), #366 (backend priority).