I'm trying to create modular build script in kotlin. Basically main script and dependencies script. in the build.gradle.kts I have:
applyFrom("dependencies.kts")
and in dependencies.kts I have the actual dependencies:
dependencies {
listOf(
kotlinModule("stdlib-jre8"),
// Spring boot
"org.springframework.boot:spring-boot-starter-web",
"org.springframework.boot:spring-boot-starter-security",
"org.springframework.boot:spring-boot-starter-logging",
"org.springframework.boot:spring-boot-actuator",
// Spring
"org.springframework.data:spring-data-mongodb",
// Logging
"org.slf4j:slf4j-api",
"org.slf4j:jcl-over-slf4j",
"ch.qos.logback:logback-classic"
).forEach { compile(it) }
listOf(
"org.codehaus.groovy:groovy-all",
"org.springframework.boot:spring-boot-starter-test",
"org.spockframework:spock-core:1.0-groovy-2.4",
"org.spockframework:spock-spring:1.0-groovy-2.4"
).forEach { testCompile(it) }
}
This fails with:
Error: Could not find method kotlinModule() for arguments [stdlib-jre8] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
If I try to import kotlinModule, it fails with:
Error:Cause: startup failed:
script '/home/czar/personal/work/***/dependencies.kts': 1: unable to resolve class org.gradle.script.lang.kotlin.kotlinModule
@ line 1, column 1.
import org.gradle.script.lang.kotlin.kotlinModule
^
1 error
What am I doing wrong and how to do it right?
Versions and relevant information:
- Gradle: 4.0
- Gradle KTS: 0.9.0
- editor: IntelliJ U 2017.1.4
- Kotlin Plugin: 1.1.3 EAP
- Kotlin version for project: 1.1.2.5
My build works perfectly when I have dependencies in the main file. All necessary configurations (buildscript, plugins, repositories, etc.) are present, but omitted here for brevity.