Skip to content

Commit

Permalink
Base, jvm-only mulitplatform setup
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszkwiecinski committed Jun 23, 2024
1 parent d326c6f commit b3285bb
Show file tree
Hide file tree
Showing 22 changed files with 91 additions and 86 deletions.
8 changes: 2 additions & 6 deletions .github/workflows/on-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@ jobs:

- run: git diff --exit-code

- uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}

- uses: actions/upload-artifact@v4
if: ${{ always() }}
with:
Expand Down Expand Up @@ -98,7 +94,7 @@ jobs:
path: diffuse-source-file
key: diffuse-${{ github.sha }}

- run: find . -regex ".*issuechecker/build/libs/issuechecker-[0-9SNAPSHOT\.-]*\.jar" -print | xargs -n 1 -I % cp % diffuse-source-file
- run: find . -regex ".*issuechecker/build/libs/issuechecker-jvm-[0-9SNAPSHOT\.-]*\.jar" -print | xargs -n 1 -I % cp % diffuse-source-file
if: github.event_name != 'pull_request'
shell: bash

Expand All @@ -109,7 +105,7 @@ jobs:
path: diffuse-source-file
key: diffuse-${{ github.event.pull_request.base.sha }}

- run: find . -regex ".*issuechecker/build/libs/issuechecker-[0-9SNAPSHOT\.-]*\.jar" -print | xargs -n 1 -I % cp % pull-request-artifact.jar
- run: find . -regex ".*issuechecker/build/libs/issuechecker-jvm-[0-9SNAPSHOT\.-]*\.jar" -print | xargs -n 1 -I % cp % pull-request-artifact.jar
if: github.event_name == 'pull_request'
shell: bash

Expand Down
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ osacky-gradledoctor = { id = "com.osacky.doctor", version.ref = "gradle-gradledo
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "mavencentral-kotlin" }
starter-config = { id = "com.starter.config", version.ref = "gradle-starter" }
starter-library-kotlin = { id = "com.starter.library.kotlin", version.ref = "gradle-starter" }
starter-library-multiplatform = { id = "com.starter.library.multiplatform", version.ref = "gradle-starter" }
starter-versioning = { id = "com.starter.versioning", version.ref = "gradle-starter" }
johnrengelman-shadow = { id = "com.github.johnrengelman.shadow", version.ref = "gradle-johnrengelman-shadow" }
kotlinx-binarycompatibility = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version.ref = "maven-binarycompatiblity" }
kotlin-samwithreceiver = { id = "org.jetbrains.kotlin.plugin.sam.with.receiver", version.ref = "mavencentral-kotlin" }
5 changes: 5 additions & 0 deletions gradle/plugins/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
plugins {
id 'java-gradle-plugin'
alias(libs.plugins.starter.library.kotlin)
alias(libs.plugins.kotlin.samwithreceiver)
}

samWithReceiver {
annotation("org.gradle.api.HasImplicitReceiver")
}

dependencies {
Expand Down
4 changes: 0 additions & 4 deletions gradle/plugins/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import org.gradle.api.initialization.resolve.RepositoriesMode

plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0"
}

dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
Expand Down
112 changes: 55 additions & 57 deletions gradle/plugins/src/main/kotlin/PublishingPlugin.kt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.plugins.ExtensionContainer
import org.gradle.api.plugins.JavaPluginExtension
import org.gradle.api.publish.PublishingExtension
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.api.tasks.TaskProvider
import org.gradle.jvm.tasks.Jar
import org.gradle.plugins.signing.SigningExtension
import org.jetbrains.dokka.gradle.DokkaTask

