Skip to content

Commit

Permalink
Make all build scripts indexed, cleanup unused plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
e5l committed Aug 21, 2023
1 parent fb94e6a commit 8a2c61c
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 75 deletions.
21 changes: 12 additions & 9 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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()
}
}

Expand All @@ -30,12 +36,14 @@ subprojects {
detektPlugins("io.gitlab.arturbosch.detekt", "detekt-formatting", "1.21.0")
}
tasks.withType<Detekt>().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<KotlinJvmCompile>().configureEach {
kotlinOptions {
jvmTarget = "1.8"
Expand All @@ -44,8 +52,3 @@ subprojects {
}
}
}

repositories {
mavenLocal()
mavenCentral()
}
20 changes: 0 additions & 20 deletions buildScripts/gradle/checkstyle.gradle.kts

This file was deleted.

41 changes: 0 additions & 41 deletions buildScripts/gradle/publishing.gradle.kts

This file was deleted.

1 change: 0 additions & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

Expand Down
28 changes: 28 additions & 0 deletions buildSrc/src/main/kotlin/org/jetbrains/exposed/gradle/Detekt.kt
Original file line number Diff line number Diff line change
@@ -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<DetektPlugin>()

configure<DetektExtension> {
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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 <T> Property<T>.by(value: T) {
Expand Down Expand Up @@ -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<MavenPublication>("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
}
}
}
}
}

0 comments on commit 8a2c61c

Please sign in to comment.