Skip to content

Commit

Permalink
follow up of junit-team#2544 to enable a fully resolveable OSGi solution
Browse files Browse the repository at this point in the history
What this means is that merely by consuming the Jupiter client APIs results in requiring a fully fleshed out runtime including launcher as follows
- junit-jupiter-api & junit-jupiter-params Requires a org.junit.platform.engine=junit-jupiter
- junit-jupiter-engine Provides org.junit.platform.engine=junit-jupiter
- junit-vintage-engine Provides org.junit.platform.engine=junit-vintage
- junit-jupiter-engine & junit-vintage-engine Requires org.junit.platform.launcher=junit-platform-launcher
- junit-platform-launcher Provides org.junit.platform.launcher=junit-platform-launcher

The solution is solvable by consuming junit-jupiter-api & junit-jupiter-params in your tests OR in the case of vintage
having @requirement(namespace = "org.junit.platform.engine", name = "junit-vintage")

Signed-off-by: Raymond Augé <raymond.auge@liferay.com>
  • Loading branch information
rotty3000 committed Oct 28, 2021
1 parent d438955 commit a417fe0
Show file tree
Hide file tree
Showing 18 changed files with 95 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ on GitHub.

==== New Features and Improvements

*
* JUnit OSGi bundles now contain `engine` and `launcher` requirements ensuring that at resolution time a fully running set of dependencies are calculated avoiding the need for these to be manually specified.


[[release-notes-5.9.0-M1-junit-jupiter]]
Expand Down
16 changes: 16 additions & 0 deletions junit-jupiter-api/junit-jupiter-api.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,20 @@ dependencies {
compileOnlyApi(libs.apiguardian)

compileOnly(kotlin("stdlib"))

osgiVerification(projects.junitJupiterEngine)
osgiVerification(projects.junitPlatformLauncher)
}

tasks {
jar {
bundle {
bnd("""
Require-Capability:\
org.junit.platform.engine;\
filter:='(&(org.junit.platform.engine=junit-jupiter)(version>=${'$'}{version_cleanup;${rootProject.property("version")!!}})(!(version>=${'$'}{versionmask;+;${'$'}{version_cleanup;${rootProject.property("version")!!}}})))';\
effective:=active
""")
}
}
}
6 changes: 6 additions & 0 deletions junit-jupiter-engine/junit-jupiter-engine.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ dependencies {
testImplementation(libs.junit4)
testImplementation(libs.kotlinx.coroutines)
testImplementation(libs.groovy4)

osgiVerification(projects.junitPlatformLauncher)
}

