experiment: leverage BuildContext API for incremental JAR creation - #566
Draft
gnodet wants to merge 2 commits into
Draft
experiment: leverage BuildContext API for incremental JAR creation#566gnodet wants to merge 2 commits into
gnodet wants to merge 2 commits into
Conversation
Integrate the Maven 4 BuildContext API to skip JAR creation when no input files have changed since the last build. When forceCreation is false and the JAR file already exists, the plugin now registers and scans the classes directory via BuildContext.registerAndProcessInputs() and skips re-packaging if all inputs are UNMODIFIED. Also signals markSkipExecution() at all skip points (skipIfEmpty, unchanged inputs) so downstream mojos can react accordingly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace the ad-hoc hasChangedInputs() check with the BuildContext InputSet aggregation pattern. This correctly registers all class files as inputs, associates them with the JAR output file, and lets the build context handle stale output cleanup when inputs are removed. Previously, inputs were registered via registerAndProcessInputs() but the JAR was never associated as an output — breaking the input→output tracking that enables BuildContext's stale output cleanup. The aggregate() pattern is the correct fit for many-inputs-to-one-output transformations like JAR packaging. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
forceCreationis false and the JAR file already exists, the plugin registers and scans the classes directory viaBuildContext.registerAndProcessInputs()and skips re-packaging if all inputs areUNMODIFIEDmarkSkipExecution()at all skip points (skipIfEmpty, unchanged inputs) so downstream mojos can react accordinglyDetails
This is an experimental branch that depends on:
4.1.0-SNAPSHOT)Changes
AbstractJarMojo.java: Added@Inject BuildContext buildContextfield,hasChangedInputs()method that usesregisterAndProcessInputs()to detect file changes, andattachArtifact()helper. Theexecute()method now checks for changed inputs before creating the JAR.TestJarMojo.java: AddedmarkSkipExecution()in the skip branchJarMojoTest.java: Updated test imports to neworg.apache.maven.testing.pluginpackage, added@Providesmethods forBuildContextandPathMatcherFactorypom.xml: BumpedmavenVersionto4.1.0-SNAPSHOTTest plan
🤖 Generated with Claude Code