Skip to content

Commit

Permalink
Switch to build.gradle.kts
Browse files Browse the repository at this point in the history
  • Loading branch information
pjagielski committed Jul 26, 2022
1 parent b32cd4d commit 95f1fb2
Show file tree
Hide file tree
Showing 13 changed files with 165 additions and 128 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")
}
}
86 changes: 37 additions & 49 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,28 +1,21 @@
buildscript {
repositories {
mavenCentral()
}

dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
}
}
import pl.touk.krush.gradle.signPublicationIfKeyPresent

plugins {
id 'org.jetbrains.kotlin.jvm' version '1.7.0'
id 'pl.allegro.tech.build.axion-release' version '1.13.14'
id 'maven-publish'
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-'
prefix = "krush-"
}
}

group = 'pl.touk.krush'
group = "pl.touk.krush"
project.version = scmVersion.version

allprojects {
Expand All @@ -31,57 +24,56 @@ allprojects {
}
}

configure([project(':annotation-processor'), project(':runtime'), project(':runtime-postgresql')]) {
apply plugin: 'java'
apply plugin: 'maven-publish'
apply plugin: 'signing'
val snapshot = scmVersion.version.endsWith("SNAPSHOT")

def 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) {
onlyIf { !snapshot }
tasks.withType(Sign::class.java) {
onlyIf { snapshot.not() }
}

java {
withJavadocJar()
withSourcesJar()
withJavadocJar()
}

publishing {
publications {
mavenJava(MavenPublication) {
artifactId "krush-${project.name}"
from components.java
pom {
groupId = 'pl.touk.krush'
name = "krush-${project.name}"
version = scmVersion.version
create<MavenPublication>("maven") {
groupId = "pl.touk.krush"
artifactId = "krush-${project.name}"

description = 'Krush, idiomatic persistence layer for Kotlin'
url = 'https://github.com/TouK/sputnik/'
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 = 'scm:[email protected]:TouK/krush.git'
connection = 'scm:[email protected]:TouK/krush.git'
developerConnection = 'scm:[email protected]:Touk/krush.git'
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 = 'The Apache Software License, Version 2.0'
url = 'https://www.apache.org/licenses/LICENSE-2.0.txt'
distribution = 'repo'
name.set("The Apache Software License, Version 2.0")
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
developers {
developer {
id = 'mateusz_sledz'
name = 'Mateusz Śledź'
id.set("mateusz_sledz")
name.set("Mateusz Śledź")
}
developer {
id = 'piotr_jagielski'
name = 'Piotr Jagielski'
id.set("piotr_jagielski")
name.set("Piotr Jagielski")
}
}
}
signPublicationIfKeyPresent(project)
}
}

Expand All @@ -91,16 +83,12 @@ configure([project(':annotation-processor'), project(':runtime'), project(':runt
username = System.getenv("SONATYPE_USERNAME")
password = System.getenv("SONATYPE_PASSWORD")
}
def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
url = snapshot ? snapshotsRepoUrl : releasesRepoUrl
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)
}
}
}

signing {
useInMemoryPgpKeys(System.getenv('SIGNING_PRIVATE_KEY'), System.getenv('SIGNING_PASSWORD'))
sign publishing.publications.mavenJava
}

}
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")
}
}

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
7 changes: 0 additions & 7 deletions runtime-postgresql/build.gradle

This file was deleted.

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

plugins {
id("kotlin")
}

dependencies {
api(project(":runtime"))
implementation("org.postgresql:postgresql:${Versions.postgresDriver}")
}
10 changes: 0 additions & 10 deletions runtime/build.gradle

This file was deleted.

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

plugins {
id("kotlin")
}

dependencies {
api("org.jetbrains.kotlin:kotlin-reflect:${Versions.kotlin}")
api("org.jetbrains.exposed:exposed-jdbc:${Versions.exposed}")
api("org.jetbrains.exposed:exposed-core:${Versions.exposed}")
api("org.jetbrains.exposed:exposed-java-time:${Versions.exposed}")
}

0 comments on commit 95f1fb2

Please sign in to comment.