tasks {
Expand All @@ -39,6 +41,10 @@ tasks {
org.junit.platform.engine;\
org.junit.platform.engine='junit-jupiter';\
version:Version="${'$'}{version_cleanup;${project.version}}"
Require-Capability:\
org.junit.platform.launcher;\
filter:='(&(org.junit.platform.launcher=junit-platform-launcher)(version>=${'$'}{version_cleanup;${rootProject.property("platformVersion")!!}})(!(version>=${'$'}{versionmask;+;${'$'}{version_cleanup;${rootProject.property("platformVersion")!!}}})))';\
effective:=active
""")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ dependencies {
testImplementation(projects.junitPlatformLauncher)
testImplementation(projects.junitPlatformSuiteEngine)
testImplementation(projects.junitPlatformTestkit)

osgiVerification(projects.junitJupiterEngine)
osgiVerification(projects.junitPlatformLauncher)
}

tasks.jar {
Expand Down
16 changes: 16 additions & 0 deletions junit-jupiter-params/junit-jupiter-params.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,22 @@ dependencies {

compileOnly(kotlin("stdlib"))
testImplementation(kotlin("stdlib"))

osgiVerification(projects.junitJupiterEngine)
osgiVerification(projects.junitPlatformLauncher)
}

tasks {
jar {
bundle {
bnd("""
Require-Capability:\
org.junit.platform.engine;\
filter:='(&(org.junit.platform.engine=junit-jupiter)(version>=${'$'}{version_cleanup;${rootProject.property("version")!!}})(!(version>=${'$'}{versionmask;+;${'$'}{version_cleanup;${rootProject.property("version")!!}}})))';\
effective:=active
""")
}
}
}

tasks {
Expand Down
3 changes: 3 additions & 0 deletions junit-jupiter/junit-jupiter.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@ dependencies {
api(projects.junitJupiterParams)

runtimeOnly(projects.junitJupiterEngine)

osgiVerification(projects.junitJupiterEngine)
osgiVerification(projects.junitPlatformLauncher)
}
3 changes: 3 additions & 0 deletions junit-platform-console/junit-platform-console.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ dependencies {
compileOnlyApi(libs.apiguardian)

shadowed(libs.picocli)

osgiVerification(projects.junitJupiterEngine)
osgiVerification(projects.junitPlatformLauncher)
}

tasks {
Expand Down
3 changes: 3 additions & 0 deletions junit-platform-engine/junit-platform-engine.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@ dependencies {
compileOnlyApi(libs.apiguardian)

testImplementation(libs.assertj)

osgiVerification(projects.junitJupiterEngine)
osgiVerification(projects.junitPlatformLauncher)
}
3 changes: 3 additions & 0 deletions junit-platform-jfr/junit-platform-jfr.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ dependencies {
api(projects.junitPlatformLauncher)

compileOnlyApi(libs.apiguardian)

osgiVerification(projects.junitJupiterEngine)
osgiVerification(projects.junitPlatformLauncher)
}

javaLibrary {
Expand Down
15 changes: 15 additions & 0 deletions junit-platform-launcher/junit-platform-launcher.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,19 @@ dependencies {
api(projects.junitPlatformEngine)

compileOnlyApi(libs.apiguardian)

osgiVerification(projects.junitJupiterEngine)
}

tasks {
jar {
bundle {
bnd("""
Provide-Capability:\
org.junit.platform.launcher;\
org.junit.platform.launcher='junit-platform-launcher';\
version:Version="${'$'}{version_cleanup;${project.version}}"
""")
}
}
}
3 changes: 3 additions & 0 deletions junit-platform-reporting/junit-platform-reporting.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ dependencies {
api(projects.junitPlatformLauncher)

compileOnlyApi(libs.apiguardian)

osgiVerification(projects.junitJupiterEngine)
osgiVerification(projects.junitPlatformLauncher)
}
3 changes: 3 additions & 0 deletions junit-platform-runner/junit-platform-runner.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ dependencies {

testImplementation(testFixtures(projects.junitPlatformEngine))
testImplementation(testFixtures(projects.junitPlatformLauncher))

osgiVerification(projects.junitJupiterEngine)
osgiVerification(projects.junitPlatformLauncher)
}

tasks.jar {
Expand Down
3 changes: 2 additions & 1 deletion junit-platform-suite-api/junit-platform-suite-api.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ dependencies {

compileOnlyApi(libs.apiguardian)

osgiVerification(projects.junitPlatformCommons)
osgiVerification(projects.junitJupiterEngine)
osgiVerification(projects.junitPlatformLauncher)
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,7 @@ dependencies {

implementation(projects.junitPlatformEngine)
implementation(projects.junitPlatformSuiteApi)

osgiVerification(projects.junitJupiterEngine)
osgiVerification(projects.junitPlatformLauncher)
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,7 @@ dependencies {
compileOnlyApi(libs.apiguardian)

implementation(projects.junitPlatformSuiteCommons)

osgiVerification(projects.junitJupiterEngine)
osgiVerification(projects.junitPlatformLauncher)
}
3 changes: 3 additions & 0 deletions junit-platform-suite/junit-platform-suite.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ dependencies {
api(platform(projects.junitBom))
api(projects.junitPlatformSuiteApi)
implementation(projects.junitPlatformSuiteEngine)

osgiVerification(projects.junitJupiterEngine)
osgiVerification(projects.junitPlatformLauncher)
}
3 changes: 3 additions & 0 deletions junit-platform-testkit/junit-platform-testkit.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@ dependencies {
api(projects.junitPlatformLauncher)

compileOnlyApi(libs.apiguardian)

osgiVerification(projects.junitJupiterEngine)
osgiVerification(projects.junitPlatformLauncher)
}
6 changes: 6 additions & 0 deletions junit-vintage-engine/junit-vintage-engine.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ dependencies {
testImplementation(projects.junitPlatformLauncher)
testImplementation(projects.junitPlatformSuiteEngine)
testImplementation(projects.junitPlatformTestkit)

osgiVerification(projects.junitPlatformLauncher)
}

tasks {
Expand Down Expand Up @@ -51,6 +53,10 @@ tasks {
org.junit.platform.engine;\
org.junit.platform.engine='junit-vintage';\
version:Version="${'$'}{version_cleanup;${project.version}}"
Require-Capability:\
org.junit.platform.launcher;\
filter:='(&(org.junit.platform.launcher=junit-platform-launcher)(version>=${'$'}{version_cleanup;${rootProject.property("platformVersion")!!}})(!(version>=${'$'}{versionmask;+;${'$'}{version_cleanup;${rootProject.property("platformVersion")!!}}})))';\
effective:=active
""")
}
}
Expand Down

0 comments on commit a417fe0

Please sign in to comment.