У меня есть Kotlin Мультиплатформенный проект, и я пытаюсь добавить Spring Boot в мои зависимости Gradle. Когда проект генерируется из Spring Initializr , он создает конфигурацию зависимостей developmentOnly
, как показано ниже. Он также создает конфигурацию зависимостей testImplementation
.
Первая build.gradle.kts
ниже - моя попытка перенести их в мультиплатформенный проект, который до сих пор не работал. Я отметил строки, у которых есть проблемы с комментариями, они находятся внизу файла. После этого я поставил для сравнения обычный Spring Boot build.gradle.kts
.
Как их можно поместить в мультиплатформенный проект? Или, если они не могут быть добавлены по какой-либо причине, настройте конфигурацию таким образом, чтобы был достигнут тот же результат.
plugins {
id("org.springframework.boot") version "2.2.4.RELEASE"
id("io.spring.dependency-management") version "1.0.9.RELEASE"
kotlin("multiplatform") version "1.3.70-eap-184"
kotlin("plugin.spring") version "1.3.70-eap-184"
kotlin("plugin.jpa") version "1.3.70-eap-184"
}
group = "com.test"
version = "0.0.1-SNAPSHOT"
java.sourceCompatibility = JavaVersion.VERSION_13
java.targetCompatibility = JavaVersion.VERSION_13
repositories {
maven { url = uri("https://dl.bintray.com/kotlin/kotlin-dev/") }
maven { url = uri("https://dl.bintray.com/kotlin/kotlin-eap") }
maven { url = uri("https://kotlin.bintray.com/kotlinx") }
maven { url = uri("https://dl.bintray.com/kotlin/kotlin-js-wrappers") }
mavenCentral()
jcenter()
}
kotlin {
jvm()
js {
browser()
}
}
kotlin.sourceSets["jsMain"].dependencies {
implementation(kotlin("stdlib-js"))
implementation("org.jetbrains:kotlin-react:16.9.0-pre.91-kotlin-1.3.61")
implementation("org.jetbrains:kotlin-react-dom:16.9.0-pre.91-kotlin-1.3.61")
implementation(npm("react", "16.12.0"))
implementation(npm("react-dom", "16.12.0"))
implementation("org.jetbrains:kotlin-styled:1.0.0-pre.91-kotlin-1.3.61")
implementation(npm("styled-components", "5.0.1"))
implementation(npm("inline-style-prefixer", "5.1.1"))
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-common:1.3.3")
}
//The problems begin here
val developmentOnly by configurations.creating
configurations {
runtimeClasspath { //can't resolve runtimeClasspath
extendsFrom(developmentOnly) //can't resolve extendsFrom
}
}
kotlin.sourceSets["jvmMain"].dependencies {
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
implementation("org.springframework.boot:spring-boot-starter-oauth2-client")
implementation("org.springframework.boot:spring-boot-starter-security")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("org.springframework.session:spring-session-core")
developmentOnly("org.springframework.boot:spring-boot-devtools") //error because of above where developmentOnly is defined
runtimeOnly("org.postgresql:postgresql")
testImplementation("org.springframework.boot:spring-boot-starter-test") { //can't resolve testImplementation
exclude(group = "org.junit.vintage", module = "junit-vintage-engine")
}
testImplementation("org.springframework.security:spring-security-test") //can't resolve testImplementation
}
Обычный build.gradle.kts
с Spring Boot (никаких проблем )
plugins {
id("org.springframework.boot") version "2.2.4.RELEASE"
id("io.spring.dependency-management") version "1.0.9.RELEASE"
war
kotlin("jvm") version "1.3.61"
kotlin("plugin.spring") version "1.3.61"
kotlin("plugin.jpa") version "1.3.61"
}
group = "com.test"
version = "0.0.1-SNAPSHOT"
java.sourceCompatibility = JavaVersion.VERSION_11
java.targetCompatibility = JavaVersion.VERSION_11
val developmentOnly by configurations.creating
configurations {
runtimeClasspath {
extendsFrom(developmentOnly)
}
}
repositories {
mavenCentral()
}
dependencies {
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
developmentOnly("org.springframework.boot:spring-boot-devtools")
runtimeOnly("com.microsoft.sqlserver:mssql-jdbc")
providedRuntime("org.springframework.boot:spring-boot-starter-tomcat")
testImplementation("org.springframework.boot:spring-boot-starter-test") {
exclude(group = "org.junit.vintage", module = "junit-vintage-engine")
}
}