diff --git a/build.gradle.kts b/build.gradle.kts index e5bf76e940..3a4825dfaa 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,19 +1,25 @@ import io.gitlab.arturbosch.detekt.Detekt import io.gitlab.arturbosch.detekt.report.ReportMergeTask +import org.jetbrains.exposed.gradle.configureDetekt +import org.jetbrains.exposed.gradle.configurePublishing import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile plugins { kotlin("jvm") apply true - id("io.github.gradle-nexus.publish-plugin") apply true id("io.gitlab.arturbosch.detekt") id("org.jetbrains.kotlinx.binary-compatibility-validator") version "0.13.2" } +repositories { + mavenLocal() + mavenCentral() +} + allprojects { - apply(from = rootProject.file("buildScripts/gradle/checkstyle.gradle.kts")) + configureDetekt() if (this.name != "exposed-tests" && this.name != "exposed-bom" && this != rootProject) { - apply(from = rootProject.file("buildScripts/gradle/publishing.gradle.kts")) + configurePublishing() } } @@ -30,12 +36,14 @@ subprojects { detektPlugins("io.gitlab.arturbosch.detekt", "detekt-formatting", "1.21.0") } tasks.withType().configureEach detekt@{ - enabled = this@subprojects.name !== "exposed-tests" + onlyIf { this@subprojects.name !== "exposed-tests" } + finalizedBy(reportMerge) reportMerge.configure { input.from(this@detekt.xmlReportFile) } } + tasks.withType().configureEach { kotlinOptions { jvmTarget = "1.8" @@ -44,8 +52,3 @@ subprojects { } } } - -repositories { - mavenLocal() - mavenCentral() -} diff --git a/buildScripts/gradle/checkstyle.gradle.kts b/buildScripts/gradle/checkstyle.gradle.kts deleted file mode 100644 index 997e95ad09..0000000000 --- a/buildScripts/gradle/checkstyle.gradle.kts +++ /dev/null @@ -1,20 +0,0 @@ -import io.gitlab.arturbosch.detekt.DetektPlugin -import io.gitlab.arturbosch.detekt.extensions.DetektExtension - -apply() - -configure { - ignoreFailures = false - buildUponDefaultConfig = true - config = files( - rootDir.resolve("detekt/detekt-config.yml").takeIf { it.isFile }, - projectDir.resolve("detekt/detekt-config.yml").takeIf { it.isFile } - ) - reports { - xml.enabled = true - html.enabled = false - txt.enabled = false - sarif.enabled = false - } - parallel = true -} diff --git a/buildScripts/gradle/publishing.gradle.kts b/buildScripts/gradle/publishing.gradle.kts deleted file mode 100644 index ed3390689e..0000000000 --- a/buildScripts/gradle/publishing.gradle.kts +++ /dev/null @@ -1,41 +0,0 @@ -import org.jetbrains.exposed.gradle.* - -apply(plugin = "java-library") -apply(plugin = "maven-publish") -apply(plugin = "signing") - -_java { - withJavadocJar() - withSourcesJar() -} - -val version: String by rootProject - -_publishing { - publications { - create("exposed") { - groupId = "org.jetbrains.exposed" - artifactId = project.name - version = version - from(components["java"]) - pom { - configureMavenCentralMetadata(project) - } - signPublicationIfKeyPresent(project) - } - } - - val publishingUsername: String? = System.getenv("PUBLISHING_USERNAME") - val publishingPassword: String? = System.getenv("PUBLISHING_PASSWORD") - - repositories { - maven { - name = "Exposed" - url = uri("https://maven.pkg.jetbrains.space/public/p/exposed/release") - credentials { - username = publishingUsername - password = publishingPassword - } - } - } -} diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 7236698310..a1cbabf0ed 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -7,7 +7,6 @@ dependencies { gradleApi() implementation("org.jetbrains.kotlin.jvm", "org.jetbrains.kotlin.jvm.gradle.plugin", "1.9.0") implementation("com.avast.gradle", "gradle-docker-compose-plugin", "0.14.9") - implementation("io.github.gradle-nexus", "publish-plugin", "1.0.0") implementation("io.gitlab.arturbosch.detekt", "detekt-gradle-plugin", "1.21.0") } diff --git a/buildSrc/src/main/kotlin/org/jetbrains/exposed/gradle/Detekt.kt b/buildSrc/src/main/kotlin/org/jetbrains/exposed/gradle/Detekt.kt new file mode 100644 index 0000000000..d8ab2eb573 --- /dev/null +++ b/buildSrc/src/main/kotlin/org/jetbrains/exposed/gradle/Detekt.kt @@ -0,0 +1,28 @@ +package org.jetbrains.exposed.gradle + +import io.gitlab.arturbosch.detekt.DetektPlugin +import io.gitlab.arturbosch.detekt.extensions.DetektExtension +import org.gradle.api.Project +import org.gradle.kotlin.dsl.apply +import org.gradle.kotlin.dsl.configure + + +fun Project.configureDetekt() { + apply() + + configure { + ignoreFailures = false + buildUponDefaultConfig = true + config = files( + rootDir.resolve("detekt/detekt-config.yml").takeIf { it.isFile }, + projectDir.resolve("detekt/detekt-config.yml").takeIf { it.isFile } + ) + reports { + xml.enabled = true + html.enabled = false + txt.enabled = false + sarif.enabled = false + } + parallel = true + } +} diff --git a/buildSrc/src/main/kotlin/org/jetbrains/exposed/gradle/Publishing.kt b/buildSrc/src/main/kotlin/org/jetbrains/exposed/gradle/Publishing.kt index 7e4ee7b6fe..1b784e7ad4 100644 --- a/buildSrc/src/main/kotlin/org/jetbrains/exposed/gradle/Publishing.kt +++ b/buildSrc/src/main/kotlin/org/jetbrains/exposed/gradle/Publishing.kt @@ -6,6 +6,10 @@ import org.gradle.api.provider.Property import org.gradle.api.publish.PublishingExtension import org.gradle.api.publish.maven.MavenPom import org.gradle.api.publish.maven.MavenPublication +import org.gradle.kotlin.dsl.apply +import org.gradle.kotlin.dsl.create +import org.gradle.kotlin.dsl.get +import org.gradle.kotlin.dsl.provideDelegate import org.gradle.plugins.signing.SigningExtension infix fun Property.by(value: T) { @@ -53,12 +57,54 @@ fun MavenPublication.signPublicationIfKeyPresent(project: Project) { } } -@Suppress("FunctionNaming") -fun Project._publishing(configure: PublishingExtension.() -> Unit) { +fun Project.publishing(configure: PublishingExtension.() -> Unit) { extensions.configure("publishing", configure) } -@Suppress("FunctionNaming") -fun Project._java(configure: JavaPluginExtension.() -> Unit) { +fun Project.java(configure: JavaPluginExtension.() -> Unit) { extensions.configure("java", configure) } + +fun Project.configurePublishing() { + apply(plugin = "java-library") + apply(plugin = "maven-publish") + apply(plugin = "signing") + + java { + withJavadocJar() + withSourcesJar() + } + + val version: String by rootProject + + publishing { + publications { + create("exposed") { + groupId = "org.jetbrains.exposed" + artifactId = project.name + + setVersion(version) + + from(components["java"]) + pom { + configureMavenCentralMetadata(project) + } + signPublicationIfKeyPresent(project) + } + } + + val publishingUsername: String? = System.getenv("PUBLISHING_USERNAME") + val publishingPassword: String? = System.getenv("PUBLISHING_PASSWORD") + + repositories { + maven { + name = "Exposed" + url = uri("https://maven.pkg.jetbrains.space/public/p/exposed/release") + credentials { + username = publishingUsername + password = publishingPassword + } + } + } + } +}