Sebastian Schuberth
04/12/2025, 11:11 AMmain
, but which uses junit-platform-console
to create a distribution that, when run, executes all (functional) tests? In essence, I want to be able to run functional tests without Gradle.Vampire
04/12/2025, 1:56 PMjunit-platform-console
and declare org.junit.platform.console.ConsoleLauncher
as main class, that's it.Adam
04/12/2025, 2:10 PMSebastian Schuberth
04/12/2025, 5:28 PMfunTest
or integTest
.Vampire
04/12/2025, 11:55 PMmain
source set and you have a dedicated project for those tests.Sebastian Schuberth
04/13/2025, 7:48 AMapplication
plugin just seemed like the natural choice to me to create a new CLI Gradle module that puts all functional tests from all funTest
source set from my multi-module project into its runtime classpath.Sebastian Schuberth
04/13/2025, 7:53 AMfunTest
classpaths from all projects in the multi-project in order to add them to the runtime classpath of the test launcher... any hints there?Vampire
04/13/2025, 9:38 AMVampire
04/13/2025, 9:39 AMSebastian Schuberth
04/13/2025, 9:45 AMconfigurations.dependencyScope("allTests")
configurations["runtimeOnly"].extendsFrom(configurations["allTests"])
rootProject.allprojects.forEach { project ->
project.tasks.withType<Test>().matching { it.name == "funTest" }.configureEach {
configurations["allTests"].asFileTree.plus(classpath)
}
}
but this does not seem to find any tests.Vampire
04/13/2025, 5:04 PMVampire
04/13/2025, 5:05 PMSebastian Schuberth
05/13/2025, 2:13 PMimplementation(project(":plugins:package-managers:node-package-manager")) {
capabilities {
// Note that this uses kebab-case although "registerFeature()" uses camelCase, see
// <https://github.com/gradle/gradle/issues/31362>.
@Suppress("UnstableApiUsage")
requireFeature("fun-test")
}
}
I'd like an implementation dependency on all subprojects with that feature. Any hints?Vampire
05/13/2025, 2:19 PMSebastian Schuberth
05/13/2025, 2:21 PMSebastian Schuberth
05/13/2025, 2:22 PMOr you make sure that all projects do have that feature, even if it produces an empty artifact and then just depend on all projects or sub projects.Ah, wait that's still an option. So how do I depend on all subprojects?
Sebastian Schuberth
05/13/2025, 2:23 PMimplementation(rootProject.subprojects)
does not work.Sebastian Schuberth
05/13/2025, 2:27 PMafterEvaluate {
rootProject.subprojects.findAll { subproject ->
subproject != project &&
subproject.plugins.hasPlugin('java-library')
}.each { libraryProject ->
dependencies {
implementation project(libraryProject.path)
}
}
}
Vampire
05/13/2025, 2:31 PMVampire
05/13/2025, 2:32 PMSebastian Schuberth
05/13/2025, 2:32 PMVampire
05/13/2025, 2:32 PMrootProject.subprojects.forEach { implementation(it) }
Sebastian Schuberth
05/13/2025, 2:34 PMimplementation(it)
does not compile (in Koltin DSL), but implementation(project(it.path))
does, so I'll be using that.Vampire
05/13/2025, 2:36 PMVampire
05/13/2025, 2:37 PMSebastian Schuberth
05/13/2025, 2:38 PMVampire
05/13/2025, 3:05 PMSebastian Schuberth
05/13/2025, 3:06 PMfun Project.hasSourceSet(name: String): Boolean {
val javaExt = extensions.findByType(JavaPluginExtension::class.java) ?: return false
return javaExt.sourceSets.findByName(name) != null
}
dependencies {
rootProject.subprojects.filter { it != project && it.hasSourceSet("funTest") }.forEach {
implementation(project(it.path)) {
capabilities {
// Note that this uses kebab-case although "registerFeature()" uses camelCase, see
// <https://github.com/gradle/gradle/issues/31362>.
@Suppress("UnstableApiUsage")
requireFeature("fun-test")
}
}
}
}
Vampire
05/13/2025, 3:08 PMVampire
05/13/2025, 3:08 PMSebastian Schuberth
05/13/2025, 5:00 PMhasSourceSet
function? Otherwise the code should be the one that you suggested.Vampire
05/13/2025, 7:04 PMSebastian Schuberth
05/13/2025, 7:05 PMit.projectDir.resolve("src/funTest").isDirectory
by now.Sebastian Schuberth
05/13/2025, 7:06 PM