Skip to content

Commit

Permalink
Merge pull request #122 from TouK/gradle_kts
Browse files Browse the repository at this point in the history
Migrate build.gradle to Kotlin
  • Loading branch information
pjagielski authored Jul 27, 2022
2 parents 923083b + c526108 commit b3e08b0
Show file tree
Hide file tree
Showing 19 changed files with 396 additions and 299 deletions.
25 changes: 0 additions & 25 deletions annotation-processor/build.gradle

This file was deleted.

28 changes: 28 additions & 0 deletions annotation-processor/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import pl.touk.krush.gradle.Versions

plugins {
id("kotlin")
id("kotlin-kapt")
}

dependencies {
implementation("org.jetbrains.kotlin:kotlin-reflect:${Versions.kotlin}")
implementation("com.squareup:kotlinpoet:${Versions.kotlinpoet}")
implementation("com.squareup:kotlinpoet-metadata:${Versions.kotlinpoet}")

api("org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.2.Final")

api(project(":runtime"))

testImplementation("org.junit.jupiter:junit-jupiter:${Versions.junit}")
testImplementation("org.assertj:assertj-core:${Versions.assertj}")
testRuntimeOnly("ch.qos.logback:logback-classic:${Versions.logback}")
testImplementation("io.github.jbock-java:compile-testing:0.19.12")
}

tasks.test {
useJUnitPlatform()
testLogging {
events("passed", "skipped", "failed")
}
}
106 changes: 0 additions & 106 deletions build.gradle

This file was deleted.

97 changes: 97 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import pl.touk.krush.gradle.signPublicationIfKeyPresent

plugins {
kotlin("jvm") apply true
kotlin("kapt") apply true
kotlin("plugin.serialization") version "1.7.10"
id("pl.allegro.tech.build.axion-release") version "1.13.14"
`maven-publish`
}

scmVersion {
useHighestVersion = true
tag {
prefix = "krush-"
}
}

group = "pl.touk.krush"
project.version = scmVersion.version
val rootVersion = scmVersion.version

allprojects {
repositories {
mavenCentral()
}
}

val snapshot = scmVersion.version.endsWith("SNAPSHOT")

configure(listOf(project(":annotation-processor"), project(":runtime"), project(":runtime-postgresql"))) {
apply(plugin = "java")
apply(plugin = "maven-publish")
apply(plugin = "signing")

tasks.withType(Sign::class.java) {
onlyIf { snapshot.not() }
}

java {
withSourcesJar()
withJavadocJar()
}

publishing {
publications {
create<MavenPublication>("maven") {
groupId = "pl.touk.krush"
artifactId = "krush-${project.name}"
version = rootVersion

from(components["java"])

pom {
name.set("krush-${project.name}")
description.set("Krush, idiomatic persistence layer for Kotlin")
url.set("https://github.com/TouK/krush")
scm {
url.set("scm:[email protected]:TouK/krush.git")
connection.set("scm:[email protected]:TouK/krush.git")
developerConnection.set("scm:[email protected]:TouK/krush.git")
}
licenses {
license {
name.set("The Apache Software License, Version 2.0")
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
developers {
developer {
id.set("mateusz_sledz")
name.set("Mateusz Śledź")
}
developer {
id.set("piotr_jagielski")
name.set("Piotr Jagielski")
}
}
}
signPublicationIfKeyPresent(project)
}
}

repositories {
maven {
credentials {
username = System.getenv("SONATYPE_USERNAME")
password = System.getenv("SONATYPE_PASSWORD")
}
val releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
val snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
url = uri(if (snapshot) snapshotsRepoUrl else releasesRepoUrl)
}
}
}


}
14 changes: 14 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
repositories {
mavenCentral()
gradlePluginPortal()
}

dependencies {
gradleApi()
implementation("org.jetbrains.kotlin.jvm", "org.jetbrains.kotlin.jvm.gradle.plugin", "1.7.10")
implementation("io.github.gradle-nexus", "publish-plugin", "1.0.0")
}

plugins {
`kotlin-dsl` apply true
}
16 changes: 16 additions & 0 deletions buildSrc/src/main/kotlin/pl/touk/krush/gradle/Signing.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package pl.touk.krush.gradle

import org.gradle.api.Project
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.plugins.signing.SigningExtension

fun MavenPublication.signPublicationIfKeyPresent(project: Project) {
val signingKey = System.getenv("SIGNING_PRIVATE_KEY")
val signingKeyPassphrase = System.getenv("SIGNING_PASSWORD")
if (!signingKey.isNullOrBlank()) {
project.extensions.configure<SigningExtension>("signing") {
useInMemoryPgpKeys(signingKey.replace(" ", "\r\n"), signingKeyPassphrase)
sign(this@signPublicationIfKeyPresent)
}
}
}
12 changes: 12 additions & 0 deletions buildSrc/src/main/kotlin/pl/touk/krush/gradle/Versions.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package pl.touk.krush.gradle

object Versions {
const val kotlin = "1.7.10"
const val exposed = "0.38.2"
const val kotlinpoet = "1.12.0"
const val postgresDriver = "42.4.0"
const val junit = "5.8.2"
const val assertj = "3.23.1"
const val logback = "1.2.11"
const val testContainers = "1.17.2"
}
33 changes: 0 additions & 33 deletions example/build.gradle

This file was deleted.

36 changes: 36 additions & 0 deletions example/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import pl.touk.krush.gradle.Versions

plugins {
id("kotlin")
id("kotlin-kapt")
id("kotlinx-serialization")
}

dependencies {
api("org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.2")

api(project(":runtime"))
api(project(":runtime-postgresql"))
api(project(":annotation-processor"))
kapt(project(":annotation-processor"))

implementation("com.h2database:h2:2.1.210")
implementation("org.postgresql:postgresql:${Versions.postgresDriver}")
implementation("org.flywaydb:flyway-core:8.5.13")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.0-RC")

testImplementation("org.junit.jupiter:junit-jupiter:${Versions.junit}")
testImplementation("org.testcontainers:testcontainers:${Versions.testContainers}")
testImplementation("org.testcontainers:junit-jupiter:${Versions.testContainers}")
testImplementation("org.testcontainers:postgresql:${Versions.testContainers}")
testImplementation("org.assertj:assertj-core:${Versions.assertj}")
testRuntimeOnly("ch.qos.logback:logback-classic:${Versions.logback}")
}

tasks.test {
useJUnitPlatform()
testLogging {
events("passed", "skipped", "failed")
}
}

6 changes: 3 additions & 3 deletions example/src/test/resources/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
</encoder>
</appender>

<root level="info">
<root level="INFO">
<appender-ref ref="STDOUT" />
</root>

<logger name="Exposed" level="debug">
<appender-ref ref="CONSOLE"/>
<logger name="Exposed" level="DEBUG">
<appender-ref ref="STDOUT"/>
</logger>

</configuration>
4 changes: 0 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
kapt.verbose=true
kotlin.incremental=true
kapt.incremental.apt=true

kotlin_version=1.7.0
exposed_version=0.38.2
kotlinpoet_version=1.12.0
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
Loading

0 comments on commit b3e08b0

Please sign in to comment.