christophsturm
11/04/2023, 9:53 PMtestImplementation("org.jetbrains.kotlin:kotlin-test") {
isTransitive = false
}
but this is not:
testImplementation(kotlin("test")) {
isTransitive = false
}
christophsturm
11/04/2023, 9:55 PMfun DependencyHandler.kotlin(module: String, version: String? = null): Any =
"org.jetbrains.kotlin:kotlin-$module${version?.let { ":$version" } ?: ""}"
christophsturm
11/04/2023, 10:11 PMephemient
11/04/2023, 10:57 PMtestImplementation(kotlin("test")) {
(this as ModuleDependency).isTransitive = false
}
but why?christophsturm
11/04/2023, 11:20 PMchristophsturm
11/04/2023, 11:21 PMAny
, this also does not work:
val dependencyNotation = "org.jetbrains.kotlin:kotlin-test" as Any
testImplementation(dependencyNotation) {
isTransitive = false
}
ephemient
11/04/2023, 11:57 PMchristophsturm
11/05/2023, 8:03 AMSam
11/05/2023, 9:03 AMAny
and a configuration block. The kotlin(...)
helper function actually does return a string, so this should work:
testImplementation("${kotlin("test")}") {
isTransitive = true
}
Alternatively you could use apply
, since adding a dependency also returns it:
implementation(kotlin("test"))?.apply {
(this as ExternalModuleDependency).isTransitive = true
}
I think the right solution would be for the kotlin(...)
function to actually return a string, or even an actual instance of ExternalModuleDependency
. Maybe worth a YouTrack ticket?christophsturm
11/05/2023, 6:13 PMchristophsturm
11/05/2023, 6:14 PMephemient
11/05/2023, 6:18 PMimplementation(...).apply { ... }
ephemient
11/05/2023, 6:20 PMkotlin-test
though. it doesn't have any dependencies other than kotlin-stdlib
which you need anywayephemient
11/05/2023, 6:24 PMephemient
11/05/2023, 6:26 PMchristophsturm
11/05/2023, 10:09 PMI'm still puzzled why you want to do this withit has a runtime dependency on junit 5 that I would like to get rid of.though. it doesn't have any dependencies other thankotlin-test
which you need anywaykotlin-stdlib
ephemient
11/05/2023, 10:10 PMkotlin-test-junit5
, although KGP automatically tries to upgrade it if you don't specifyephemient
11/05/2023, 10:13 PMkotlin.test.infer.jvm.variant=false
to disable that, but note that the assertions and annotations in that package won't work anymore (unless you specify a -junit
, -junit5
, or -testng
dependency yourself)christophsturm
11/06/2023, 10:01 AMchristophsturm
11/06/2023, 10:05 AMephemient
11/06/2023, 4:26 PMephemient
11/06/2023, 4:27 PMisTransitive
that you configure there because it's a adding a dependency to the configurationchristophsturm
11/06/2023, 4:31 PMephemient
11/06/2023, 4:42 PMgetWorkerImplementationClasspathModules()
etc.ephemient
11/06/2023, 4:43 PMchristophsturm
11/06/2023, 4:46 PM