Skip to content

Commit

Permalink
Modernize the build scripts (#207)
Browse files Browse the repository at this point in the history
  • Loading branch information
ansman authored Apr 12, 2023
1 parent 7ee6eb0 commit d72a23d
Show file tree
Hide file tree
Showing 36 changed files with 559 additions and 532 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: '11'
distribution: 'zulu'
java-version: '19'
cache: 'gradle'
- name: Run Checks
run: ./gradlew check --continue --stacktrace -Pkotshi.createAnnotationsUsingConstructor=false
Expand All @@ -24,8 +24,8 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: '11'
distribution: 'zulu'
java-version: '19'
cache: 'gradle'
- name: Run Checks
run: ./gradlew check --continue --stacktrace
Expand All @@ -35,8 +35,8 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: '11'
distribution: 'zulu'
java-version: '19'
cache: 'gradle'
- name: Run Checks
run: ./gradlew check --continue --stacktrace -Pkotshi.useLegacyDataClassRenderer=true
Expand All @@ -47,8 +47,8 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: '11'
distribution: 'zulu'
java-version: '19'
cache: 'gradle'
- name: Deploy snapshot
run: ./gradlew publishSnapshot --stacktrace
Expand Down
39 changes: 5 additions & 34 deletions api/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,41 +1,19 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
//import org.jetbrains.kotlin.incremental.mkdirsOrThrow
import java.net.URL
import org.jetbrains.dokka.gradle.DokkaTask

plugins {
`published-library`
id("published-library")
}

dependencies {
api(deps.moshi.oldestSupported)
testImplementation(deps.junit)
testImplementation(deps.truth)
testImplementation(deps.kotlin.junit)
}

tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = freeCompilerArgs + listOf(
"-opt-in=kotlin.RequiresOptIn"
)
}
}

tasks.compileTestKotlin {
kotlinOptions {
freeCompilerArgs = freeCompilerArgs + listOf(
"-Xjvm-default=all"
)
}
api(libs.moshi.oldestSupported)
}

val packagesMarkdown = buildDir.resolve("generated/docs/packages.md")
val buildPackagesDocs by tasks.registering(Task::class) {
val buildPackagesDocs by tasks.registering {
val readme = rootDir.resolve("README.md")
inputs.file(readme)
outputs.file(packagesMarkdown)
doFirst {
// packagesMarkdown.parentFile!!.mkdirsOrThrow()
packagesMarkdown.writer().use { writer ->
writer.write("# Module kotshi\n\n")
readme.reader().use { reader ->
Expand All @@ -45,18 +23,11 @@ val buildPackagesDocs by tasks.registering(Task::class) {
}
}

tasks.withType<org.jetbrains.dokka.gradle.DokkaTask> {
tasks.withType<DokkaTask>().configureEach {
dependsOn(buildPackagesDocs)
moduleName.set("kotshi")
dokkaSourceSets {
configureEach {
sourceLink {
localDirectory.set(file("src/main/kotlin"))
remoteUrl.set(URL("https://github.com/ansman/kotshi/blob/main/api/src/main/kotlin"))
remoteLineSuffix.set("#L")
}
externalDocumentationLink { url.set(URL("https://square.github.io/okio/2.x/okio/")) }
externalDocumentationLink { url.set(URL("https://square.github.io/moshi/1.x/moshi/")) }
includes.from(packagesMarkdown)
}
}
Expand Down
4 changes: 3 additions & 1 deletion api/src/test/kotlin/se/ansman/kotshi/TestKotshiUtils.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package se.ansman.kotshi

import com.google.common.truth.Truth.assertThat
import assertk.assertThat
import assertk.assertions.isEqualTo
import assertk.assertions.isNotEqualTo
import com.squareup.moshi.JsonQualifier
import org.junit.Test
import se.ansman.kotshi.KotshiUtils.createJsonQualifierImplementation
Expand Down
29 changes: 2 additions & 27 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,33 +1,8 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
id("org.jetbrains.kotlinx.binary-compatibility-validator") version "0.11.0"
}

allprojects {
repositories {
google()
mavenCentral()
mavenLocal()
}
tasks.withType<Javadoc> { enabled = false }
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = freeCompilerArgs + listOf(
"-opt-in=kotlin.RequiresOptIn"
)
}
}
kotlin("jvm") version libs.versions.kotlin.get() apply false
alias(libs.plugins.kotlinx.binaryCompatibilityValidator)
}

apiValidation {
allprojects.filterNot { it.path == ":api" }.mapTo(ignoredProjects) { it.name }
}

tasks.register("publishSnapshot") {
if (version.toString().endsWith("-SNAPSHOT")) {
for (project in allprojects) {
project.tasks.findByName("publishAllPublicationsToSonatypeSnapshotsRepository")?.let { dependsOn(it) }
}
}
}
47 changes: 0 additions & 47 deletions buildSrc/build.gradle.kts

This file was deleted.

1 change: 0 additions & 1 deletion buildSrc/settings.gradle.kts

This file was deleted.

48 changes: 0 additions & 48 deletions buildSrc/src/main/kotlin/deps.kt

This file was deleted.

29 changes: 0 additions & 29 deletions buildSrc/src/main/kotlin/se/ansman/kotshi/gradle/LibraryPlugin.kt

This file was deleted.

11 changes: 0 additions & 11 deletions buildSrc/src/main/kotlin/se/ansman/kotshi/gradle/Projects.kt

This file was deleted.

Loading

0 comments on commit d72a23d

Please sign in to comment.