-
-
Notifications
You must be signed in to change notification settings - Fork 305
Switch to the correct BuildContext API #6797
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
Conversation
052ec84 to
e3905d4
Compare
8e2053a to
1344bbf
Compare
| Files.createDirectories(artifactFile.toPath() | ||
| .getParent()); | ||
| try (OutputStream os = buildContext.newFileOutputStream(artifactFile)) { | ||
| try (CachingOutputStream os = new CachingOutputStream(artifactFile)) { |
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.
Seems like this capability should be part of the build context rather than requiring all plugins to do something like this :-)
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.
This build context (the one you use)? https://github.com/sonatype/sisu-build-api
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.
No, my mistake, sorry, the used one is this https://github.com/codehaus-plexus/plexus-build-api
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.
We use this one:
bnd/maven-plugins/bnd-maven-plugin/src/main/java/aQute/bnd/maven/plugin/AbstractBndMavenPlugin.java
Lines 169 to 170 in a644f2d
| @Component | |
| BuildContext buildContext; |
It is injected by maven.
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 think we're on the wrong track. The default build context should already cache the stream, see https://github.com/codehaus-plexus/plexus-build-api/blob/903ed6c3e9dc767da4f9ac6cf5a22f0324400bbf/src/main/java/org/codehaus/plexus/build/DefaultBuildContext.java#L96-L101
However, multiple successive runs of bad generate different output, for example:
< Export-Package: org.eclipse.aether;uses:="org.eclipse.aether.artifact,
< org.eclipse.aether.collection,org.eclipse.aether.deployment,org.eclip
< se.aether.graph,org.eclipse.aether.installation,org.eclipse.aether.me
< tadata,org.eclipse.aether.repository,org.eclipse.aether.resolution,or
< g.eclipse.aether.scope,org.eclipse.aether.transfer";version="2.0.11",
---
> Export-Package: org.eclipse.aether;version="2.0.11";uses:="org.eclipse
> .aether.artifact,org.eclipse.aether.collection,org.eclipse.aether.dep
> loyment,org.eclipse.aether.graph,org.eclipse.aether.installation,org.
> eclipse.aether.metadata,org.eclipse.aether.repository,org.eclipse.aet
> her.resolution,org.eclipse.aether.scope,org.eclipse.aether.transfer",
is there a way to have a consistent manifest written ?
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.
lack of build idempotency
Not sure if I interpret "idempotency" correctly, but if you are referring to reproducible build outputs maybe have a look at https://bnd.bndtools.org/instructions/reproducible.html and https://bnd.bndtools.org/instructions/noextraheaders.html (also see https://github.com/bndtools/bnd/blob/master/maven-plugins/bnd-maven-plugin/README.md#reproducible-builds )
This is mainly about timestamps.. but I will have a look if it is used for something else.
Question: Whic bnd version are you using here?
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.
@gnodet @cstamas I just remembered a past issue which might be related to your problem (not sure):
#6221 (comment) and the PR #6222
I believe the #6222 should be in bnd 7.1.0 https://github.com/bndtools/bnd/releases/tag/7.1.0
see the deleteExistingManifest option
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.
Sure, but that looks like a work-around. The input looks the same, just the order of clause seems different. Given that has no effect in OSGi, a fix order should be used somehow I think.
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 had a quick look and maaaybe a suspicion:
I noticed that in your debug output above the uses: directive comes first in example A, and then at the end in Example B.
So this means the attributes (Attrs) of the Export-Package parameter (or any) are ordered differently... potentially in insertion-order.
bnd/biz.aQute.bndlib/src/aQute/bnd/osgi/Analyzer.java
Lines 2465 to 2469 in a644f2d
| override = override.substring(1); | |
| if (override.isEmpty()) { | |
| clause.remove(USES_DIRECTIVE); | |
| } else { | |
| clause.put(USES_DIRECTIVE, override); |
And given the comment in
| // Check if someone already set the uses: directive |
It looks like this could be your case where "someone else" is your previous build.
Attrs.java
bnd/biz.aQute.bndlib/src/aQute/bnd/header/Attrs.java
Lines 86 to 88 in a644f2d
| public Attrs() { | |
| this(new LinkedHashMap<>(), new HashMap<>()); | |
| } |
Maybe we should think about using a Treemap instead so that attributes are consistently ordered by key.
Thoughts @bjhargrave @pkriens ?
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.
Or fix where emitted. Isn't that already done?
1344bbf to
96a075c
Compare
Signed-off-by: Guillaume Nodet <[email protected]>
96a075c to
cbdb904
Compare
|
I repurposed this PR to switch to the correct library for BuildContext. |
chrisrueger
left a comment
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.
Given BJ's 👍 and since this change became minimal I think we can give this a try. Thanks a lot for the PR.
This avoids rebuilding the jar when nothing has changed, and in projects with subproject, avoids downstream project recompilations.