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
BundleTaskExtension$BuildAction
adds undeclared inputs to jar
tasks
#5279
Milestone
Comments
ben-manes
added a commit
to ben-manes/caffeine
that referenced
this issue
Jun 8, 2022
The gradle-build-action uses read only caching on dev branches and produces a job summary. This causes some noise and slow down, so revert to the old behavior. The bnd plugin does not declare its inputs so task caching for a snapshot/release jar can produce incorrect OSGi version metadata. The version is now an explicit input to avoid this mistake. Fixes #728 (bndtools/bnd#5279)
bjhargrave
added a commit
to bjhargrave/bnd
that referenced
this issue
Jun 14, 2022
If Bundle-SymbolicName and/or Bundle-Version are not specified in the bnd instructions, then BundleTaskExtension will set default values based upon the Jar task's archiveBaseName, archiveClassifier, and archiveVersion properties. However, these Jar task properties are not considered inputs to the Jar task. They are just considered as parts of the archiveFile property which is an output property. Setting the defaults as input properties means that Gradle will consider them as part of the build cache key. This is important since the values can end up in the build jar's manifest. Fixes bndtools#5279 Signed-off-by: BJ Hargrave <bj@hargrave.dev>
@clayburn Thanks for the bug report. I have a fix PR #5280 for Bnd 6.4. In the meantime, here is a workaround for your build that will work with Bnd 6.3: diff --git a/caffeine/build.gradle b/caffeine/build.gradle
index 260e0e4e..a30284e1 100644
--- a/caffeine/build.gradle
+++ b/caffeine/build.gradle
@@ -87,6 +87,9 @@ tasks.named('jar').configure {
dependsOn compileCodeGenJava
manifest {
attributes 'Bundle-SymbolicName': 'com.github.ben-manes.caffeine'
+ attributes 'Bundle-Version': aQute.bnd.version.MavenVersion.parseMavenString(project.version.toString())
+ .getOSGiVersion()
+ .toString()
attributes 'Import-Package': ''
attributes 'Export-Package': [
'com.github.benmanes.caffeine', |
Awesome, thanks for the quick fix! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Discovered in: ben-manes/caffeine#728. The
BuildAction
class in theBundleTaskExtension
is affecting the output of thejar
task by changing the manifest based on certain properties but not declaring them as inputs.This was noticed in ben-manes/caffeine#728 regarding the
archiveVersion
of thejar
task. In this project, thejar
task was made cacheable. Before that, the task would be considered out of date in the below scenario, since the name of the output file had changed. But when thejar
task is made cacheable, the output file name is not considered as part of the cache key, so an invalid cache hit results in a jar without the newer version.archiveVersion
is just one example in this action. It appears there are other properties in this action that are effectively inputs but are not declared.To reproduce:
./gradlew clean :caffeine:jar
unzip -p caffeine/build/libs/caffeine-3.1.2-SNAPSHOT.jar META-INF/MANIFEST.MF | grep Bundle-Version
Bundle-Version
is3.1.2.SNAPSHOT
./gradlew :caffeine:jar -Prelease
unzip -p caffeine/build/libs/caffeine-3.1.2.jar META-INF/MANIFEST.MF | grep Bundle-Version
Bundle-Version
is still3.1.2.SNAPSHOT
, when the desired outcome is3.1.2
The text was updated successfully, but these errors were encountered: