In groovy script I could assign a list of dependencies in an array as “implementation libraries.frameworkLibs”, does similar approach exists in kotlin?
plugins {
id 'org.springframework.boot' version '2.1.4.RELEASE'
id 'java'
}
apply plugin: 'io.spring.dependency-management'
sourceCompatibility = '1.8'
/* 1. centerilize dependencies for all projects */
ext.libraries = [
frameworkLibs: [
'org.springframework.boot:spring-boot-starter-data-redis',
'org.springframework.boot:spring-boot-starter-web',
'org.mybatis.spring.boot:mybatis-spring-boot-starter:2.0.1',
'org.springframework.kafka:spring-kafka'
],
testLibs: [
'org.springframework.boot:spring-boot-starter-test',
'org.springframework.kafka:spring-kafka-test'
],
sqlLibs: [
'org.postgresql:postgresql'
]
]
allprojects {
group = 'com.example'
version = '0.0.1-SNAPSHOT'
repositories {
mavenCentral()
}
dependencies {
/* 2. establish dependencies */
implementation libraries.frameworkLibs
runtimeOnly libraries.sqlLibs
testImplementation libraries.testLibs
}
}
Below is what I have in Kotlin. The goal is to have a list with one or more dependencies in a single array as shown in the groovy script above, for example libraries.frameworkLibs, then be able to assign it to dependencies {}.
plugins {
id("org.springframework.boot") version "2.1.4.RELEASE"
java
// this plugin is required for Kotlin
id("io.spring.dependency-management") version "1.0.7.RELEASE"
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
repositories {
jcenter()
}
allprojects {
group = "com.example"
version = "0.0.1-SNAPSHOT"
dependencies {
/* unable to modularize */
implementation ("org.springframework.boot:spring-boot-starter-data-redis")
implementation ("org.springframework.boot:spring-boot-starter-web")
implementation ("org.mybatis.spring.boot:mybatis-spring-boot-starter:2.0.1")
implementation ("org.springframework.kafka:spring-kafka")
runtimeOnly ("org.postgresql:postgresql")
testImplementation ("org.springframework.boot:spring-boot-starter-test")
testImplementation ("org.springframework.kafka:spring-kafka-test")
}
}