Gradle 创建一个空文件夹 `build/kotlin/sessions` ,为什么?当我删除它回来时,如何修复它?

标签 gradle kotlin intellij-idea

我在 Kotlin/Springboot 中有一个使用 Gradle 构建的多模块项目。 我有一个文件夹 build/kotlin/sessions,即使我删除它也总是会出现。

文件夹是什么,为什么在那里?我可以将它完全移除,这样它就不会再出现吗?

enter image description here

我的根settings.gradle.kts:

pluginManagement {
    repositories {
        maven(url = "https://repo.spring.io/snapshot")

        maven(url = "https://repo.spring.io/milestone")

        gradlePluginPortal()
    }
    resolutionStrategy {
        eachPlugin {
            if (requested.id.id == "org.springframework.boot") {
                useModule("org.springframework.boot:spring-boot-gradle-plugin:${requested.version}")
            }
        }
    }
}

rootProject.name = "ris_2.0_backend"
include("workflow")
include("messaging")
include("project")
include("restapi")

我的根build.gradle.kts:

plugins {
    id("io.spring.dependency-management") version "1.0.8.RELEASE"
    kotlin("jvm") version "1.3.61" apply false
    kotlin("plugin.spring") version "1.3.61"
    kotlin("plugin.jpa") version "1.3.61"
}

subprojects {

    apply(plugin = "io.spring.dependency-management")

    repositories {
        jcenter()
    }

    dependencyManagement {
        imports {
            mavenBom("org.springframework.boot:spring-boot-dependencies:2.1.8.RELEASE") {
                bomProperty("kotlin.version", "1.3.61")
            }
        }
    }



}

以及每个模块中的所有build.gradle.kts:

import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
    id("com.adarshr.test-logger").version("1.7.0") // pretty log printing
    kotlin("jvm")
    kotlin("plugin.spring")
    jacoco
}

group = "no.inmeta.ris.workflow"
version = "0.0.1-SNAPSHOT"
val junit5Version = "5.5.1"

val developmentOnly = configurations.create("developmentOnly")

configurations.runtimeClasspath.get().extendsFrom(developmentOnly)

configurations {
    developmentOnly
    testCompile {
        exclude(group = "junit", module = "junit") // force junit5
        exclude(group = "mocito-core", module = "mockito-core")
    }
}

repositories {
    mavenCentral()
}

dependencies {

    // Spring
    implementation("org.springframework.boot:spring-boot-starter")
    implementation("org.springframework.boot:spring-boot-starter-web")
    implementation("org.springframework.boot:spring-boot-starter-data-jpa")


    // Swagger
    implementation("io.springfox:springfox-swagger2:2.9.2")

    // Testing
    implementation(enforcedPlatform("org.junit:junit-bom:$junit5Version"))
    testImplementation("org.springframework.boot:spring-boot-starter-test:2.1.9.RELEASE")
    testImplementation("org.junit.jupiter:junit-jupiter")
    testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
    testImplementation("org.assertj:assertj-core:3.11.1")

    // Kotlin testing library
    testImplementation("com.ninja-squad:springmockk:1.1.3")
    testImplementation("io.mockk:mockk:1.9.3")

    // Kotlin
    implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
    implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.10.0")
}

configure<JacocoPluginExtension> {
    toolVersion = "0.8.4"
}

tasks.withType<JacocoReport> {
    reports {
        xml.isEnabled = true
        csv.isEnabled = false
        xml.destination = file("${buildDir}/jacoco/reports/test.xml")
        html.destination = file("${buildDir}/jacoco/reports/test.html")
    }
}

tasks.withType<Test> {
    useJUnitPlatform()
    testLogging {
        events("passed", "skipped", "failed")
    }
    finalizedBy("jacocoTestReport")
}

val compileKotlin: KotlinCompile by tasks
compileKotlin.kotlinOptions {
    jvmTarget = "1.8"
}
val compileTestKotlin: KotlinCompile by tasks
compileTestKotlin.kotlinOptions {
    jvmTarget = "1.8"
}

我的配置中是否有任何东西导致出现这个空的构建文件夹?

感谢您的帮助!

最佳答案

Gradle会自动在每个项目中添加构建目录(很正常,每个Gradle项目都有这样的目录)。

如果您查看子项目(消息传递、restapi 等)的文件夹,您可能会在那里看到类似的构建文件夹。稍后您可能会添加更多 gradle 插件,这些插件会将它们的数据存储在这些目录中。

IntelliJ IDEA 会自动将这些目录标记为已排除,因此 IDE 不会处理其中的任何文件。如果您使用的是 Git,请将这些目录添加到您的 .gitignore 文件中(只需在其中添加“构建”行,它将从 VCS 中删除所有子项目的所有构建文件夹)。如果您对看到这些文件夹感到非常恼火,您可以在 IDEA 中隐藏排除的文件夹。

关于Gradle 创建一个空文件夹 `build/kotlin/sessions` ,为什么?当我删除它回来时,如何修复它?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59777055/

相关文章:

jenkins - Jenkins插件开发Gradle构建

scala - 使用 Spark 和 IntelliJ 时出现 NoSuchMethodError

java - SpringBoot Thymeleaf 无法解析模板

android - 添加flutter_contact插件后,Flutter App Gradle构建失败

java - 我应该掌握 maven 还是开始学习 gradle

java - 使用 kotlin 时在单元测试和仪器测试之间共享代码

android - ViewModelFactory需要

android - 包含协程延迟时如何对协程进行单元测试?

intellij-idea - 尝试在 IntelliJ IDEA 中运行 Kotlin 脚本

java - 如何使用 upstart 正确启动 gradle 生成的脚本?