Skip to content

Commit 287607c

Browse files
authored
Work around bndtools/bnd#5695 by configuring jar tasks eagerly (#3354)
Eagerly configure Jar tasks to create the BundleTaskExtension prior to the Gradle compileClasspath configuration becoming locked and triggering it's beforeLocking callback to run. This allows the BND extension to modify the LibraryElements attribute on that configuration and request a variant with the "jar" value prior to Gradle automatically modifying the attribute to request the "classes" value. This ensures jars are present on the classpath for BND to use when checked for exported classes to use when building the manifest. If it only uses the classes directory for this task, it will not have access to version information and will not write version info to the manifest it is assembling for the current project, causing the verifyOSGi task to fail. Addresses issue bndtools/bnd#5695 and allows merging of #3351.
1 parent c71d671 commit 287607c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

gradle/plugins/common/src/main/kotlin/junitbuild.osgi-conventions.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ val projectDescription = objects.property<String>().convention(provider { projec
1414
// metadata into the jar
1515
tasks.withType<Jar>().matching { task: Jar ->
1616
task.name == "jar" || task.name == "shadowJar"
17-
}.configureEach {
17+
}.all { // configure tasks eagerly as workaround for https://github.com/bndtools/bnd/issues/5695
1818
extra["importAPIGuardian"] = importAPIGuardian
1919

2020
extensions.create<BundleTaskExtension>(BundleTaskExtension.NAME, this).apply {

0 commit comments

Comments
 (0)