Skip to content

Refactor Gradle scripts and use build-logic #114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
plugins {
`kotlin-dsl`
}

dependencies {
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.22")
implementation("com.alecstrong:grammar-kit-composer:0.1.10")
implementation("io.github.gradle-nexus:publish-plugin:1.1.0")
implementation("org.jetbrains.kotlinx.binary-compatibility-validator:org.jetbrains.kotlinx.binary-compatibility-validator.gradle.plugin:0.12.1")
implementation("gradle.plugin.com.github.johnrengelman:shadow:7.1.2")
implementation("app.cash.sqldelight:gradle-plugin:2.0.0-alpha04")
implementation("app.cash.licensee:licensee-gradle-plugin:1.6.0")
}

gradlePlugin {
plugins {
create("MyRepos") {
id = "MyRepos"
implementationClass = "MyRepos"
}
create("repos") {
id = "repos"
implementationClass = "Repos"
}
}
}
9 changes: 9 additions & 0 deletions build-logic/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
gradlePluginPortal()
}
}

rootProject.name = "build-logic"
24 changes: 24 additions & 0 deletions build-logic/src/main/kotlin/MyRepos.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import org.gradle.api.*
import org.gradle.api.artifacts.dsl.*
import org.gradle.api.initialization.*
import org.gradle.kotlin.dsl.*

class MyRepos : Plugin<Settings> {
override fun apply(settings: Settings) {
settings.dependencyResolutionManagement {
repositories {
repos()
}
}
}
}

fun RepositoryHandler.repos() {
maven(url = "https://s01.oss.sonatype.org/content/repositories/snapshots/")
mavenCentral()

maven(url = "https://www.jetbrains.com/intellij-repository/releases")
maven(url = "https://cache-redirector.jetbrains.com/intellij-dependencies")
maven(url = "https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-ide-plugin-dependencies/")
maven(url = "https://maven.pkg.jetbrains.space/public/p/ktor/eap")
}
9 changes: 9 additions & 0 deletions build-logic/src/main/kotlin/Repos.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import org.gradle.api.*

class Repos: Plugin<Project> {
override fun apply(project: Project) {
project.repositories.apply {
repos()
}
}
}
12 changes: 12 additions & 0 deletions build-logic/src/main/kotlin/exclude.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
configurations.configureEach {
exclude(group = "com.jetbrains.rd")
exclude(group = "com.github.jetbrains", module = "jetCheck")
exclude(group = "com.jetbrains.infra")

exclude(group = "org.roaringbitmap")

exclude(group = "ai.grazie.spell")
exclude(group = "ai.grazie.model")
exclude(group = "ai.grazie.utils")
exclude(group = "ai.grazie.nlp")
}
61 changes: 61 additions & 0 deletions build-logic/src/main/kotlin/publish.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import org.gradle.api.artifacts.repositories.*
import org.gradle.api.publish.maven.*
import org.gradle.api.tasks.bundling.*
import org.gradle.kotlin.dsl.*
import java.util.*

plugins {
`maven-publish`
signing
}

val emptyJar by tasks.registering(Jar::class) { }

publishing {
repositories {
maven(url = "https://maven.pkg.github.com/hfhbd/kobol") {
name = "GitHubPackages"
credentials(PasswordCredentials::class)
}
}
publications.all {
this as MavenPublication
artifact(emptyJar) {
classifier = "javadoc"
}
pom {
name.set("app.softwork Postgres Native Driver and SqlDelight Dialect")
description.set("A Postgres native driver including support for SqlDelight")
url.set("https://github.com/hfhbd/SqlDelightNativePostgres")
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
developers {
developer {
id.set("hfhbd")
name.set("Philip Wedemann")
email.set("[email protected]")
}
}
scm {
connection.set("scm:git://github.com/hfhbd/SqlDelightNativePostgres.git")
developerConnection.set("scm:git://github.com/hfhbd/SqlDelightNativePostgres.git")
url.set("https://github.com/hfhbd/SqlDelightNativePostgres")
}
}
}
}

(System.getProperty("signing.privateKey") ?: System.getenv("SIGNING_PRIVATE_KEY"))?.let {
String(Base64.getDecoder().decode(it)).trim()
}?.let { key ->
println("found key, config signing")
signing {
val signingPassword = System.getProperty("signing.password") ?: System.getenv("SIGNING_PASSWORD")
useInMemoryPgpKeys(key, signingPassword)
sign(publishing.publications)
}
}
93 changes: 1 addition & 92 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,96 +1,5 @@
import app.cash.licensee.*
import org.jetbrains.kotlin.gradle.dsl.*
import java.util.*

plugins {
kotlin("multiplatform") version "1.7.22" apply false
`maven-publish`
signing
id("io.github.gradle-nexus.publish-plugin") version "1.1.0"
id("org.jetbrains.kotlinx.binary-compatibility-validator") version "0.12.1"
id("com.github.johnrengelman.shadow") version "7.1.2" apply false
id("com.alecstrong.grammar.kit.composer") version "0.1.10" apply false
id("app.cash.sqldelight") version "2.0.0-alpha04" apply false
id("app.cash.licensee") version "1.6.0" apply false
}

