import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import org.springframework.boot.gradle.tasks.bundling.BootJar import java.net.URI plugins { id("org.springframework.boot") version "2.3.1.RELEASE" id("io.spring.dependency-management") version "1.0.9.RELEASE" kotlin("jvm") version "1.4.0" kotlin("plugin.spring") version "1.4.0" kotlin("plugin.jpa") version "1.4.0" id("distribution") } group = "com.pqh" version = "0.0.1-SNAPSHOT" java.sourceCompatibility = JavaVersion.VERSION_1_8 val taskGraph=gradle.getTaskGraph() val junitVersion = "5.0.0" var enabledProcessResources:Boolean? = null val miraiVersion="1.2.2" repositories { maven { url=URI("https://maven.aliyun.com/repository/public/") } maven { url=URI("https://repo.spring.io/libs-milestone/") } mavenCentral() } dependencies { implementation("net.mamoe:mirai-core-qqandroid:${miraiVersion}") implementation("com.alibaba:fastjson:1.2.71") // implementation("org.springframework.boot:spring-boot-starter-data-jpa") implementation("org.springframework.boot:spring-boot-starter-web") implementation("org.springframework.boot:spring-boot-starter-data-mongodb") implementation("org.jetbrains.kotlin:kotlin-reflect") implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8") testImplementation("org.springframework.boot:spring-boot-starter-test") { exclude(module = "junit") exclude(module = "mockito-core") exclude(module = "junit-vintage-engine") } } tasks.register("qqbot") { dependsOn(tasks.withType()) from("src/main/resources") into("${buildDir}/libs/config") doLast{ println("完成任务,buildDir=${buildDir}") } } taskGraph.beforeTask { if(this.name=="processResources") { if (taskGraph.hasTask(":bootJar")) { println("不打包资源文件") enabled = false } else { println("打包资源文件") enabled = true } } } tasks.withType { useJUnitPlatform() } tasks.withType { kotlinOptions { freeCompilerArgs = listOf("-Xjsr305=strict") jvmTarget = "1.8" } }