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

refactor #17

Merged
merged 2 commits into from
Jul 31, 2023
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ It has only one function: generate the [Fibonacci sequence](https://en.wikipedia
## How do I build it?

1. - [x] Clone this repository ot just [use it as template](https://github.com/asm0dey/dummylib-multiplatform/generate)
1. - [ ] Edit project name in [`settings.gradle.kts`](settings.gradle.kts#L17)
1. - [ ] Edit library module name and include it in [`settings.gradle.kts`](settings.gradle.kts#L18)
1. - [ ] Edit [`groupId` and `version`](convention-plugins/src/main/kotlin/module.publication.gradle.kts#L10-L11)
1. If you need the Android support update namespace [there](library/build.gradle.kts#L38) too
1. If you don't need an Android support delete the [`android` section](library/build.gradle.kts#L37-L43)
Expand Down
1 change: 0 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
plugins {
id("root.publication")
id("module.publication")
//trick: for the same plugin versions in all sub-modules
alias(libs.plugins.androidLibrary).apply(false)
alias(libs.plugins.kotlinMultiplatform).apply(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ plugins {
signing
}

group = "com.github.asm0dey.dummylib"
version = "0.0.1"

publishing {
// Configure all publications
publications.withType<MavenPublication> {
Expand All @@ -19,7 +16,7 @@ publishing {
archiveAppendix.set([email protected])
})

// Provide artifacts information requited by Maven Central
// Provide artifacts information required by Maven Central
pom {
name.set("Dummy Kotlin Multiplatform library")
description.set("Dummy library to test deployment to Maven Central")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ plugins {
id("io.github.gradle-nexus.publish-plugin")
}

allprojects {
group = "com.github.asm0dey.dummylib"
version = "0.0.1"
}

nexusPublishing {
// Configure maven central repository
// https://github.com/gradle-nexus/publish-plugin#publishing-to-maven-central-via-sonatype-ossrh
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#Gradle
org.gradle.jvmargs=-Xmx2048M -Dfile.encoding=UTF-8 -Dkotlin.daemon.jvm.options\="-Xmx2048M"
org.gradle.caching=true
org.gradle.configuration-cache=true

#Kotlin
kotlin.code.style=official
Expand Down
16 changes: 11 additions & 5 deletions library/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,17 @@ kotlin {
iosSimulatorArm64()
linuxX64()

sourceSets.commonMain.get().dependencies {
//put your multiplatform dependencies here
}
sourceSets.commonTest.get().dependencies {
implementation(libs.kotlin.test)
sourceSets {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you changed the way which Sebastian recommended

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is not good idea because it works only for common source sets. for any other user will have to use "by getting" syntax

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another point is I'd prefer to have a common approach in our templates.
we don't use sourceSets. for each source set

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With 1.9.20 there will be static accessors not just for commonMain but other default source sets (including nativeMain, iosMain and etc)

val commonMain by getting {
dependencies {
//put your multiplatform dependencies here
}
}
val commonTest by getting {
dependencies {
implementation(libs.kotlin.test)
}
}
}
}

Expand Down
10 changes: 10 additions & 0 deletions library/src/androidUnitTest/kotlin/AndroidFibiTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import kotlin.test.Test
import kotlin.test.assertEquals

class AndroidFibiTest {

@Test
fun `test 3rd element`() {
assertEquals(3, fibi.take(3).last())
}
}
9 changes: 0 additions & 9 deletions library/src/androidUnitTest/kotlin/FibiTest.kt

This file was deleted.

10 changes: 10 additions & 0 deletions library/src/commonTest/kotlin/FibiTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import kotlin.test.Test
import kotlin.test.assertEquals

class FibiTest {

@Test
fun `test 3rd element`() {
assertEquals(firstElement + secondElement, fibi.take(3).last())
}
}
9 changes: 0 additions & 9 deletions library/src/iosTest/kotlin/FibiTest.kt

This file was deleted.

10 changes: 10 additions & 0 deletions library/src/iosTest/kotlin/IosFibiTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import kotlin.test.Test
import kotlin.test.assertEquals

class IosFibiTest {

@Test
fun `test 3rd element`() {
assertEquals(7, fibi.take(3).last())
}
}
9 changes: 0 additions & 9 deletions library/src/jvmTest/kotlin/FibiTest.kt

This file was deleted.

10 changes: 10 additions & 0 deletions library/src/jvmTest/kotlin/JvmFibiTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import kotlin.test.Test
import kotlin.test.assertEquals

class JvmFibiTest {

@Test
fun `test 3rd element`() {
assertEquals(5, fibi.take(3).last())
}
}
9 changes: 0 additions & 9 deletions library/src/linuxX64Test/kotlin/FibiTest.kt

This file was deleted.

10 changes: 10 additions & 0 deletions library/src/linuxX64Test/kotlin/LinuxFibiTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import kotlin.test.Test
import kotlin.test.assertEquals

class LinuxFibiTest {

@Test
fun `test 3rd element`() {
assertEquals(8, fibi.take(3).last())
}
}
6 changes: 1 addition & 5 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
pluginManagement {
includeBuild("convention-plugins")
repositories {
google {
mavenContent {
releasesOnly()
}
}
google()
mavenCentral()
gradlePluginPortal()
}
Expand Down