"Kotlin not configured"当我在 gradle 中添加一个新的源集时。(智能)



我有这个gradle项目,我添加了两个新的源集"acceptanceTest"one_answers"integrationTest"。我首先添加了"acceptanceTest",它正常工作,然后我复制了代码来创建"integrationTest"。

当我在integrationTest下创建一个文件时,我会在IntelliJ中得到"Kotlin未配置"。当我试着跑gradle时也是如此。

plugins {
id 'org.jetbrains.kotlin.jvm' version '1.3.71'
}
apply plugin: 'idea'
group 'org.example'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
jcenter()
}
configurations {
acceptanceTestCompile.extendsFrom testCompile
acceptanceTestRuntime.extendsFrom testRuntime
integrationTestCompile.extendsFrom testCompile
integrationTestRuntime.extendsFrom testRuntime
}
sourceSets {
acceptanceTest {
kotlin {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
srcDir file("src/acceptanceTest/kotlin")
}
resources.srcDir file("src/acceptanceTest/resources")
}
kotlin {
}
integrationTest {
kotlin {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
srcDir file("src/integrationTest/kotlin")
}
resources.srcDir file("src/integrationTest/resources")
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
runtimeOnly "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
implementation "org.yaml:snakeyaml:1.26"
testImplementation "org.junit.jupiter:junit-jupiter:5.6.1"
testImplementation "io.mockk:mockk:1.9.3.kotlin12"
testRuntimeOnly "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
testImplementation "org.assertj:assertj-core:3.11.1"
acceptanceTestRuntime "org.yaml:snakeyaml:1.26"
acceptanceTestImplementation "org.spekframework.spek2:spek-dsl-jvm:$spek_version"
acceptanceTestImplementation "org.spekframework.spek2:spek-runner-junit5:$spek_version"
acceptanceTestImplementation "org.assertj:assertj-core:3.11.1"
acceptanceTestImplementation "io.mockk:mockk:1.9.3.kotlin12"
}

task acceptanceTest(type: Test) {
testClassesDirs = sourceSets.acceptanceTest.output.classesDirs
classpath = sourceSets.acceptanceTest.runtimeClasspath
outputs.upToDateWhen { false }
}
task integrationTest(type: Test) {
testClassesDirs = sourceSets.integrationTest.output.classesDirs
classpath = sourceSets.integrationTest.runtimeClasspath
outputs.upToDateWhen { false }
}
check.dependsOn integrationTest
integrationTest.mustRunAfter test
check.dependsOn acceptanceTest
acceptanceTest.mustRunAfter integrationTest
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
test {
useJUnitPlatform()
testLogging {
events("passed", "skipped", "failed")
}
}
acceptanceTest {
useJUnitPlatform {
includeEngines 'spek2'
}
testLogging {
events("passed", "skipped", "failed")
}
}
integrationTest {
useJUnitPlatform()
testLogging {
events("passed", "skipped", "failed")
}
}
idea {
module {
testSourceDirs += project.sourceSets.integrationTest.kotlin.srcDirs
testSourceDirs += project.sourceSets.integrationTest.resources.srcDirs
testSourceDirs += project.sourceSets.acceptanceTest.kotlin.srcDirs
testSourceDirs += project.sourceSets.acceptanceTest.resources.srcDirs
}
}

我现在找到了答案。在依赖项中,您需要为该源集添加kotlin-stdlib。类似integrationTestImplementation"org.jetbrains.kotlin:kotlin-stdlib-jdk8">

最新更新