Skip to content
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

Update template to improve developer experience #34

Merged
merged 6 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
63 changes: 0 additions & 63 deletions .github/workflows/deploy.yml

This file was deleted.

25 changes: 25 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Publish
on:
release:
types: [released, prereleased]
jobs:
publish:
name: Release build and publish
runs-on: macOS-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 21
- name: Publish to MavenCentral
run: ./gradlew publishToMavenCentral --no-configuration-cache
env:
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.SIGNING_KEY_ID }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_KEY_CONTENTS }}

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ captures
.cxx
local.properties
xcuserdata
.kotlin
.kotlin
adam-enko marked this conversation as resolved.
Show resolved Hide resolved
*.gpg
289 changes: 243 additions & 46 deletions README.md

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
plugins {
id("root.publication")
//trick: for the same plugin versions in all sub-modules
alias(libs.plugins.androidLibrary).apply(false)
alias(libs.plugins.kotlinMultiplatform).apply(false)
}
alias(libs.plugins.publish) apply false
adam-enko marked this conversation as resolved.
Show resolved Hide resolved
}
7 changes: 0 additions & 7 deletions convention-plugins/build.gradle.kts

This file was deleted.

21 changes: 0 additions & 21 deletions convention-plugins/settings.gradle.kts

This file was deleted.

51 changes: 0 additions & 51 deletions convention-plugins/src/main/kotlin/module.publication.gradle.kts

This file was deleted.

19 changes: 0 additions & 19 deletions convention-plugins/src/main/kotlin/root.publication.gradle.kts

This file was deleted.

7 changes: 3 additions & 4 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
[versions]
agp = "8.5.0"
kotlin = "2.0.0"
nexus-publish = "2.0.0"
kotlin = "2.0.20"
android-minSdk = "24"
android-compileSdk = "34"

[libraries]
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" }
nexus-publish = { module = "io.github.gradle-nexus.publish-plugin:io.github.gradle-nexus.publish-plugin.gradle.plugin", version.ref = "nexus-publish" }

[plugins]
androidLibrary = { id = "com.android.library", version.ref = "agp" }
kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
adam-enko marked this conversation as resolved.
Show resolved Hide resolved
publish = { id = "com.vanniktech.maven.publish", version = "0.29.0" }
Binary file added images/image1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/image2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/image3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/image4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/image5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/image6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/image7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 39 additions & 1 deletion library/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import com.vanniktech.maven.publish.SonatypeHost
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

group = "io.github.kotlin"
version = "1.0.0"

plugins {
alias(libs.plugins.kotlinMultiplatform)
alias(libs.plugins.androidLibrary)
id("module.publication")
alias(libs.plugins.publish)
}

adam-enko marked this conversation as resolved.
Show resolved Hide resolved
kotlin {
Expand Down Expand Up @@ -42,3 +46,37 @@ android {
minSdk = libs.versions.android.minSdk.get().toInt()
}
}

mavenPublishing {
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)

signAllPublications()

coordinates("io.github.kotlin", "library", "1.0.0")

pom {
name = "My library"
description = "A library."
inceptionYear = "2024"
url = "https://github.com/kotlin/multiplatform-library-template/"
licenses {
license {
name = "XXX"
url = "YYY"
distribution = "ZZZ"
}
}
developers {
developer {
id = "XXX"
name = "YYY"
url = "ZZZ"
}
}
scm {
url = "XXX"
connection = "YYY"
developerConnection = "ZZZ"
}
}
}
2 changes: 2 additions & 0 deletions library/src/androidMain/kotlin/fibiprops.android.kt
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
package io.github.kotlin.fibonacci

actual val firstElement: Int = 1
actual val secondElement: Int = 2
4 changes: 3 additions & 1 deletion library/src/androidUnitTest/kotlin/AndroidFibiTest.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package io.github.kotlin.fibonacci

import kotlin.test.Test
import kotlin.test.assertEquals

class AndroidFibiTest {

@Test
fun `test 3rd element`() {
assertEquals(3, fibi.take(3).last())
assertEquals(3, generateFibi().take(3).last())
}
}
4 changes: 3 additions & 1 deletion library/src/commonMain/kotlin/CustomFibi.kt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
val fibi = sequence {
package io.github.kotlin.fibonacci

fun generateFibi() = sequence {
var a = firstElement
yield(a)
var b = secondElement
Expand Down
4 changes: 3 additions & 1 deletion library/src/commonTest/kotlin/FibiTest.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package io.github.kotlin.fibonacci

import kotlin.test.Test
import kotlin.test.assertEquals

class FibiTest {

@Test
fun `test 3rd element`() {
assertEquals(firstElement + secondElement, fibi.take(3).last())
assertEquals(firstElement + secondElement, generateFibi().take(3).last())
}
}
2 changes: 2 additions & 0 deletions library/src/iosMain/kotlin/fibiprops.ios.kt
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
package io.github.kotlin.fibonacci

actual val firstElement: Int = 3
actual val secondElement: Int = 4
4 changes: 3 additions & 1 deletion library/src/iosTest/kotlin/IosFibiTest.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package io.github.kotlin.fibonacci

import kotlin.test.Test
import kotlin.test.assertEquals

class IosFibiTest {

@Test
fun `test 3rd element`() {
assertEquals(7, fibi.take(3).last())
assertEquals(7, generateFibi().take(3).last())
}
}
2 changes: 2 additions & 0 deletions library/src/jvmMain/kotlin/fibiprops.jvm.kt
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
package io.github.kotlin.fibonacci

actual val firstElement: Int = 2
actual val secondElement: Int = 3
4 changes: 3 additions & 1 deletion library/src/jvmTest/kotlin/JvmFibiTest.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package io.github.kotlin.fibonacci

import kotlin.test.Test
import kotlin.test.assertEquals

class JvmFibiTest {

@Test
fun `test 3rd element`() {
assertEquals(5, fibi.take(3).last())
assertEquals(5, generateFibi().take(3).last())
}
}
2 changes: 2 additions & 0 deletions library/src/linuxX64Main/kotlin/fibiprops.linuxX64.kt
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
package io.github.kotlin.fibonacci

actual val firstElement: Int = 3
actual val secondElement: Int = 5
4 changes: 3 additions & 1 deletion library/src/linuxX64Test/kotlin/LinuxFibiTest.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package io.github.kotlin.fibonacci

import kotlin.test.Test
import kotlin.test.assertEquals

class LinuxFibiTest {

@Test
fun `test 3rd element`() {
assertEquals(8, fibi.take(3).last())
assertEquals(8, generateFibi().take(3).last())
}
}
1 change: 0 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
pluginManagement {
includeBuild("convention-plugins")
repositories {
google()
mavenCentral()
Expand Down
Loading