Skip to content

Commit 44c9609

Browse files
committed
Polish OSGi build checks
- Run verifyOSGi later (as part of check) - Use custom osgiVerification configuration instead of testRuntimeClasspath - Rename verifyOSGiProperties task to osgiProperties
1 parent 8448534 commit 44c9609

File tree

5 files changed

+24
-14
lines changed

5 files changed

+24
-14
lines changed

buildSrc/src/main/kotlin/junit4-compatibility.gradle.kts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ dependencies {
1919
strictly("4.12")
2020
}
2121
}
22-
testRuntimeOnly("org.apache.servicemix.bundles:org.apache.servicemix.bundles.junit:4.12_1")
22+
pluginManager.withPlugin("osgi-conventions") {
23+
"osgiVerification"("org.apache.servicemix.bundles:org.apache.servicemix.bundles.junit:4.12_1")
24+
}
2325
}
2426

2527
tasks {

buildSrc/src/main/kotlin/osgi-conventions.gradle.kts

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,41 +61,49 @@ tasks.withType<Jar>().matching {
6161
// Do the actual work putting OSGi stuff in the jar.
6262
btc.buildBundle()
6363
}
64-
65-
finalizedBy("verifyOSGi")
6664
}
6765

66+
val osgiPropertiesFile = file("$buildDir/verifyOSGiProperties.bndrun")
67+
6868
// Bnd's Resolve task uses a properties file for it's configuration. This
6969
// task writes out the properties necessary for it to verify the OSGi
7070
// metadata.
71-
tasks.register<WriteProperties>("verifyOSGiProperties") {
72-
setOutputFile("${buildDir}/verifyOSGiProperties.bndrun")
73-
property("-standalone", "true")
71+
val osgiProperties by tasks.registering(WriteProperties::class) {
72+
outputFile = osgiPropertiesFile
73+
property("-standalone", true)
7474
property("-runee", "JavaSE-${Versions.jvmTarget}")
7575
property("-runrequires", "osgi.identity;filter:='(osgi.identity=${project.name})'")
7676
property("-runsystempackages", "jdk.internal.misc,sun.misc")
7777
}
7878

79+
val osgiVerification by configurations.creating {
80+
extendsFrom(configurations.runtimeClasspath.get())
81+
}
82+
7983
// Bnd's Resolve task is what verifies that a jar can be used in OSGi and
8084
// that it's metadata is valid. If the metadata is invalid this task will
8185
// fail.
82-
tasks.register<Resolve>("verifyOSGi") {
83-
dependsOn("verifyOSGiProperties")
84-
setBndrun("${buildDir}/verifyOSGiProperties.bndrun")
86+
val verifyOSGi by tasks.registering(Resolve::class) {
87+
dependsOn(osgiProperties)
88+
setBndrun(osgiPropertiesFile)
8589
isReportOptional = false
8690
withConvention(FileSetRepositoryConvention::class) {
8791

8892
// By default bnd will use jars found in:
8993
// 1. project.sourceSets.main.runtimeClasspath
9094
// 2. project.configurations.archives.artifacts.files
9195
// to validate the metadata.
92-
// This adds jars defined in `testRuntimeClasses` also so that bnd
96+
// This adds jars defined in `osgiVerification` also so that bnd
9397
// can use them to validate the metadata without causing those to
9498
// end up in the dependencies of those projects.
95-
bundles(sourceSets["test"].runtimeClasspath)
99+
bundles(osgiVerification)
96100
}
97101
}
98102

103+
tasks.check {
104+
dependsOn(verifyOSGi)
105+
}
106+
99107
// The ${project.description}, for some odd reason, is only available
100108
// afterEvaluate.
101109
afterEvaluate {

junit-platform-console-standalone/junit-platform-console-standalone.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ tasks {
7979
// (org.junit.platform.console.ConsoleLauncherToolProvider which implements
8080
// java.util.spi.ToolProvider which is @since 9).
8181
// So in order to resolve this, it can only run on Java 9
82-
verifyOSGiProperties {
82+
osgiProperties {
8383
property("-runee", "JavaSE-9")
8484
}
8585
}

junit-platform-console/junit-platform-console.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ tasks {
4747
// (org.junit.platform.console.ConsoleLauncherToolProvider which implements
4848
// java.util.spi.ToolProvider which is @since 9).
4949
// So in order to resolve this, it can only run on Java 9
50-
verifyOSGiProperties {
50+
osgiProperties {
5151
property("-runee", "JavaSE-9")
5252
}
5353
}

junit-platform-suite-api/junit-platform-suite-api.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ dependencies {
99

1010
api("org.apiguardian:apiguardian-api:${Versions.apiGuardian}")
1111

12-
testRuntimeOnly(project(":junit-platform-commons"))
12+
osgiVerification(project(":junit-platform-commons"))
1313
}

0 commit comments

Comments
 (0)