André Martins
04/27/2024, 7:57 PM(code in comment)
This is working currently, but I do have two questions/concerns:
• Do I always need to setup everything inside project.afterEvaluate
?
• Is there a more convenient type instead of Property for specifying a function? In order to avoid .get()()
Thanks in advance ✌️André Martins
04/27/2024, 7:57 PMplugins {
`common-plug`
}
test {
dependencies {
implementation...
}
}
e.g. common-plug.gradle.kts
interface TestExtension {
val dependencies: Property<JvmComponentDependencies.() -> Unit>
fun dependencies(block: JvmComponentDependencies.() -> Unit) {
dependencies = block
}
}
val extension = project.extensions.create<TestExtension>("test")
project.afterEvaluate {
testing {
suites {
getByName<JvmTestSuite>("test") {
//common config...
dependencies {
extension.dependencies.get()()
}
}
}
}
}
ephemient
04/27/2024, 8:01 PMephemient
04/27/2024, 8:03 PM@since 8.6
)André Martins
04/27/2024, 8:04 PMAndré Martins
04/27/2024, 8:05 PMephemient
04/27/2024, 8:05 PMephemient
04/27/2024, 8:17 PMinterface TestExtension {
interface TestDependencies : GradleDependencies {
val implementation: DependencyCollector
}
val dependencies: TestDependencies
fun dependencies(action: Action<TestDependencies>) {
action.execute(dependencies)
}
}
project.configurations.getByName("testImplementation") {
fromDependencyCollector(extension.dependencies.implementation)
}