diff --git a/HeaderTestModule/build.gradle.kts b/HeaderTestModule/build.gradle.kts index 5e805ed..468b69d 100644 --- a/HeaderTestModule/build.gradle.kts +++ b/HeaderTestModule/build.gradle.kts @@ -5,12 +5,33 @@ plugins { id("com.android.library") id("com.chromaticnoise.multiplatform-swiftpackage") version "2.0.3" id("kotlin-android-extensions") +// id("io.gitlab.arturbosch.detekt") version "1.17.1" jacoco + } version = "0.0.1" group = "com.unidays.headertestmodule" +//detekt { +// buildUponDefaultConfig = true // preconfigure defaults +// allRules = false // activate all available (even unstable) rules. +// input = files("src/commonMain/kotlin") +// autoCorrect = false +// +// reports { +// html.enabled = true +// xml.enabled = true +// txt.enabled = true +// sarif.enabled = true +// } +//} +// +//tasks.withType().configureEach { +// // Target version of the generated JVM bytecode. It is used for type resolution. +// jvmTarget = "1.8" +//} + jacoco { toolVersion = "0.8.6" } diff --git a/HeaderTestModule/src/commonMain/kotlin/com/unidays/headertestmodule/HeaderBuilder.kt b/HeaderTestModule/src/commonMain/kotlin/com/unidays/headertestmodule/HeaderBuilder.kt index 1a325c6..4792239 100644 --- a/HeaderTestModule/src/commonMain/kotlin/com/unidays/headertestmodule/HeaderBuilder.kt +++ b/HeaderTestModule/src/commonMain/kotlin/com/unidays/headertestmodule/HeaderBuilder.kt @@ -12,4 +12,4 @@ class HeaderBuilder { const val TEST_HEADER_ID = 1 const val SOME_OTHER_HEADER = "Some other shit" } -} \ No newline at end of file +} diff --git a/KMPExampleModule/build.gradle.kts b/KMPExampleModule/build.gradle.kts index 8c6c945..68f0798 100644 --- a/KMPExampleModule/build.gradle.kts +++ b/KMPExampleModule/build.gradle.kts @@ -5,12 +5,31 @@ plugins { id("com.android.library") id("com.chromaticnoise.multiplatform-swiftpackage") version "2.0.3" id("kotlin-android-extensions") + id("io.gitlab.arturbosch.detekt") version "1.15.0" jacoco } version = "0.0.1" group = "com.example.kmpexamplemodule" +detekt { + buildUponDefaultConfig = true // preconfigure defaults + input = files("src/commonMain/kotlin") + autoCorrect = false + + reports { + html.enabled = true + xml.enabled = true + txt.enabled = true + sarif.enabled = true + } +} + +tasks.withType().configureEach { + // Target version of the generated JVM bytecode. It is used for type resolution. + jvmTarget = "1.8" +} + jacoco { toolVersion = "0.8.6" } diff --git a/KMPExampleModule/src/androidMain/kotlin/com/example/kmpexamplemodule/Platform.kt b/KMPExampleModule/src/androidMain/kotlin/com/example/kmpexamplemodule/Platform.kt index 3874751..ef53809 100644 --- a/KMPExampleModule/src/androidMain/kotlin/com/example/kmpexamplemodule/Platform.kt +++ b/KMPExampleModule/src/androidMain/kotlin/com/example/kmpexamplemodule/Platform.kt @@ -1,5 +1,5 @@ package com.example.kmpexamplemodule actual class Platform actual constructor() { - actual val platform: String = "Android ${android.os.Build.VERSION.SDK_INT}" + actual val name: String = "Android ${android.os.Build.VERSION.SDK_INT}" } \ No newline at end of file diff --git a/KMPExampleModule/src/androidTest/kotlin/com/example/kmpexamplemodule/androidTest.kt b/KMPExampleModule/src/androidTest/kotlin/com/example/kmpexamplemodule/androidTest.kt index cc39b00..8862c4b 100644 --- a/KMPExampleModule/src/androidTest/kotlin/com/example/kmpexamplemodule/androidTest.kt +++ b/KMPExampleModule/src/androidTest/kotlin/com/example/kmpexamplemodule/androidTest.kt @@ -7,6 +7,6 @@ class AndroidGreetingTest { @Test fun testExample() { - assertTrue("Check Android is mentioned", Greeting().greeting().contains("Android")) + assertTrue("Check Android is mentioned", Greeting().build().contains("Android")) } } \ No newline at end of file diff --git a/KMPExampleModule/src/commonMain/kotlin/com/example/kmpexamplemodule/Greeting.kt b/KMPExampleModule/src/commonMain/kotlin/com/example/kmpexamplemodule/Greeting.kt index e472e44..bbcc792 100644 --- a/KMPExampleModule/src/commonMain/kotlin/com/example/kmpexamplemodule/Greeting.kt +++ b/KMPExampleModule/src/commonMain/kotlin/com/example/kmpexamplemodule/Greeting.kt @@ -1,7 +1,7 @@ package com.example.kmpexamplemodule class Greeting { - fun greeting(): String { - return "Hello, ${Platform().platform}!" + fun build(): String { + return "Hello, ${Platform().name}!" } -} \ No newline at end of file +} diff --git a/KMPExampleModule/src/commonMain/kotlin/com/example/kmpexamplemodule/Platform.kt b/KMPExampleModule/src/commonMain/kotlin/com/example/kmpexamplemodule/Platform.kt index 0fb51f5..d537694 100644 --- a/KMPExampleModule/src/commonMain/kotlin/com/example/kmpexamplemodule/Platform.kt +++ b/KMPExampleModule/src/commonMain/kotlin/com/example/kmpexamplemodule/Platform.kt @@ -1,5 +1,8 @@ package com.example.kmpexamplemodule +/* we need to suppress this as the expect / actual keywords do not work without an empty constructor. +* those key words are still in beta so this should fix itself eventually */ +@Suppress("EmptyDefaultConstructor") expect class Platform() { - val platform: String -} \ No newline at end of file + val name: String +} diff --git a/KMPExampleModule/src/commonTest/kotlin/com/example/kmpexamplemodule/commonTest.kt b/KMPExampleModule/src/commonTest/kotlin/com/example/kmpexamplemodule/commonTest.kt index 28d6d5d..e46fed0 100644 --- a/KMPExampleModule/src/commonTest/kotlin/com/example/kmpexamplemodule/commonTest.kt +++ b/KMPExampleModule/src/commonTest/kotlin/com/example/kmpexamplemodule/commonTest.kt @@ -7,6 +7,6 @@ class CommonGreetingTest { @Test fun testExample() { - assertTrue(Greeting().greeting().contains("Hello"), "Check 'Hello' is mentioned") + assertTrue(Greeting().build().contains("Hello"), "Check 'Hello' is mentioned") } } \ No newline at end of file diff --git a/KMPExampleModule/src/iosMain/kotlin/com/example/kmpexamplemodule/Platform.kt b/KMPExampleModule/src/iosMain/kotlin/com/example/kmpexamplemodule/Platform.kt index ad1a8b3..f058291 100644 --- a/KMPExampleModule/src/iosMain/kotlin/com/example/kmpexamplemodule/Platform.kt +++ b/KMPExampleModule/src/iosMain/kotlin/com/example/kmpexamplemodule/Platform.kt @@ -3,5 +3,5 @@ package com.example.kmpexamplemodule import platform.UIKit.UIDevice actual class Platform actual constructor() { - actual val platform: String = UIDevice.currentDevice.systemName() + " " + UIDevice.currentDevice.systemVersion + actual val name: String = UIDevice.currentDevice.systemName() + " " + UIDevice.currentDevice.systemVersion } \ No newline at end of file diff --git a/KMPExampleModule/src/iosTest/kotlin/com/example/kmpexamplemodule/iosTest.kt b/KMPExampleModule/src/iosTest/kotlin/com/example/kmpexamplemodule/iosTest.kt index 37b2aaf..49c86ba 100644 --- a/KMPExampleModule/src/iosTest/kotlin/com/example/kmpexamplemodule/iosTest.kt +++ b/KMPExampleModule/src/iosTest/kotlin/com/example/kmpexamplemodule/iosTest.kt @@ -7,6 +7,6 @@ class IosGreetingTest { @Test fun testExample() { - assertTrue(Greeting().greeting().contains("iOS"), "Check iOS is mentioned") + assertTrue(Greeting().build().contains("iOS"), "Check iOS is mentioned") } } \ No newline at end of file diff --git a/codemagic.yaml b/codemagic.yaml index 359a284..c4cf74f 100644 --- a/codemagic.yaml +++ b/codemagic.yaml @@ -15,6 +15,12 @@ workflows: - &install_java_15 name: Install Java 15.0.2 script: ./codeMagicScripts/installJava15.sh + - &run_static_analysis + name: Run Static Analysis + script: | + source ~/.bash_profile + export JAVA_HOME=$JAVA_LOCATION + ./gradlew -Dorg.gradle.java.home=$JAVA_LOCATION build KMPExampleModule:detekt - &run_unit_tests name: Run Unit Tests script: | @@ -57,6 +63,7 @@ workflows: source: true scripts: - *install_java_15 + - *run_static_analysis - *run_unit_tests - *verify_tests_coverage artifacts: