From b69b6ba083a327abae9cb5e3e43e049127849efd Mon Sep 17 00:00:00 2001 From: tursom Date: Mon, 23 Aug 2021 15:52:10 +0800 Subject: [PATCH] update dependence --- .gitignore | 2 +- build.gradle.kts | 119 +------- ts-core/build.gradle.kts | 22 +- ts-core/ts-async-http/build.gradle.kts | 30 +- ts-core/ts-buffer/build.gradle.kts | 26 +- ts-core/ts-clone/build.gradle.kts | 22 +- ts-core/ts-coroutine/build.gradle.kts | 22 +- .../ts-coroutine-lock/build.gradle.kts | 22 +- ts-core/ts-datastruct/build.gradle.kts | 22 +- ts-core/ts-delegation/build.gradle.kts | 22 +- .../ts-observer/build.gradle.kts | 22 +- ts-core/ts-encrypt/build.gradle.kts | 22 +- ts-core/ts-hash/build.gradle.kts | 22 +- ts-core/ts-json/build.gradle.kts | 22 +- ts-core/ts-log/build.gradle.kts | 22 +- ts-core/ts-mail/build.gradle.kts | 22 +- ts-core/ts-pool/build.gradle.kts | 22 +- ts-core/ts-ws-client/build.gradle.kts | 22 +- ts-core/ts-xml/build.gradle.kts | 22 +- ts-core/ts-yaml/build.gradle.kts | 22 +- ts-database/build.gradle.kts | 22 +- ts-database/ts-mongodb/build.gradle.kts | 22 +- .../ts-mongodb-spring/build.gradle.kts | 22 +- ts-database/ts-redis/build.gradle.kts | 22 +- ts-gradle/build.gradle.kts | 17 +- ts-gradle/src/main/kotlin/Internal.kt | 7 + ts-gradle/src/main/kotlin/Utils.kt | 132 +++++++++ .../cn/tursom/gradle/TursomGradlePlugin.kt | 105 +++++++ .../tursom/gradle/TursomServerDependencies.kt | 258 ++++++++++++++++++ ts-socket/build.gradle.kts | 22 +- ts-web/build.gradle.kts | 26 +- ts-web/ts-web-coroutine/build.gradle.kts | 22 +- ts-web/ts-web-netty/build.gradle.kts | 24 +- 33 files changed, 544 insertions(+), 686 deletions(-) create mode 100644 ts-gradle/src/main/kotlin/Internal.kt create mode 100644 ts-gradle/src/main/kotlin/Utils.kt create mode 100644 ts-gradle/src/main/kotlin/cn/tursom/gradle/TursomGradlePlugin.kt create mode 100644 ts-gradle/src/main/kotlin/cn/tursom/gradle/TursomServerDependencies.kt diff --git a/.gitignore b/.gitignore index 9c0add7..570a9de 100644 --- a/.gitignore +++ b/.gitignore @@ -6,5 +6,5 @@ build */build/ #gradle.properties -local.properties +local.yml !.idea/codeStyles \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 2d54a25..bd48d74 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,94 +1,9 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile -import java.util.* - -ext["netty.version"] = "4.1.59.Final" -ext["excludeTest"] = { project: Project, tasks: TaskContainer -> - if (project.gradle.startParameter.taskNames.firstOrNull { taskName -> - ":test" in taskName - } == null) { - tasks { - test { enabled = false } - testClasses { enabled = false } - compileTestJava { enabled = false } - compileTestKotlin { enabled = false } - processTestResources { enabled = false } - } - } -} -ext["publishRepositories"] = { project: Project, p: PublishingExtension -> - p.repositories { - try { - val artifactoryUser: String = rootProject.ext["tursom.artifactoryUser"] as String - val artifactoryPassword: String = rootProject.ext["tursom.artifactoryPassword"] as String - 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 - } - } - } catch (e: Exception) { - println("cannot push to repository tursom") - } - try { - maven { - val githubUser: String by rootProject - val githubToken: String by rootProject - name = "GitHubPackages" - url = uri("https://maven.pkg.github.com/$githubUser/TursomServer") - credentials { - username = githubUser - password = githubToken - } - } - } catch (e: Exception) { - println("cannot push to repository github") - } - - val repositoriesRegex = "repositories\\.[a-zA-z]*".toRegex() - rootProject.properties.keys.asSequence().filter { - it matches repositoriesRegex - }.forEach { - val repositoryName = rootProject.ext.properties["$it.name"]?.toString() ?: it.substringAfterLast('.') - try { - val artifactoryUser = rootProject.ext.properties["$it.artifactoryUser"].toString() - val artifactoryPassword = rootProject.ext.properties["$it.artifactoryPassword"].toString() - maven { - name = repositoryName - val releasesRepoUrl = rootProject.ext.properties["$it.release"]?.let { uri(it.toString()) } - val snapshotRepoUrl = rootProject.ext.properties["$it.snapshot"]?.let { uri(it.toString()) } - val repoUrl = rootProject.ext.properties["$it.url"]?.let { uri(it.toString()) } - url = if (project.version.toString().endsWith("SNAPSHOT") - && snapshotRepoUrl != null - ) { - snapshotRepoUrl - } else releasesRepoUrl ?: repoUrl!! - credentials { - username = artifactoryUser - password = artifactoryPassword - } - } - } catch (e: Exception) { - println("cannot push to repository $repositoryName") - } - } - } -} - -try { - val properties = Properties() - properties.load(rootProject.file("local.properties").inputStream()) - properties.forEach { (k, v) -> - rootProject.ext.set(k.toString(), v) - } -} catch (e: Exception) { -} plugins { kotlin("jvm") version "1.5.21" `maven-publish` + id("ts-gradle") } allprojects { @@ -96,7 +11,6 @@ allprojects { version = "1.0-SNAPSHOT" repositories { - // mavenLocal() mavenCentral() maven { url = uri("https://nvm.tursom.cn/repository/maven-public/") @@ -125,37 +39,14 @@ allprojects { } } -@Suppress("UNCHECKED_CAST") -(rootProject.ext["excludeTest"] as (Project, TaskContainer) -> Unit)(project, tasks) + dependencies { - api("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.21") - api("org.jetbrains.kotlin:kotlin-reflect:1.5.21") - testImplementation(group = "junit", name = "junit", version = "4.13.2") + api(kotlin("stdlib-jdk8")) + api(kotlin("reflect")) + testApi(group = "junit", name = "junit", version = "4.13.2") } artifacts { archives(tasks["kotlinSourcesJar"]) } - -tasks.register("install") { - finalizedBy(tasks["publishToMavenLocal"]) -} - -//publishing { -// @Suppress("UNCHECKED_CAST") -// (rootProject.ext["publishRepositories"] as (Project, PublishingExtension) -> Unit)(project, this) -// publications { -// create("maven") { -// groupId = project.group.toString() -// artifactId = project.name -// version = project.version.toString() -// -// from(components["java"]) -// try { -// artifact(tasks["kotlinSourcesJar"]) -// } catch (e: Exception) { -// } -// } -// } -//} diff --git a/ts-core/build.gradle.kts b/ts-core/build.gradle.kts index 87bc98b..190a3be 100644 --- a/ts-core/build.gradle.kts +++ b/ts-core/build.gradle.kts @@ -1,6 +1,7 @@ plugins { kotlin("jvm") `maven-publish` + id("ts-gradle") } dependencies { @@ -12,27 +13,6 @@ dependencies { testImplementation(group = "junit", name = "junit", version = "4.13.2") } -@kotlin.Suppress("UNCHECKED_CAST") -(rootProject.ext["excludeTest"] as (Project, TaskContainer) -> Unit)(project, tasks) -tasks.register("install") { - finalizedBy(tasks["publishToMavenLocal"]) -} -publishing { - @Suppress("UNCHECKED_CAST") - (rootProject.ext["publishRepositories"] as (Project, PublishingExtension) -> Unit)(project, this) - publications { - create("maven") { - groupId = project.group.toString() - artifactId = project.name - version = project.version.toString() - from(components["java"]) - try { - artifact(tasks["kotlinSourcesJar"]) - } catch (e: Exception) { - } - } - } -} diff --git a/ts-core/ts-async-http/build.gradle.kts b/ts-core/ts-async-http/build.gradle.kts index acf19fe..522cd35 100644 --- a/ts-core/ts-async-http/build.gradle.kts +++ b/ts-core/ts-async-http/build.gradle.kts @@ -1,6 +1,7 @@ plugins { kotlin("jvm") `maven-publish` + id("ts-gradle") } dependencies { @@ -19,32 +20,3 @@ dependencies { testImplementation(project(":ts-core:ts-coroutine")) } - -@kotlin.Suppress("UNCHECKED_CAST") -(rootProject.ext["excludeTest"] as (Project, TaskContainer) -> Unit)(project, tasks) - -tasks.register("install") { - finalizedBy(tasks["publishToMavenLocal"]) -} - -artifacts { - archives(tasks["kotlinSourcesJar"]) -} - -publishing { - @Suppress("UNCHECKED_CAST") - (rootProject.ext["publishRepositories"] as (Project, PublishingExtension) -> Unit)(project, this) - publications { - create("maven") { - groupId = project.group.toString() - artifactId = project.name - version = project.version.toString() - - from(components["java"]) - try { - artifact(tasks["kotlinSourcesJar"]) - } catch (e: Exception) { - } - } - } -} diff --git a/ts-core/ts-buffer/build.gradle.kts b/ts-core/ts-buffer/build.gradle.kts index cb95898..835693c 100644 --- a/ts-core/ts-buffer/build.gradle.kts +++ b/ts-core/ts-buffer/build.gradle.kts @@ -1,6 +1,7 @@ plugins { kotlin("jvm") `maven-publish` + id("ts-gradle") } dependencies { @@ -9,31 +10,6 @@ dependencies { compileOnly(group = "io.netty", name = "netty-all", version = "4.1.67.Final") } -@kotlin.Suppress("UNCHECKED_CAST") -(rootProject.ext["excludeTest"] as (Project, TaskContainer) -> Unit)(project, tasks) - -tasks.register("install") { - finalizedBy(tasks["publishToMavenLocal"]) -} - artifacts { archives(tasks["kotlinSourcesJar"]) } - -publishing { - @Suppress("UNCHECKED_CAST") - (rootProject.ext["publishRepositories"] as (Project, PublishingExtension) -> Unit)(project, this) - publications { - create("maven") { - groupId = project.group.toString() - artifactId = project.name - version = project.version.toString() - - from(components["java"]) - try { - artifact(tasks["kotlinSourcesJar"]) - } catch (e: Exception) { - } - } - } -} diff --git a/ts-core/ts-clone/build.gradle.kts b/ts-core/ts-clone/build.gradle.kts index 9f7bd9d..d26f0a4 100644 --- a/ts-core/ts-clone/build.gradle.kts +++ b/ts-core/ts-clone/build.gradle.kts @@ -1,6 +1,7 @@ plugins { kotlin("jvm") `maven-publish` + id("ts-gradle") } dependencies { @@ -10,27 +11,6 @@ dependencies { implementation(project(":ts-core:ts-datastruct")) } -@kotlin.Suppress("UNCHECKED_CAST") -(rootProject.ext["excludeTest"] as (Project, TaskContainer) -> Unit)(project, tasks) -tasks.register("install") { - finalizedBy(tasks["publishToMavenLocal"]) -} -publishing { - @Suppress("UNCHECKED_CAST") - (rootProject.ext["publishRepositories"] as (Project, PublishingExtension) -> Unit)(project, this) - publications { - create("maven") { - groupId = project.group.toString() - artifactId = project.name - version = project.version.toString() - from(components["java"]) - try { - artifact(tasks["kotlinSourcesJar"]) - } catch (e: Exception) { - } - } - } -} diff --git a/ts-core/ts-coroutine/build.gradle.kts b/ts-core/ts-coroutine/build.gradle.kts index 1b8befd..c5879da 100644 --- a/ts-core/ts-coroutine/build.gradle.kts +++ b/ts-core/ts-coroutine/build.gradle.kts @@ -1,6 +1,7 @@ plugins { kotlin("jvm") `maven-publish` + id("ts-gradle") } dependencies { @@ -8,27 +9,6 @@ dependencies { api("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.1") } -@kotlin.Suppress("UNCHECKED_CAST") -(rootProject.ext["excludeTest"] as (Project, TaskContainer) -> Unit)(project, tasks) -tasks.register("install") { - finalizedBy(tasks["publishToMavenLocal"]) -} -publishing { - @Suppress("UNCHECKED_CAST") - (rootProject.ext["publishRepositories"] as (Project, PublishingExtension) -> Unit)(project, this) - publications { - create("maven") { - groupId = project.group.toString() - artifactId = project.name - version = project.version.toString() - from(components["java"]) - try { - artifact(tasks["kotlinSourcesJar"]) - } catch (e: Exception) { - } - } - } -} diff --git a/ts-core/ts-coroutine/ts-coroutine-lock/build.gradle.kts b/ts-core/ts-coroutine/ts-coroutine-lock/build.gradle.kts index 1b8befd..c5879da 100644 --- a/ts-core/ts-coroutine/ts-coroutine-lock/build.gradle.kts +++ b/ts-core/ts-coroutine/ts-coroutine-lock/build.gradle.kts @@ -1,6 +1,7 @@ plugins { kotlin("jvm") `maven-publish` + id("ts-gradle") } dependencies { @@ -8,27 +9,6 @@ dependencies { api("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.1") } -@kotlin.Suppress("UNCHECKED_CAST") -(rootProject.ext["excludeTest"] as (Project, TaskContainer) -> Unit)(project, tasks) -tasks.register("install") { - finalizedBy(tasks["publishToMavenLocal"]) -} -publishing { - @Suppress("UNCHECKED_CAST") - (rootProject.ext["publishRepositories"] as (Project, PublishingExtension) -> Unit)(project, this) - publications { - create("maven") { - groupId = project.group.toString() - artifactId = project.name - version = project.version.toString() - from(components["java"]) - try { - artifact(tasks["kotlinSourcesJar"]) - } catch (e: Exception) { - } - } - } -} diff --git a/ts-core/ts-datastruct/build.gradle.kts b/ts-core/ts-datastruct/build.gradle.kts index dda140b..a2324b8 100644 --- a/ts-core/ts-datastruct/build.gradle.kts +++ b/ts-core/ts-datastruct/build.gradle.kts @@ -1,6 +1,7 @@ plugins { kotlin("jvm") `maven-publish` + id("ts-gradle") } dependencies { @@ -10,27 +11,6 @@ dependencies { implementation(project(":ts-core:ts-hash")) } -@kotlin.Suppress("UNCHECKED_CAST") -(rootProject.ext["excludeTest"] as (Project, TaskContainer) -> Unit)(project, tasks) -tasks.register("install") { - finalizedBy(tasks["publishToMavenLocal"]) -} -publishing { - @Suppress("UNCHECKED_CAST") - (rootProject.ext["publishRepositories"] as (Project, PublishingExtension) -> Unit)(project, this) - publications { - create("maven") { - groupId = project.group.toString() - artifactId = project.name - version = project.version.toString() - from(components["java"]) - try { - artifact(tasks["kotlinSourcesJar"]) - } catch (e: Exception) { - } - } - } -} diff --git a/ts-core/ts-delegation/build.gradle.kts b/ts-core/ts-delegation/build.gradle.kts index 987f3be..159ade0 100644 --- a/ts-core/ts-delegation/build.gradle.kts +++ b/ts-core/ts-delegation/build.gradle.kts @@ -1,6 +1,7 @@ plugins { kotlin("jvm") `maven-publish` + id("ts-gradle") } dependencies { @@ -8,27 +9,6 @@ dependencies { compileOnly(group = "io.netty", name = "netty-all", version = "4.1.67.Final") } -@kotlin.Suppress("UNCHECKED_CAST") -(rootProject.ext["excludeTest"] as (Project, TaskContainer) -> Unit)(project, tasks) -tasks.register("install") { - finalizedBy(tasks["publishToMavenLocal"]) -} -publishing { - @Suppress("UNCHECKED_CAST") - (rootProject.ext["publishRepositories"] as (Project, PublishingExtension) -> Unit)(project, this) - publications { - create("maven") { - groupId = project.group.toString() - artifactId = project.name - version = project.version.toString() - from(components["java"]) - try { - artifact(tasks["kotlinSourcesJar"]) - } catch (e: Exception) { - } - } - } -} diff --git a/ts-core/ts-delegation/ts-observer/build.gradle.kts b/ts-core/ts-delegation/ts-observer/build.gradle.kts index 1a7d2c6..448de31 100644 --- a/ts-core/ts-delegation/ts-observer/build.gradle.kts +++ b/ts-core/ts-delegation/ts-observer/build.gradle.kts @@ -1,6 +1,7 @@ plugins { kotlin("jvm") `maven-publish` + id("ts-gradle") } dependencies { @@ -8,27 +9,6 @@ dependencies { api(project(":ts-core:ts-delegation")) } -@kotlin.Suppress("UNCHECKED_CAST") -(rootProject.ext["excludeTest"] as (Project, TaskContainer) -> Unit)(project, tasks) -tasks.register("install") { - finalizedBy(tasks["publishToMavenLocal"]) -} -publishing { - @Suppress("UNCHECKED_CAST") - (rootProject.ext["publishRepositories"] as (Project, PublishingExtension) -> Unit)(project, this) - publications { - create("maven") { - groupId = project.group.toString() - artifactId = project.name - version = project.version.toString() - from(components["java"]) - try { - artifact(tasks["kotlinSourcesJar"]) - } catch (e: Exception) { - } - } - } -} diff --git a/ts-core/ts-encrypt/build.gradle.kts b/ts-core/ts-encrypt/build.gradle.kts index 8b80faf..26f0acf 100644 --- a/ts-core/ts-encrypt/build.gradle.kts +++ b/ts-core/ts-encrypt/build.gradle.kts @@ -1,6 +1,7 @@ plugins { kotlin("jvm") `maven-publish` + id("ts-gradle") } dependencies { @@ -10,27 +11,6 @@ dependencies { implementation(project(":ts-core:ts-datastruct")) } -@kotlin.Suppress("UNCHECKED_CAST") -(rootProject.ext["excludeTest"] as (Project, TaskContainer) -> Unit)(project, tasks) -tasks.register("install") { - finalizedBy(tasks["publishToMavenLocal"]) -} -publishing { - @Suppress("UNCHECKED_CAST") - (rootProject.ext["publishRepositories"] as (Project, PublishingExtension) -> Unit)(project, this) - publications { - create("maven") { - groupId = project.group.toString() - artifactId = project.name - version = project.version.toString() - from(components["java"]) - try { - artifact(tasks["kotlinSourcesJar"]) - } catch (e: Exception) { - } - } - } -} diff --git a/ts-core/ts-hash/build.gradle.kts b/ts-core/ts-hash/build.gradle.kts index c1b8bee..2063896 100644 --- a/ts-core/ts-hash/build.gradle.kts +++ b/ts-core/ts-hash/build.gradle.kts @@ -1,6 +1,7 @@ plugins { kotlin("jvm") `maven-publish` + id("ts-gradle") } dependencies { @@ -8,27 +9,6 @@ dependencies { implementation(project(":ts-core:ts-buffer")) } -@kotlin.Suppress("UNCHECKED_CAST") -(rootProject.ext["excludeTest"] as (Project, TaskContainer) -> Unit)(project, tasks) -tasks.register("install") { - finalizedBy(tasks["publishToMavenLocal"]) -} -publishing { - @Suppress("UNCHECKED_CAST") - (rootProject.ext["publishRepositories"] as (Project, PublishingExtension) -> Unit)(project, this) - publications { - create("maven") { - groupId = project.group.toString() - artifactId = project.name - version = project.version.toString() - from(components["java"]) - try { - artifact(tasks["kotlinSourcesJar"]) - } catch (e: Exception) { - } - } - } -} diff --git a/ts-core/ts-json/build.gradle.kts b/ts-core/ts-json/build.gradle.kts index 5b73773..9129ac7 100644 --- a/ts-core/ts-json/build.gradle.kts +++ b/ts-core/ts-json/build.gradle.kts @@ -1,6 +1,7 @@ plugins { kotlin("jvm") `maven-publish` + id("ts-gradle") } dependencies { @@ -10,27 +11,6 @@ dependencies { compileOnly(group = "com.fasterxml.jackson.core", name = "jackson-databind", version = "2.12.4") } -@kotlin.Suppress("UNCHECKED_CAST") -(rootProject.ext["excludeTest"] as (Project, TaskContainer) -> Unit)(project, tasks) -tasks.register("install") { - finalizedBy(tasks["publishToMavenLocal"]) -} -publishing { - @Suppress("UNCHECKED_CAST") - (rootProject.ext["publishRepositories"] as (Project, PublishingExtension) -> Unit)(project, this) - publications { - create("maven") { - groupId = project.group.toString() - artifactId = project.name - version = project.version.toString() - from(components["java"]) - try { - artifact(tasks["kotlinSourcesJar"]) - } catch (e: Exception) { - } - } - } -} diff --git a/ts-core/ts-log/build.gradle.kts b/ts-core/ts-log/build.gradle.kts index 7c585e2..6de7707 100644 --- a/ts-core/ts-log/build.gradle.kts +++ b/ts-core/ts-log/build.gradle.kts @@ -1,6 +1,7 @@ plugins { kotlin("jvm") `maven-publish` + id("ts-gradle") } dependencies { @@ -13,27 +14,6 @@ dependencies { compileOnly(group = "com.google.code.gson", name = "gson", version = "2.8.7") } -@kotlin.Suppress("UNCHECKED_CAST") -(rootProject.ext["excludeTest"] as (Project, TaskContainer) -> Unit)(project, tasks) -tasks.register("install") { - finalizedBy(tasks["publishToMavenLocal"]) -} -publishing { - @Suppress("UNCHECKED_CAST") - (rootProject.ext["publishRepositories"] as (Project, PublishingExtension) -> Unit)(project, this) - publications { - create("maven") { - groupId = project.group.toString() - artifactId = project.name - version = project.version.toString() - from(components["java"]) - try { - artifact(tasks["kotlinSourcesJar"]) - } catch (e: Exception) { - } - } - } -} diff --git a/ts-core/ts-mail/build.gradle.kts b/ts-core/ts-mail/build.gradle.kts index 17df3dc..e0a526a 100644 --- a/ts-core/ts-mail/build.gradle.kts +++ b/ts-core/ts-mail/build.gradle.kts @@ -1,6 +1,7 @@ plugins { kotlin("jvm") `maven-publish` + id("ts-gradle") } dependencies { @@ -8,27 +9,6 @@ dependencies { implementation(group = "com.sun.mail", name = "javax.mail", version = "1.6.2") } -@kotlin.Suppress("UNCHECKED_CAST") -(rootProject.ext["excludeTest"] as (Project, TaskContainer) -> Unit)(project, tasks) -tasks.register("install") { - finalizedBy(tasks["publishToMavenLocal"]) -} -publishing { - @Suppress("UNCHECKED_CAST") - (rootProject.ext["publishRepositories"] as (Project, PublishingExtension) -> Unit)(project, this) - publications { - create("maven") { - groupId = project.group.toString() - artifactId = project.name - version = project.version.toString() - from(components["java"]) - try { - artifact(tasks["kotlinSourcesJar"]) - } catch (e: Exception) { - } - } - } -} diff --git a/ts-core/ts-pool/build.gradle.kts b/ts-core/ts-pool/build.gradle.kts index 918d9dd..778d33a 100644 --- a/ts-core/ts-pool/build.gradle.kts +++ b/ts-core/ts-pool/build.gradle.kts @@ -1,6 +1,7 @@ plugins { kotlin("jvm") `maven-publish` + id("ts-gradle") } dependencies { @@ -10,27 +11,6 @@ dependencies { implementation(project(":ts-core:ts-datastruct")) } -@kotlin.Suppress("UNCHECKED_CAST") -(rootProject.ext["excludeTest"] as (Project, TaskContainer) -> Unit)(project, tasks) -tasks.register("install") { - finalizedBy(tasks["publishToMavenLocal"]) -} -publishing { - @Suppress("UNCHECKED_CAST") - (rootProject.ext["publishRepositories"] as (Project, PublishingExtension) -> Unit)(project, this) - publications { - create("maven") { - groupId = project.group.toString() - artifactId = project.name - version = project.version.toString() - from(components["java"]) - try { - artifact(tasks["kotlinSourcesJar"]) - } catch (e: Exception) { - } - } - } -} diff --git a/ts-core/ts-ws-client/build.gradle.kts b/ts-core/ts-ws-client/build.gradle.kts index 35cb3e5..52bb39f 100644 --- a/ts-core/ts-ws-client/build.gradle.kts +++ b/ts-core/ts-ws-client/build.gradle.kts @@ -1,6 +1,7 @@ plugins { kotlin("jvm") `maven-publish` + id("ts-gradle") } dependencies { @@ -11,31 +12,10 @@ dependencies { api(group = "io.netty", name = "netty-all", version = "4.1.67.Final") } -@kotlin.Suppress("UNCHECKED_CAST") -(rootProject.ext["excludeTest"] as (Project, TaskContainer) -> Unit)(project, tasks) -tasks.register("install") { - finalizedBy(tasks["publishToMavenLocal"]) -} artifacts { archives(tasks["kotlinSourcesJar"]) } -publishing { - @Suppress("UNCHECKED_CAST") - (rootProject.ext["publishRepositories"] as (Project, PublishingExtension) -> Unit)(project, this) - publications { - create("maven") { - groupId = project.group.toString() - artifactId = project.name - version = project.version.toString() - from(components["java"]) - try { - artifact(tasks["kotlinSourcesJar"]) - } catch (e: Exception) { - } - } - } -} diff --git a/ts-core/ts-xml/build.gradle.kts b/ts-core/ts-xml/build.gradle.kts index 6e2552d..586c852 100644 --- a/ts-core/ts-xml/build.gradle.kts +++ b/ts-core/ts-xml/build.gradle.kts @@ -1,6 +1,7 @@ plugins { kotlin("jvm") `maven-publish` + id("ts-gradle") } dependencies { @@ -9,27 +10,6 @@ dependencies { api(group = "org.dom4j", name = "dom4j", version = "2.1.3") } -@kotlin.Suppress("UNCHECKED_CAST") -(rootProject.ext["excludeTest"] as (Project, TaskContainer) -> Unit)(project, tasks) -tasks.register("install") { - finalizedBy(tasks["publishToMavenLocal"]) -} -publishing { - @Suppress("UNCHECKED_CAST") - (rootProject.ext["publishRepositories"] as (Project, PublishingExtension) -> Unit)(project, this) - publications { - create("maven") { - groupId = project.group.toString() - artifactId = project.name - version = project.version.toString() - from(components["java"]) - try { - artifact(tasks["kotlinSourcesJar"]) - } catch (e: Exception) { - } - } - } -} diff --git a/ts-core/ts-yaml/build.gradle.kts b/ts-core/ts-yaml/build.gradle.kts index 56a24f3..803365a 100644 --- a/ts-core/ts-yaml/build.gradle.kts +++ b/ts-core/ts-yaml/build.gradle.kts @@ -1,6 +1,7 @@ plugins { kotlin("jvm") `maven-publish` + id("ts-gradle") } dependencies { @@ -9,27 +10,6 @@ dependencies { implementation(group = "org.yaml", name = "snakeyaml", version = "1.29") } -@kotlin.Suppress("UNCHECKED_CAST") -(rootProject.ext["excludeTest"] as (Project, TaskContainer) -> Unit)(project, tasks) -tasks.register("install") { - finalizedBy(tasks["publishToMavenLocal"]) -} -publishing { - @Suppress("UNCHECKED_CAST") - (rootProject.ext["publishRepositories"] as (Project, PublishingExtension) -> Unit)(project, this) - publications { - create("maven") { - groupId = project.group.toString() - artifactId = project.name - version = project.version.toString() - from(components["java"]) - try { - artifact(tasks["kotlinSourcesJar"]) - } catch (e: Exception) { - } - } - } -} diff --git a/ts-database/build.gradle.kts b/ts-database/build.gradle.kts index 12e1545..00d4888 100644 --- a/ts-database/build.gradle.kts +++ b/ts-database/build.gradle.kts @@ -1,6 +1,7 @@ plugins { kotlin("jvm") `maven-publish` + id("ts-gradle") } dependencies { @@ -13,27 +14,6 @@ dependencies { compileOnly(group = "com.google.code.gson", name = "gson", version = "2.8.7") } -@kotlin.Suppress("UNCHECKED_CAST") -(rootProject.ext["excludeTest"] as (Project, TaskContainer) -> Unit)(project, tasks) -tasks.register("install") { - finalizedBy(tasks["publishToMavenLocal"]) -} -publishing { - @Suppress("UNCHECKED_CAST") - (rootProject.ext["publishRepositories"] as (Project, PublishingExtension) -> Unit)(project, this) - publications { - create("maven") { - groupId = project.group.toString() - artifactId = project.name - version = project.version.toString() - from(components["java"]) - try { - artifact(tasks["kotlinSourcesJar"]) - } catch (e: Exception) { - } - } - } -} diff --git a/ts-database/ts-mongodb/build.gradle.kts b/ts-database/ts-mongodb/build.gradle.kts index e4e569d..5e29f5a 100644 --- a/ts-database/ts-mongodb/build.gradle.kts +++ b/ts-database/ts-mongodb/build.gradle.kts @@ -1,6 +1,7 @@ plugins { kotlin("jvm") `maven-publish` + id("ts-gradle") } dependencies { @@ -12,27 +13,6 @@ dependencies { api(group = "org.mongodb", name = "mongodb-driver-reactivestreams", version = "4.3.0") } -@kotlin.Suppress("UNCHECKED_CAST") -(rootProject.ext["excludeTest"] as (Project, TaskContainer) -> Unit)(project, tasks) -tasks.register("install") { - finalizedBy(tasks["publishToMavenLocal"]) -} -publishing { - @Suppress("UNCHECKED_CAST") - (rootProject.ext["publishRepositories"] as (Project, PublishingExtension) -> Unit)(project, this) - publications { - create("maven") { - groupId = project.group.toString() - artifactId = project.name - version = project.version.toString() - from(components["java"]) - try { - artifact(tasks["kotlinSourcesJar"]) - } catch (e: Exception) { - } - } - } -} diff --git a/ts-database/ts-mongodb/ts-mongodb-spring/build.gradle.kts b/ts-database/ts-mongodb/ts-mongodb-spring/build.gradle.kts index b97505a..bcaef58 100644 --- a/ts-database/ts-mongodb/ts-mongodb-spring/build.gradle.kts +++ b/ts-database/ts-mongodb/ts-mongodb-spring/build.gradle.kts @@ -1,6 +1,7 @@ plugins { kotlin("jvm") `maven-publish` + id("ts-gradle") } dependencies { @@ -9,27 +10,6 @@ dependencies { compileOnly(group = "org.springframework.data", name = "spring-data-mongodb", version = "3.2.4") } -@kotlin.Suppress("UNCHECKED_CAST") -(rootProject.ext["excludeTest"] as (Project, TaskContainer) -> Unit)(project, tasks) -tasks.register("install") { - finalizedBy(tasks["publishToMavenLocal"]) -} -publishing { - @Suppress("UNCHECKED_CAST") - (rootProject.ext["publishRepositories"] as (Project, PublishingExtension) -> Unit)(project, this) - publications { - create("maven") { - groupId = project.group.toString() - artifactId = project.name - version = project.version.toString() - from(components["java"]) - try { - artifact(tasks["kotlinSourcesJar"]) - } catch (e: Exception) { - } - } - } -} diff --git a/ts-database/ts-redis/build.gradle.kts b/ts-database/ts-redis/build.gradle.kts index 4fdf4d7..5610d0b 100644 --- a/ts-database/ts-redis/build.gradle.kts +++ b/ts-database/ts-redis/build.gradle.kts @@ -1,6 +1,7 @@ plugins { kotlin("jvm") `maven-publish` + id("ts-gradle") } dependencies { @@ -10,27 +11,6 @@ dependencies { api(group = "redis.clients", name = "jedis", version = "3.6.3") } -@kotlin.Suppress("UNCHECKED_CAST") -(rootProject.ext["excludeTest"] as (Project, TaskContainer) -> Unit)(project, tasks) -tasks.register("install") { - finalizedBy(tasks["publishToMavenLocal"]) -} -publishing { - @Suppress("UNCHECKED_CAST") - (rootProject.ext["publishRepositories"] as (Project, PublishingExtension) -> Unit)(project, this) - publications { - create("maven") { - groupId = project.group.toString() - artifactId = project.name - version = project.version.toString() - from(components["java"]) - try { - artifact(tasks["kotlinSourcesJar"]) - } catch (e: Exception) { - } - } - } -} diff --git a/ts-gradle/build.gradle.kts b/ts-gradle/build.gradle.kts index 575ee3b..660412b 100644 --- a/ts-gradle/build.gradle.kts +++ b/ts-gradle/build.gradle.kts @@ -20,7 +20,7 @@ try { } catch (e: Exception) { } -group = "com.ddbes" +group = "cn.tursom" version = SimpleDateFormat("yy.MM.dd-HH.mm").format(Date()) repositories { @@ -34,11 +34,11 @@ dependencies { gradlePlugin { plugins { - create("ddbes-gradle") { + create("ts-gradle") { // 在 app 模块需要通过 id 引用这个插件 - id = "ddbes-gradle" + id = "ts-gradle" // 实现这个插件的类的路径 - implementationClass = "DdbesGradlePlugin" + implementationClass = "cn.tursom.gradle.TursomGradlePlugin" } } } @@ -46,13 +46,14 @@ gradlePlugin { publishing { repositories { try { - val artifactoryUser: String = rootProject.ext["tursom.artifactoryUser"] as String - val artifactoryPassword: String = rootProject.ext["tursom.artifactoryPassword"] as String maven { + name = "tursom" 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 { + val artifactoryUser: String = rootProject.ext["tursom.artifactoryUser"] as String + val artifactoryPassword: String = rootProject.ext["tursom.artifactoryPassword"] as String username = artifactoryUser password = artifactoryPassword } @@ -62,9 +63,9 @@ publishing { } try { maven { - val githubUser: String by rootProject - val githubToken: String by rootProject name = "GitHubPackages" + val githubUser: String = rootProject.ext["github.artifactoryUser"] as String + val githubToken: String = rootProject.ext["github.artifactoryPassword"] as String url = uri("https://maven.pkg.github.com/$githubUser/TursomServer") credentials { username = githubUser diff --git a/ts-gradle/src/main/kotlin/Internal.kt b/ts-gradle/src/main/kotlin/Internal.kt new file mode 100644 index 0000000..13e5948 --- /dev/null +++ b/ts-gradle/src/main/kotlin/Internal.kt @@ -0,0 +1,7 @@ +import org.gradle.api.Project +import org.gradle.api.plugins.ExtensionAware +import org.gradle.api.plugins.ExtraPropertiesExtension + +internal val Project.ext: ExtraPropertiesExtension + get() = (this as ExtensionAware).extensions + .getByName("ext") as ExtraPropertiesExtension \ No newline at end of file diff --git a/ts-gradle/src/main/kotlin/Utils.kt b/ts-gradle/src/main/kotlin/Utils.kt new file mode 100644 index 0000000..c467533 --- /dev/null +++ b/ts-gradle/src/main/kotlin/Utils.kt @@ -0,0 +1,132 @@ +import org.gradle.api.Project +import org.gradle.api.artifacts.ConfigurationContainer +import org.gradle.api.publish.PublishingExtension +import org.gradle.api.publish.maven.MavenPublication +import java.util.concurrent.TimeUnit + +var nettyVersion = "4.1.67.Final" + +fun Project.excludeTest() { + if (gradle.startParameter.taskNames.firstOrNull { taskName -> + taskName.contains("test", true) + } == null) { + tasks.run { + named("test") { it.enabled = false } + named("testClasses") { it.enabled = false } + named("compileTestJava") { it.enabled = false } + try { + named("compileTestKotlin") { it.enabled = false } + } catch (e: Exception) { + } + named("processTestResources") { it.enabled = false } + } + } +} + +fun Project.publish(publish: PublishingExtension) { + val properties = rootProject.properties + publish.repositories { repositoryHandler -> + try { + repositoryHandler.maven { repository -> + repository.name = "tursom" + repository.url = if (version.toString().endsWith("SNAPSHOT")) { + uri("https://nvm.tursom.cn/repository/maven-snapshots/") + } else { + uri("https://nvm.tursom.cn/repository/maven-releases/") + } + repository.credentials { credentials -> + val artifactoryUser: String = rootProject.ext["tursom.artifactoryUser"]!!.toString() + val artifactoryPassword: String = rootProject.ext["tursom.artifactoryPassword"]!!.toString() + credentials.username = artifactoryUser + credentials.password = artifactoryPassword + } + } + } catch (e: Exception) { + println("cannot publish to repository tursom:\n${e.javaClass}: ${e.message}") + } + + val repositoriesRegex = "repositories\\.[a-zA-z][a-zA-z0-9]*".toRegex() + properties.keys.asSequence().filter { + it matches repositoriesRegex + }.forEach { repositoryName -> + try { + val artifactoryUser = rootProject.ext["$repositoryName.artifactoryUser"]?.toString() + ?: throw Exception("no artifactory user found") + val artifactoryPassword = rootProject.ext["$repositoryName.artifactoryPassword"]?.toString() + ?: throw Exception("no artifactory password found") + repositoryHandler.maven { repository -> + repository.name = properties["$repository.name"]?.toString() + ?: repositoryName.substringAfterLast('.') + val releasesRepoUrl = properties["$repositoryName.release"]?.let { + uri(it.toString()) + } + val snapshotRepoUrl = properties["$repositoryName.snapshot"]?.let { + uri(it.toString()) + } + val repoUrl = properties["$repositoryName.url"]?.let { + uri(it.toString()) + } + repository.url = if (version.toString().endsWith("SNAPSHOT") && snapshotRepoUrl != null) { + snapshotRepoUrl + } else { + releasesRepoUrl + } ?: repoUrl ?: throw Exception("no repo found") + repository.credentials { + it.username = artifactoryUser + it.password = artifactoryPassword + } + } + } catch (e: Exception) { + println( + "cannot publish to repository ${repositoryName.substringAfterLast('.')}:\n" + + "${e.javaClass}: ${e.message}" + ) + } + } + } + publish.publications { + it.create("maven", MavenPublication::class.java) { mavenPublication -> + mavenPublication.groupId = project.group.toString() + mavenPublication.artifactId = project.name + mavenPublication.version = project.version.toString() + + try { + mavenPublication.from(components.getByName("java")) + } catch (e: Exception) { + } + try { + mavenPublication.artifact(tasks.getByName("kotlinSourcesJar")) + } catch (e: Exception) { + } + } + } +} + +fun ConfigurationContainer.noExpire() { + all { + it.resolutionStrategy.cacheChangingModulesFor(0, TimeUnit.SECONDS) + it.resolutionStrategy.cacheDynamicVersionsFor(0, TimeUnit.SECONDS) + } +} + +fun Project.userTursomRepositories( + useAliyunMirror: Boolean = false, + mavenCentral: Boolean = false, + tursom: Boolean = true +) { + repositories.run { + if (useAliyunMirror) { + maven { + it.url = uri("https://maven.aliyun.com/repository/public") + } + } + if (mavenCentral) { + mavenCentral() + } + if (tursom) { + maven { + it.url = uri("https://nvm.tursom.cn/repository/maven-public") + } + } + } +} diff --git a/ts-gradle/src/main/kotlin/cn/tursom/gradle/TursomGradlePlugin.kt b/ts-gradle/src/main/kotlin/cn/tursom/gradle/TursomGradlePlugin.kt new file mode 100644 index 0000000..0e8971d --- /dev/null +++ b/ts-gradle/src/main/kotlin/cn/tursom/gradle/TursomGradlePlugin.kt @@ -0,0 +1,105 @@ +package cn.tursom.gradle + +import excludeTest +import ext +import org.gradle.api.DefaultTask +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.api.publish.PublishingExtension +import org.yaml.snakeyaml.Yaml +import publish +import java.io.FileNotFoundException +import java.util.* + +class TursomGradlePlugin : Plugin { + companion object { + val yaml = Yaml() + var project: Project? = null + private set + } + + override fun apply(target: Project) { + project = target + listOf( + "local.properties", + "local.yml", + "local.yaml", + "gradle.yml", + "gradle.yaml" + ).forEach { propertiesFile -> + when { + propertiesFile.endsWith(".properties") -> loadProperties(target, propertiesFile) + propertiesFile.endsWith(".yml") || propertiesFile.endsWith(".yaml") -> + loadYaml(target, propertiesFile) + } + } + //println(target.ext.properties) + + target.excludeTest() + + try { + target.extensions.configure("publishing") { + target.publish(it) + } + } catch (e: Exception) { + } + + if (try { + target.tasks.findByName("install") + } catch (e: Exception) { + null + } == null + ) run install@{ + val publishToMavenLocal = target.tasks.findByName("publishToMavenLocal") ?: return@install + target.tasks.register("install", DefaultTask::class.java) { + it.finalizedBy(publishToMavenLocal) + } + } + } +} + + +fun loadProperties(target: Project, propertiesFile: String) = try { + val properties = Properties() + properties.load(target.file(propertiesFile).inputStream()) + properties.forEach { (k, v) -> + setProperty(target, k.toString(), v) + } +} catch (e: Exception) { +} + +fun loadYaml(target: Project, propertiesFile: String) { + try { + TursomGradlePlugin.yaml.load>(target.file(propertiesFile).inputStream()).forEach { (k, v) -> + put(target, k, v) + } + } catch (e: Exception) { + if (e !is FileNotFoundException) { + e.printStackTrace() + } + } +} + +fun put(target: Project, key: String, value: Any?) { + when (value) { + null -> return + is String, is Byte, is Short, is Int, is Long, is Float, is Double, is Char -> + setProperty(target, key, value) + else -> { + setProperty(target, key, value) + if (value is Map<*, *>) { + value.forEach { (k, v) -> + put(target, "$key.$k", v) + } + } + } + } +} + +fun setProperty(target: Project, key: String, value: Any) { + target.ext.set(key, value) + try { + target.setProperty(key, value) + } catch (e: Exception) { + } +} diff --git a/ts-gradle/src/main/kotlin/cn/tursom/gradle/TursomServerDependencies.kt b/ts-gradle/src/main/kotlin/cn/tursom/gradle/TursomServerDependencies.kt new file mode 100644 index 0000000..237deac --- /dev/null +++ b/ts-gradle/src/main/kotlin/cn/tursom/gradle/TursomServerDependencies.kt @@ -0,0 +1,258 @@ +@file:Suppress("unused", "ObjectPropertyName", "FunctionName") + +package cn.tursom.gradle + +import org.gradle.api.Action +import org.gradle.api.artifacts.ExternalModuleDependency +import org.gradle.api.artifacts.dsl.DependencyHandler + +var commonVersion = "1.1-SNAPSHOT" + +private fun DependencyHandler.add( + configurationName: String, + name: String, + group: String = "cn.tursom", + version: String = commonVersion, + configuration: String? = null, + classifier: String? = null, + ext: String? = null, + dependencyConfiguration: Action? = null +) = create(mapOf( + "group" to group, + "name" to name, + "version" to version, + "configuration" to configuration, + "classifier" to classifier, + "ext" to ext +).filter { it.value != null }).let { + it as ExternalModuleDependency + dependencyConfiguration?.execute(it) + add(configurationName, it) + it +} + +fun DependencyHandler.tursomServer( + name: String, + version: String = commonVersion, + configuration: String? = null, + classifier: String? = null, + ext: String? = null, + dependencyConfiguration: Action? = null +) = add("implementation", name, "cn.tursom", version, configuration, classifier, ext, dependencyConfiguration) + +fun DependencyHandler.implementationTursomServer( + name: String, + version: String = commonVersion, + configuration: String? = null, + classifier: String? = null, + ext: String? = null, + dependencyConfiguration: Action? = null +) = add("implementation", name, "cn.tursom", version, configuration, classifier, ext, dependencyConfiguration) + +fun DependencyHandler.testImplementationTursomServer( + name: String, + version: String = commonVersion, + configuration: String? = null, + classifier: String? = null, + ext: String? = null, + dependencyConfiguration: Action? = null +) = add("testImplementation", name, "cn.tursom", version, configuration, classifier, ext, dependencyConfiguration) + +fun DependencyHandler.apiTursomServer( + name: String, + version: String = commonVersion, + configuration: String? = null, + classifier: String? = null, + ext: String? = null, + dependencyConfiguration: Action? = null +) = add("api", name, "cn.tursom", version, configuration, classifier, ext, dependencyConfiguration) + +fun DependencyHandler.testApiTursomServer( + name: String, + version: String = commonVersion, + configuration: String? = null, + classifier: String? = null, + ext: String? = null, + dependencyConfiguration: Action? = null +) = add("testApi", name, "cn.tursom", version, configuration, classifier, ext, dependencyConfiguration) + +fun DependencyHandler.compileOnlyTursomServer( + name: String, + version: String = commonVersion, + configuration: String? = null, + classifier: String? = null, + ext: String? = null, + dependencyConfiguration: Action? = null +) = add("compileOnly", name, "cn.tursom", version, configuration, classifier, ext, dependencyConfiguration) + +fun DependencyHandler.testCompileOnlyTursomServer( + name: String, + version: String = commonVersion, + configuration: String? = null, + classifier: String? = null, + ext: String? = null, + dependencyConfiguration: Action? = null +) = add("testCompileOnly", name, "cn.tursom", version, configuration, classifier, ext, dependencyConfiguration) + +fun DependencyHandler.runtimeOnlyTursomServer( + name: String, + version: String = commonVersion, + configuration: String? = null, + classifier: String? = null, + ext: String? = null, + dependencyConfiguration: Action? = null +) = add("runtimeOnly", name, "cn.tursom", version, configuration, classifier, ext, dependencyConfiguration) + +fun DependencyHandler.testRuntimeOnlyTursomServer( + name: String, + version: String = commonVersion, + configuration: String? = null, + classifier: String? = null, + ext: String? = null, + dependencyConfiguration: Action? = null +) = add("testRuntimeOnly", name, "cn.tursom", version, configuration, classifier, ext, dependencyConfiguration) + +val DependencyHandler.`ts-core` get() = tursomServer("ts-core") +val DependencyHandler.`ts-async-http` get() = tursomServer("ts-async-http") +val DependencyHandler.`ts-buffer` get() = tursomServer("ts-buffer") +val DependencyHandler.`ts-clone` get() = tursomServer("ts-clone") +val DependencyHandler.`ts-coroutine` get() = tursomServer("ts-coroutine") +val DependencyHandler.`ts-coroutine-lock` get() = tursomServer("ts-coroutine-lock") +val DependencyHandler.`ts-datastruct` get() = tursomServer("ts-datastruct") +val DependencyHandler.`ts-delegation` get() = tursomServer("ts-delegation") +val DependencyHandler.`ts-observer` get() = tursomServer("ts-observer") +val DependencyHandler.`ts-encrypt` get() = tursomServer("ts-encrypt") +val DependencyHandler.`ts-hash` get() = tursomServer("ts-hash") +val DependencyHandler.`ts-json` get() = tursomServer("ts-json") +val DependencyHandler.`ts-log` get() = tursomServer("ts-log") +val DependencyHandler.`ts-mail` get() = tursomServer("ts-mail") +val DependencyHandler.`ts-pool` get() = tursomServer("ts-pool") +val DependencyHandler.`ts-ws-client` get() = tursomServer("ts-ws-client") +val DependencyHandler.`ts-xml` get() = tursomServer("ts-xml") +val DependencyHandler.`ts-yaml` get() = tursomServer("ts-yaml") + +val DependencyHandler.`ts-database` get() = tursomServer("ts-database") +val DependencyHandler.`ts-mongodb` get() = tursomServer("ts-mongodb") +val DependencyHandler.`ts-mongodb-spring` get() = tursomServer("ts-mongodb-spring") +val DependencyHandler.`ts-redis` get() = tursomServer("ts-redis") + +val DependencyHandler.`ts-gradle` get() = tursomServer("ts-gradle") + +val DependencyHandler.`ts-socket` get() = tursomServer("ts-socket") + +val DependencyHandler.`ts-web` get() = tursomServer("ts-web") +val DependencyHandler.`ts-web-coroutine` get() = tursomServer("ts-web-coroutine") +val DependencyHandler.`ts-web-netty` get() = tursomServer("ts-web-netty") + + +fun DependencyHandler.`ts-core`( + dependencyConfiguration: Action? = null +) = tursomServer("ts-core", dependencyConfiguration = dependencyConfiguration) + +fun DependencyHandler.`ts-async-http`( + dependencyConfiguration: Action? = null +) = tursomServer("ts-async-http", dependencyConfiguration = dependencyConfiguration) + +fun DependencyHandler.`ts-buffer`( + dependencyConfiguration: Action? = null +) = tursomServer("ts-buffer", dependencyConfiguration = dependencyConfiguration) + +fun DependencyHandler.`ts-clone`( + dependencyConfiguration: Action? = null +) = tursomServer("ts-clone", dependencyConfiguration = dependencyConfiguration) + +fun DependencyHandler.`ts-coroutine`( + dependencyConfiguration: Action? = null +) = tursomServer("ts-coroutine", dependencyConfiguration = dependencyConfiguration) + +fun DependencyHandler.`ts-coroutine-lock`( + dependencyConfiguration: Action? = null +) = tursomServer("ts-coroutine-lock", dependencyConfiguration = dependencyConfiguration) + +fun DependencyHandler.`ts-datastruct`( + dependencyConfiguration: Action? = null +) = tursomServer("ts-datastruct", dependencyConfiguration = dependencyConfiguration) + +fun DependencyHandler.`ts-delegation`( + dependencyConfiguration: Action? = null +) = tursomServer("ts-delegation", dependencyConfiguration = dependencyConfiguration) + +fun DependencyHandler.`ts-observer`( + dependencyConfiguration: Action? = null +) = tursomServer("ts-observer", dependencyConfiguration = dependencyConfiguration) + +fun DependencyHandler.`ts-encrypt`( + dependencyConfiguration: Action? = null +) = tursomServer("ts-encrypt", dependencyConfiguration = dependencyConfiguration) + +fun DependencyHandler.`ts-hash`( + dependencyConfiguration: Action? = null +) = tursomServer("ts-hash", dependencyConfiguration = dependencyConfiguration) + +fun DependencyHandler.`ts-json`( + dependencyConfiguration: Action? = null +) = tursomServer("ts-json", dependencyConfiguration = dependencyConfiguration) + +fun DependencyHandler.`ts-log`( + dependencyConfiguration: Action? = null +) = tursomServer("ts-log", dependencyConfiguration = dependencyConfiguration) + +fun DependencyHandler.`ts-mail`( + dependencyConfiguration: Action? = null +) = tursomServer("ts-mail", dependencyConfiguration = dependencyConfiguration) + +fun DependencyHandler.`ts-pool`( + dependencyConfiguration: Action? = null +) = tursomServer("ts-pool", dependencyConfiguration = dependencyConfiguration) + +fun DependencyHandler.`ts-ws-client`( + dependencyConfiguration: Action? = null +) = tursomServer("ts-ws-client", dependencyConfiguration = dependencyConfiguration) + +fun DependencyHandler.`ts-xml`( + dependencyConfiguration: Action? = null +) = tursomServer("ts-xml", dependencyConfiguration = dependencyConfiguration) + +fun DependencyHandler.`ts-yaml`( + dependencyConfiguration: Action? = null +) = tursomServer("ts-yaml", dependencyConfiguration = dependencyConfiguration) + + +fun DependencyHandler.`ts-database`( + dependencyConfiguration: Action? = null +) = tursomServer("ts-database", dependencyConfiguration = dependencyConfiguration) + +fun DependencyHandler.`ts-mongodb`( + dependencyConfiguration: Action? = null +) = tursomServer("ts-mongodb", dependencyConfiguration = dependencyConfiguration) + +fun DependencyHandler.`ts-mongodb-spring`( + dependencyConfiguration: Action? = null +) = tursomServer("ts-mongodb-spring", dependencyConfiguration = dependencyConfiguration) + +fun DependencyHandler.`ts-redis`( + dependencyConfiguration: Action? = null +) = tursomServer("ts-redis", dependencyConfiguration = dependencyConfiguration) + + +fun DependencyHandler.`ts-gradle`( + dependencyConfiguration: Action? = null +) = tursomServer("ts-gradle", dependencyConfiguration = dependencyConfiguration) + + +fun DependencyHandler.`ts-socket`( + dependencyConfiguration: Action? = null +) = tursomServer("ts-socket", dependencyConfiguration = dependencyConfiguration) + + +fun DependencyHandler.`ts-web`( + dependencyConfiguration: Action? = null +) = tursomServer("ts-web", dependencyConfiguration = dependencyConfiguration) + +fun DependencyHandler.`ts-web-coroutine`( + dependencyConfiguration: Action? = null +) = tursomServer("ts-web-coroutine", dependencyConfiguration = dependencyConfiguration) + +fun DependencyHandler.`ts-web-netty`( + dependencyConfiguration: Action? = null +) = tursomServer("ts-web-netty", dependencyConfiguration = dependencyConfiguration) diff --git a/ts-socket/build.gradle.kts b/ts-socket/build.gradle.kts index e2ed24e..45c9a4f 100644 --- a/ts-socket/build.gradle.kts +++ b/ts-socket/build.gradle.kts @@ -1,6 +1,7 @@ plugins { kotlin("jvm") `maven-publish` + id("ts-gradle") } dependencies { @@ -12,27 +13,6 @@ dependencies { implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.1") } -@kotlin.Suppress("UNCHECKED_CAST") -(rootProject.ext["excludeTest"] as (Project, TaskContainer) -> Unit)(project, tasks) -tasks.register("install") { - finalizedBy(tasks["publishToMavenLocal"]) -} -publishing { - @Suppress("UNCHECKED_CAST") - (rootProject.ext["publishRepositories"] as (Project, PublishingExtension) -> Unit)(project, this) - publications { - create("maven") { - groupId = project.group.toString() - artifactId = project.name - version = project.version.toString() - from(components["java"]) - try { - artifact(tasks["kotlinSourcesJar"]) - } catch (e: Exception) { - } - } - } -} diff --git a/ts-web/build.gradle.kts b/ts-web/build.gradle.kts index df699d3..81ccd1f 100644 --- a/ts-web/build.gradle.kts +++ b/ts-web/build.gradle.kts @@ -1,6 +1,7 @@ plugins { kotlin("jvm") `maven-publish` + id("ts-gradle") } dependencies { @@ -10,28 +11,3 @@ dependencies { compileOnly(project(":ts-core:ts-json")) implementation(group = "org.slf4j", name = "slf4j-api", version = "1.7.32") } - -@kotlin.Suppress("UNCHECKED_CAST") -(rootProject.ext["excludeTest"] as (Project, TaskContainer) -> Unit)(project, tasks) - -tasks.register("install") { - finalizedBy(tasks["publishToMavenLocal"]) -} - -publishing { - @Suppress("UNCHECKED_CAST") - (rootProject.ext["publishRepositories"] as (Project, PublishingExtension) -> Unit)(project, this) - publications { - create("maven") { - groupId = project.group.toString() - artifactId = project.name - version = project.version.toString() - - from(components["java"]) - try { - artifact(tasks["kotlinSourcesJar"]) - } catch (e: Exception) { - } - } - } -} diff --git a/ts-web/ts-web-coroutine/build.gradle.kts b/ts-web/ts-web-coroutine/build.gradle.kts index 9b60d05..f7af6c3 100644 --- a/ts-web/ts-web-coroutine/build.gradle.kts +++ b/ts-web/ts-web-coroutine/build.gradle.kts @@ -1,6 +1,7 @@ plugins { kotlin("jvm") `maven-publish` + id("ts-gradle") } dependencies { @@ -12,27 +13,6 @@ dependencies { implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.1") } -@kotlin.Suppress("UNCHECKED_CAST") -(rootProject.ext["excludeTest"] as (Project, TaskContainer) -> Unit)(project, tasks) -tasks.register("install") { - finalizedBy(tasks["publishToMavenLocal"]) -} -publishing { - @Suppress("UNCHECKED_CAST") - (rootProject.ext["publishRepositories"] as (Project, PublishingExtension) -> Unit)(project, this) - publications { - create("maven") { - groupId = project.group.toString() - artifactId = project.name - version = project.version.toString() - from(components["java"]) - try { - artifact(tasks["kotlinSourcesJar"]) - } catch (e: Exception) { - } - } - } -} diff --git a/ts-web/ts-web-netty/build.gradle.kts b/ts-web/ts-web-netty/build.gradle.kts index b45fd9f..b8eab20 100644 --- a/ts-web/ts-web-netty/build.gradle.kts +++ b/ts-web/ts-web-netty/build.gradle.kts @@ -1,6 +1,7 @@ plugins { kotlin("jvm") `maven-publish` + id("ts-gradle") } dependencies { @@ -8,31 +9,10 @@ dependencies { api(project(":ts-core:ts-buffer")) api(project(":ts-core:ts-log")) api(project(":ts-web")) - api(group = "io.netty", name = "netty-all", version = "4.1.67.Final") + api(group = "io.netty", name = "netty-all", version = nettyVersion) api(group = "org.slf4j", name = "slf4j-api", version = "1.7.32") } -@kotlin.Suppress("UNCHECKED_CAST") -(rootProject.ext["excludeTest"] as (Project, TaskContainer) -> Unit)(project, tasks) -tasks.register("install") { - finalizedBy(tasks["publishToMavenLocal"]) -} -publishing { - @Suppress("UNCHECKED_CAST") - (rootProject.ext["publishRepositories"] as (Project, PublishingExtension) -> Unit)(project, this) - publications { - create("maven") { - groupId = project.group.toString() - artifactId = project.name - version = project.version.toString() - from(components["java"]) - try { - artifact(tasks["kotlinSourcesJar"]) - } catch (e: Exception) { - } - } - } -}