-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Move InputLocation/InputLocationTracker/InputSource to velocity templates #10931
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: master
Are you sure you want to change the base?
Move InputLocation/InputLocationTracker/InputSource to velocity templates #10931
Conversation
ce86500
to
c8f3505
Compare
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.
I strongly prefer code to be Java instead of some other random format (here mdo). Given that the Java code already exists, I don;t see why we would want to throw it away in favor of generated code.
The current state is we have 5 times those 3 classes in different packages :
I'd rather avoid duplication, hence this proposal to reduce to a single set of generated classes. I really don't think we should avoid generation and favour duplication instead. It will become a nightmare to maintain. And there's more than just those 15 classes. |
Maven Code Generation Analysis ReportExecutive SummaryThis analysis examines the code generation efficiency in the Apache Maven project, comparing the lines of code (LOC) in input files (MDO model definitions and Velocity templates) versus the generated Java output files. Key FindingsInput Files
Generated Output
Code Generation Ratios
Detailed BreakdownInput Files AnalysisMDO Files (Model Definition Objects)The largest MDO files by line count:
VM Templates (Velocity Templates)The VM templates by complexity:
Generated Files AnalysisBy File Type
By Module (Top Contributors)
Code Generation EfficiencyProductivity Metrics
Template EfficiencyEach VM template serves a specific purpose:
Conclusions
Recommendations
Analysis performed on Apache Maven codebase - maven-4.0.x branch |
c8f3505
to
7ba539f
Compare
…ates This PR moves the InputLocation, InputLocationTracker, and InputSource classes from maven-api-model to be generated using the existing velocity templates in src/mdo/java/. Changes Made: - Updated Velocity Templates with Maven-specific features controlled by isMavenModel parameter - Added locationTracking=true and generateLocationClasses=true parameters to maven-api-model configuration - Removed manually written InputLocation classes from api/maven-api-model/src/main/java/org/apache/maven/api/model/ Benefits: - Consistency: InputLocation classes are now generated consistently across all Maven modules - Maintainability: Changes can be made in one place (the templates) rather than maintaining separate implementations - Feature Parity: All Maven-specific features are preserved through the isMavenModel boolean parameter - Code Reuse: The same templates can generate both simple and Maven-enhanced versions
7ba539f
to
4bf95a4
Compare
Summary
This PR moves the InputLocation, InputLocationTracker, and InputSource classes from maven-api-model to be generated using the existing velocity templates in
src/mdo/java/
.Changes Made
Updated Velocity Templates
InputLocation.java: Added Maven-specific features controlled by
isMavenModel
parameter:importedFrom
field and constructor supporttoString()
format usingString.format()
getImportedFrom()
method implementationInputLocationTracker.java: Added Maven-specific
getImportedFrom()
method whenisMavenModel=true
InputSource.java: Added Maven-specific features:
modelId
field and related constructorsinputs
collection for merged sourcesimportedFrom
fieldequals()
,hashCode()
, andtoString()
methodsmerge()
static method for combining sourcesRemoved Manual Classes
api/maven-api-model/src/main/java/org/apache/maven/api/model/
Benefits
isMavenModel
boolean parameterTesting
mvn clean install -DskipTests
The implementation uses the existing
isMavenModel
boolean parameter pattern that was already established in the codebase, ensuring consistency with the existing approach for handling differences between Maven and other model types.