@Suppress("unused")
class PublishingPlugin : Plugin<Project> {

override fun apply(target: Project) = with(target) {
Expand All @@ -16,77 +16,79 @@ class PublishingPlugin : Plugin<Project> {
pluginManager.apply("signing")
}

extensions.configure<JavaPluginExtension> {
withSourcesJar()
withJavadocJar()
}

pluginManager.withPlugin("org.jetbrains.kotlin.jvm") {
pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
pluginManager.apply("org.jetbrains.dokka")

tasks.withType(DokkaTask::class.java).configureEach { dokkaTask ->
dokkaTask.notCompatibleWithConfigurationCache("https://github.com/Kotlin/dokka/issues/1217")
tasks.withType(DokkaTask::class.java).configureEach {
notCompatibleWithConfigurationCache("https://github.com/Kotlin/dokka/issues/1217")
}
tasks.named("javadocJar", Jar::class.java) { javadocJar ->
javadocJar.from(tasks.named("dokkaJavadoc"))

tasks.register("javadocJar", Jar::class.java) {
archiveClassifier.set("javadoc")
from(tasks.named("dokkaJavadoc"))
}
}

extensions.configure<PublishingExtension> {
with(repositories) {
maven { maven ->
maven.name = "github"
maven.setUrl("https://maven.pkg.github.com/usefulness/issuechecker")
with(maven.credentials) {
extensions.configure(PublishingExtension::class.java) {
repositories {
maven {
name = "github"
setUrl("https://maven.pkg.github.com/usefulness/issuechecker")
credentials {
username = "usefulness"
password = findConfig("GITHUB_TOKEN")
}
}
maven { maven ->
maven.name = "mavenCentral"
maven.setUrl("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
maven.mavenContent { it.releasesOnly() }
with(maven.credentials) {
maven {
name = "mavenCentral"
setUrl("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
mavenContent { releasesOnly() }
credentials {
username = findConfig("OSSRH_USERNAME")
password = findConfig("OSSRH_PASSWORD")
}
}
maven { maven ->
maven.name = "mavenCentralSnapshot"
maven.setUrl("https://oss.sonatype.org/content/repositories/snapshots")
maven.mavenContent { it.snapshotsOnly() }
with(maven.credentials) {
maven {
name = "mavenCentralSnapshot"
setUrl("https://oss.sonatype.org/content/repositories/snapshots")
mavenContent { snapshotsOnly() }
credentials {
username = findConfig("OSSRH_USERNAME")
password = findConfig("OSSRH_PASSWORD")
}
}
}
with(publications) {
register("mavenJava", MavenPublication::class.java) { publication ->
publication.from(components.getByName("java"))
publication.pom { pom ->
pom.name.set("${project.group}:${project.name}")
pom.description.set("A tool that scans sources for all resolved links to public trackers")
pom.url.set("https://github.com/usefulness/issuechecker")
pom.licenses { licenses ->
licenses.license { license ->
license.name.set("MIT")
license.url.set("https://github.com/usefulness/issuechecker/blob/master/LICENSE")
}
}
pom.developers { developers ->
developers.developer { developer ->
developer.id.set("mateuszkwiecinski")
developer.name.set("Mateusz Kwiecinski")
developer.email.set("36954793+mateuszkwiecinski@users.noreply.github.com")
}
publications.named { it == "jvm" }.configureEach {
this as MavenPublication
artifact(tasks.named("javadocJar"))
}
publications.configureEach {
if (this !is MavenPublication) {
return@configureEach
}

pom {
name.set("${project.group}:${project.name}")
description.set("A tool that scans sources for all resolved links to public trackers")
url.set("https://github.com/usefulness/issuechecker")
licenses {
license {
name.set("MIT")
url.set("https://github.com/usefulness/issuechecker/blob/master/LICENSE")
}
pom.scm { scm ->
scm.connection.set("scm:git:github.com/usefulness/issuechecker.git")
scm.developerConnection.set("scm:git:ssh://github.com/usefulness/issuechecker.git")
scm.url.set("https://github.com/usefulness/issuechecker/tree/master")
}
developers {
developer {
id.set("mateuszkwiecinski")
name.set("Mateusz Kwiecinski")
email.set("36954793+mateuszkwiecinski@users.noreply.github.com")
}
}
scm {
connection.set("scm:git:github.com/usefulness/issuechecker.git")
developerConnection.set("scm:git:ssh://github.com/usefulness/issuechecker.git")
url.set("https://github.com/usefulness/issuechecker/tree/master")
}
}
}
}
Expand All @@ -97,15 +99,11 @@ class PublishingPlugin : Plugin<Project> {
set("signing.secretKeyRingFile", findConfig("SIGNING_SECRET_KEY_RING_FILE"))
}

extensions.configure<SigningExtension>("signing") { signing ->
signing.sign(extensions.getByType(PublishingExtension::class.java).publications)
extensions.configure<SigningExtension>("signing") {
sign(extensions.getByType(PublishingExtension::class.java).publications)
}
}
}

private inline fun <reified T> ExtensionContainer.configure(crossinline receiver: T.() -> Unit) {
configure(T::class.java) { receiver(it) }
}
}

private fun Project.findConfig(key: String): String {
Expand Down
45 changes: 27 additions & 18 deletions issuechecker/build.gradle
Original file line number Diff line number Diff line change
@@ -1,33 +1,42 @@
plugins {
alias(libs.plugins.starter.library.kotlin)
alias(libs.plugins.starter.library.multiplatform)
alias(libs.plugins.kotlin.serialization)
id 'com.starter.publishing'
}

tasks.named("test") {
tasks.withType(Test).configureEach {
useJUnitPlatform()
testLogging {
events "skipped", "failed"
}
}

kotlin {
jvm()

explicitApi()
sourceSets {
commonMain.dependencies {
implementation(libs.coroutines.core)
implementation(libs.okio.core)
implementation(libs.kotlinx.serialization.json)
implementation(project.dependencies.platform(libs.retrofit.bom))
}
jvmMain.dependencies {
api(libs.okhttp.core)
implementation(libs.retrofit.core)
implementation(libs.retrofit.converter.kotlinxserialization)
}
commonTest.dependencies {
implementation(kotlin("test"))
}
jvmTest.dependencies {
runtimeOnly(libs.junit.platform.launcher)
implementation(libs.coroutines.test)
implementation(libs.okhttp.mockwebserver)
implementation(libs.assertj.core)
implementation(libs.junit.jupiter.api)
}
}
}

dependencies {
implementation(libs.coroutines.core)
api(libs.okhttp.core)
implementation(libs.okio.core)
implementation(libs.kotlinx.serialization.json)
implementation(platform(libs.retrofit.bom))
implementation(libs.retrofit.core)
implementation(libs.retrofit.converter.kotlinxserialization)

testRuntimeOnly(libs.junit.platform.launcher)

testImplementation(libs.coroutines.test)
testImplementation(libs.okhttp.mockwebserver)
testImplementation(libs.assertj.core)
testImplementation(libs.junit.jupiter.api)
}
File renamed without changes.
1 change: 0 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ pluginManagement {
}

plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0"
id("com.gradle.develocity") version "3.17.5"
}

Expand Down

0 comments on commit b3285bb

Please sign in to comment.