2021-04-11 18:15:58 +08:00
|
|
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
2021-08-13 21:23:48 +08:00
|
|
|
import java.util.*
|
2021-04-11 18:15:58 +08:00
|
|
|
|
|
|
|
ext["netty.version"] = "4.1.59.Final"
|
|
|
|
ext["excludeTest"] = { project: Project, tasks: TaskContainer ->
|
2021-07-10 12:04:11 +08:00
|
|
|
if (project.gradle.startParameter.taskNames.firstOrNull { taskName ->
|
2021-08-14 00:17:16 +08:00
|
|
|
":test" in taskName
|
2021-07-10 12:04:11 +08:00
|
|
|
} == null) {
|
|
|
|
tasks {
|
|
|
|
test { enabled = false }
|
|
|
|
testClasses { enabled = false }
|
|
|
|
compileTestJava { enabled = false }
|
|
|
|
compileTestKotlin { enabled = false }
|
|
|
|
processTestResources { enabled = false }
|
2021-04-11 18:15:58 +08:00
|
|
|
}
|
2021-07-10 12:04:11 +08:00
|
|
|
}
|
2021-04-11 18:15:58 +08:00
|
|
|
}
|
2021-08-13 21:23:48 +08:00
|
|
|
ext["publishRepositories"] = { project: Project, p: PublishingExtension ->
|
|
|
|
val artifactoryUser: String by rootProject
|
|
|
|
val artifactoryPassword: String by rootProject
|
|
|
|
p.repositories {
|
|
|
|
maven {
|
|
|
|
val releasesRepoUrl = uri("https://nvm.tursom.cn/repository/maven-releases/")
|
|
|
|
val snapshotRepoUrl = uri("https://nvm.tursom.cn/repository/maven-snapshots/")
|
|
|
|
url = if (project.version.toString().endsWith("SNAPSHOT")) snapshotRepoUrl else releasesRepoUrl
|
|
|
|
credentials {
|
|
|
|
username = artifactoryUser
|
|
|
|
password = artifactoryPassword
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-04-11 18:15:58 +08:00
|
|
|
|
2021-08-13 21:23:48 +08:00
|
|
|
try {
|
|
|
|
val properties = Properties()
|
|
|
|
properties.load(rootProject.file("local.properties").inputStream())
|
|
|
|
properties.forEach { (k, v) ->
|
|
|
|
rootProject.ext.set(k.toString(), v)
|
|
|
|
}
|
|
|
|
} catch (e: Exception) {
|
|
|
|
}
|
2021-04-11 18:15:58 +08:00
|
|
|
|
|
|
|
plugins {
|
2021-07-16 00:33:42 +08:00
|
|
|
kotlin("jvm") version "1.5.21"
|
2021-07-10 12:04:11 +08:00
|
|
|
`maven-publish`
|
2021-04-11 18:15:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
allprojects {
|
2021-07-10 12:04:11 +08:00
|
|
|
group = "cn.tursom"
|
2021-08-13 21:23:48 +08:00
|
|
|
version = "1.0"
|
2021-04-11 18:15:58 +08:00
|
|
|
|
2021-07-10 12:04:11 +08:00
|
|
|
repositories {
|
2021-08-14 00:17:16 +08:00
|
|
|
// mavenLocal()
|
|
|
|
// mavenCentral()
|
|
|
|
maven {
|
|
|
|
url = uri("https://nvm.tursom.cn/repository/maven-public/")
|
|
|
|
}
|
2021-07-10 12:04:11 +08:00
|
|
|
}
|
2021-04-11 18:15:58 +08:00
|
|
|
|
2021-07-10 12:04:11 +08:00
|
|
|
tasks.withType<JavaCompile> {
|
|
|
|
tasks.withType<KotlinCompile>().configureEach {
|
|
|
|
kotlinOptions.jvmTarget = "1.8"
|
|
|
|
kotlinOptions.freeCompilerArgs += "-Xopt-in=kotlin.RequiresOptIn"
|
2021-04-11 18:15:58 +08:00
|
|
|
}
|
2021-04-19 16:19:35 +08:00
|
|
|
|
2021-07-10 12:04:11 +08:00
|
|
|
if (project.gradle.startParameter.taskNames.firstOrNull { taskName ->
|
|
|
|
taskName.endsWith(":test")
|
|
|
|
} == null) {
|
|
|
|
tasks.withType<Test> {
|
|
|
|
enabled = false
|
|
|
|
}
|
2021-04-19 16:19:35 +08:00
|
|
|
}
|
2021-07-10 12:04:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
tasks.withType<KotlinCompile>().configureEach {
|
|
|
|
kotlinOptions.jvmTarget = "1.8"
|
|
|
|
kotlinOptions.freeCompilerArgs += "-Xopt-in=kotlin.RequiresOptIn"
|
|
|
|
//kotlinOptions.useIR = true
|
|
|
|
}
|
2021-04-11 18:15:58 +08:00
|
|
|
}
|
|
|
|
|
2021-08-13 21:23:48 +08:00
|
|
|
@Suppress("UNCHECKED_CAST")
|
2021-04-11 18:15:58 +08:00
|
|
|
(rootProject.ext["excludeTest"] as (Project, TaskContainer) -> Unit)(project, tasks)
|
|
|
|
|
|
|
|
dependencies {
|
2021-07-10 12:04:11 +08:00
|
|
|
api(kotlin("stdlib-jdk8"))
|
|
|
|
api(kotlin("reflect"))
|
|
|
|
testImplementation(group = "junit", name = "junit", version = "4.12")
|
2021-04-11 18:15:58 +08:00
|
|
|
}
|
2021-04-11 18:48:18 +08:00
|
|
|
|
2021-04-19 16:19:35 +08:00
|
|
|
artifacts {
|
2021-07-10 12:04:11 +08:00
|
|
|
archives(tasks["kotlinSourcesJar"])
|
2021-04-19 16:19:35 +08:00
|
|
|
}
|
|
|
|
|
2021-04-11 18:48:18 +08:00
|
|
|
tasks.register("install") {
|
2021-07-10 12:04:11 +08:00
|
|
|
finalizedBy(tasks["publishToMavenLocal"])
|
2021-04-11 18:48:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
publishing {
|
2021-08-13 21:23:48 +08:00
|
|
|
@Suppress("UNCHECKED_CAST")
|
|
|
|
(rootProject.ext["publishRepositories"] as (Project, PublishingExtension) -> Unit)(project, this)
|
2021-07-10 12:04:11 +08:00
|
|
|
publications {
|
|
|
|
create<MavenPublication>("maven") {
|
|
|
|
groupId = project.group.toString()
|
|
|
|
artifactId = project.name
|
|
|
|
version = project.version.toString()
|
2021-04-11 18:48:18 +08:00
|
|
|
|
2021-07-10 12:04:11 +08:00
|
|
|
from(components["java"])
|
|
|
|
try {
|
|
|
|
artifact(tasks["kotlinSourcesJar"])
|
|
|
|
} catch (e: Exception) {
|
|
|
|
}
|
2021-04-11 18:48:18 +08:00
|
|
|
}
|
2021-07-10 12:04:11 +08:00
|
|
|
}
|
2021-04-11 18:48:18 +08:00
|
|
|
}
|