repositories {
mavenCentral()
}

group = "app.softwork"

subprojects {
if (this.name == "testing") {
return@subprojects
}

plugins.apply("app.cash.licensee")
configure<LicenseeExtension> {
allow("Apache-2.0")
allow("MIT")
allowUrl("https://jdbc.postgresql.org/about/license.html")
}

afterEvaluate {
configure<KotlinProjectExtension> {
explicitApi()
sourceSets {
all {
languageSettings.progressiveMode = true
}
}
}
}

plugins.apply("org.gradle.maven-publish")
plugins.apply("org.gradle.signing")
val emptyJar by tasks.creating(Jar::class) { }

group = "app.softwork"

publishing {
publications.all {
this as MavenPublication
artifact(emptyJar) {
classifier = "javadoc"
}
pom {
name.set("app.softwork Postgres Native Driver and SqlDelight Dialect")
description.set("A Postgres native driver including support for SqlDelight")
url.set("https://github.com/hfhbd/kotlinx-serialization-csv")
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
developers {
developer {
id.set("hfhbd")
name.set("Philip Wedemann")
email.set("[email protected]")
}
}
scm {
connection.set("scm:git://github.com/hfhbd/SqlDelightNativePostgres.git")
developerConnection.set("scm:git://github.com/hfhbd/SqlDelightNativePostgres.git")
url.set("https://github.com/hfhbd/SqlDelightNativePostgres")
}
}
}
}

(System.getProperty("signing.privateKey") ?: System.getenv("SIGNING_PRIVATE_KEY"))?.let {
String(Base64.getDecoder().decode(it)).trim()
}?.let { key ->
println("found key, config signing")
signing {
val signingPassword = System.getProperty("signing.password") ?: System.getenv("SIGNING_PASSWORD")
useInMemoryPgpKeys(key, signingPassword)
sign(publishing.publications)
}
}
id("io.github.gradle-nexus.publish-plugin")
}

nexusPublishing {
Expand Down
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ kotlin.native.cacheKind.linuxX64=none

org.gradle.parallel=true
org.gradle.jvmargs=-Xmx2048m

group=app.softwork
38 changes: 19 additions & 19 deletions postgres-native-sqldelight-dialect/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,20 @@ import org.jetbrains.grammarkit.tasks.*

plugins {
kotlin("jvm")
`maven-publish`
id("com.github.johnrengelman.shadow")
id("com.alecstrong.grammar.kit.composer")
com.alecstrong.grammar.kit.composer
com.github.johnrengelman.shadow
org.jetbrains.kotlinx.`binary-compatibility-validator`
app.cash.licensee
repos
publish
exclude
}

java {
withJavadocJar()
withSourcesJar()
}

repositories {
mavenCentral()
maven(url = "https://www.jetbrains.com/intellij-repository/releases")
maven(url = "https://cache-redirector.jetbrains.com/intellij-dependencies")
maven(url = "https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-ide-plugin-dependencies/")
maven(url = "https://maven.pkg.jetbrains.space/public/p/ktor/eap")
}

val idea = "222.4459.24"

grammarKit {
Expand Down Expand Up @@ -55,14 +51,12 @@ kotlin {
target.compilations.all {
kotlinOptions.allWarningsAsErrors = true
}
}

configurations.all {
exclude(group = "com.jetbrains.rd")
exclude(group = "com.github.jetbrains", module = "jetCheck")
exclude(group = "org.roaringbitmap")
exclude(group = "com.jetbrains.intellij.remoteDev")
exclude(group = "com.jetbrains.intellij.spellchecker")
explicitApi()
sourceSets {
all {
languageSettings.progressiveMode = true
}
}
}

tasks {
Expand Down Expand Up @@ -131,3 +125,9 @@ publishing {
}
}
}

licensee {
allow("Apache-2.0")
allow("MIT")
allowUrl("https://jdbc.postgresql.org/about/license.html")
}
17 changes: 13 additions & 4 deletions postgres-native-sqldelight-driver/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.*

plugins {
kotlin("multiplatform")
}

repositories {
mavenCentral()
app.cash.licensee
repos
}

kotlin {
explicitApi()
sourceSets {
all {
languageSettings.progressiveMode = true
}
}

fun KotlinNativeTarget.config() {
compilations.getByName("main") {
cinterops {
Expand Down Expand Up @@ -48,3 +53,7 @@ kotlin {
}
}
}

licensee {
allow("Apache-2.0")
}
12 changes: 12 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
}
includeBuild("build-logic")
}

plugins {
id("MyRepos")
}

rootProject.name = "postgres-native-sqldelight"

enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
Expand Down
7 changes: 2 additions & 5 deletions testing/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
plugins {
kotlin("multiplatform")
id("app.cash.sqldelight")
}

repositories {
mavenCentral()
app.cash.sqldelight
repos
}

kotlin {
Expand Down