Speed up workspace compilation e.g. in Eclipse - New -rebuildtriggerpolicy instruction to avoid unnecessary rebuild cascades#7209
Open
chrisrueger with Copilot wants to merge 2 commits into
Open
Conversation
Copilot created this pull request from a session on behalf of
chrisrueger
April 18, 2026 08:49
View session
Contributor
|
First experiments in my larger project look very promising. Simple java changes which do not change public API or the manifest do not cause a downstream rebuild cascade. Only e.g. changes to interfaces , method signatures etc. would cause a downstream rebuild of dependant projects like before. This makes development nicer since it cuts down waiting time a lot. |
Contributor
|
@peterkir FYI Let's discuss next week. |
After building a project's JAR, compute a timeless content digest and compare with the previously stored digest. If the content is unchanged, preserve the old JAR's timestamp. This prevents dependent projects from seeing a newer timestamp and triggering unnecessary rebuilds. The optimization uses Jar.getTimelessDigest() which ignores build-time-specific data (BND_LASTMODIFIED, version qualifier) to determine if the meaningful content has changed. A .digest sidecar file stores the hex digest alongside each build output. Agent-Logs-Url: https://github.com/bndtools/bnd/sessions/662b413c-3754-4104-a50f-cb8503721220 Signed-off-by: Christoph Rueger <chrisrueger@gmail.com> Co-Authored-By: chrisrueger <188422+chrisrueger@users.noreply.github.com>
bb790c6 to
8ec68dc
Compare
Adds a new 'Rebuild Trigger Policy' dropdown to the Bnd Build preferences page, letting users choose between 'Always rebuild' and 'API-based (skip if API unchanged)' without editing cnf/build.bnd. Signed-off-by: Christoph Rueger <chrisrueger@gmail.com>
chrisrueger
reviewed
Jun 29, 2026
| RebuildTriggerPolicyResult doRebuildTriggerPolicy(Processor proc, Jar jar, File outputFile) { | ||
| String rebuildTriggerPolicy = proc.get(Constants.REBUILDTRIGGERPOLICY, ALWAYS); | ||
| if (ALWAYS.equals(rebuildTriggerPolicy)) { | ||
| String rebuildTriggerPolicy = proc.get(Constants.REBUILDTRIGGERPOLICY, |
Contributor
There was a problem hiding this comment.
@chrisrueger
Idea: also define a SystemProperty which can override the instruction.
Why? Then Eclipse Preferences (or CI) could set this to override whatever is in build.bnd
This would make the Eclipse Pref. switch behavior more predictable.
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.
This pull request introduces a new build optimization to the bnd build system, allowing projects to avoid unnecessary rebuilds of dependent artifacts when the output JAR's content or exported API has not changed. The feature is controlled by a new
-rebuildtriggerpolicyproperty, which can be set to eitheralways(the default) orapi. When set toapi, the system preserves the JAR's timestamp if the content or exported API is unchanged, thereby preventing downstream rebuild cascades. The implementation includes content and API digest calculation and storage, as well as comprehensive tests validating the new behavior.Eclipse bndtools Preference
There is a new bndtools Preference setting in Eclipse, which can override the
-rebuildtriggerpolicy:incnf/build.bnd. That means you can also use the feature without touchingcnf/build.bndat all.Testing the value via
cnf/build.bnd/cnf/build.bndor to tie it only to Eclipse builds
Press Refresh Bnd Workspace button
rebuild the whole workspace (e.g. clean all just once)
Go to a Bundle A of your choise which has many downstream bundles which depend on A (usually some util bundle at the root of the bundle hiearchy which is used by every bundle)
Pick a random java method and add a
System.out.println("hello");Save the file
Expected result:
Expected result:
Previous bahavior before this PR:
If you remove
-rebuildtriggerpolicyfrombuild.bndif should behave as before this PR - all downstream projects should be build with each change all the time.Key changes:
Build Optimization: Content/API Digest and Timestamp Preservation
RebuildTriggerPolicymechanism inProject.java, which determines whether to preserve the build artifact's timestamp based on content or API digests. This prevents unnecessary downstream rebuilds when the output JAR is unchanged or only non-API changes occurred. The policy supportsalways(default) andapimodes, with digest files (.digestand.api-digest) used for comparison. [1] [2] [3]Configuration and Documentation
-rebuildtriggerpolicyproperty toConstants.javaand included it in the recognized options set. [1] [2]Syntax.java.Testing
ProjectTest.javato verify:Dependency and Import Updates
Project.java. [1] [2] [3] [4] [5]