diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 41acb22..bc58951 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -73,6 +73,11 @@ jobs: working-directory: tests-projects/tests-android-old run: ../../gradlew --stacktrace check shell: bash + - name: Check plugin with Android new layout (ubuntu) + if: matrix.os == 'ubuntu-latest' + working-directory: tests-projects/tests-android-new + run: ../../gradlew --stacktrace check + shell: bash - name: Upload (macos / windows) if: matrix.os != 'ubuntu-latest' run: ./gradlew --stacktrace hostOnlyPublish -Porg.kodein.sonatype.repositoryId=${{ needs.create-staging-repository.outputs.repository_id }} diff --git a/.github/workflows/snapshot.yml b/.github/workflows/snapshot.yml index f57d999..7357bcf 100644 --- a/.github/workflows/snapshot.yml +++ b/.github/workflows/snapshot.yml @@ -71,6 +71,11 @@ jobs: working-directory: tests-projects/tests-android-old run: ../../gradlew --stacktrace check shell: bash + - name: Check plugin with Android new layout (ubuntu) + if: matrix.os == 'ubuntu-latest' + working-directory: tests-projects/tests-android-new + run: ../../gradlew --stacktrace check + shell: bash - name: Upload (macos / windows) if: matrix.os != 'ubuntu-latest' run: ./gradlew --stacktrace hostOnlyPublish -PgitRef=${{ github.ref }} -Psnapshot=true diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d9b9a03..57aa63a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -57,3 +57,8 @@ jobs: working-directory: tests-projects/tests-android-old run: ../../gradlew --stacktrace check shell: bash + - name: Check plugin with Android new layout (ubuntu) + if: matrix.os == 'ubuntu-latest' + working-directory: tests-projects/tests-android-new + run: ../../gradlew --stacktrace check + shell: bash diff --git a/mockmp-gradle-plugin/src/main/kotlin/org/kodein/mock/gradle/MocKMPGradlePlugin.kt b/mockmp-gradle-plugin/src/main/kotlin/org/kodein/mock/gradle/MocKMPGradlePlugin.kt index 728ba79..ad1c8f3 100644 --- a/mockmp-gradle-plugin/src/main/kotlin/org/kodein/mock/gradle/MocKMPGradlePlugin.kt +++ b/mockmp-gradle-plugin/src/main/kotlin/org/kodein/mock/gradle/MocKMPGradlePlugin.kt @@ -84,7 +84,10 @@ class MocKMPGradlePlugin : Plugin { // Adding KSP JVM result to COMMON source set when (jvmTarget.preset!!.name) { "jvm" -> commonTest.kotlin.srcDir("${project.buildDir}/generated/ksp/${jvmTarget.name}/${jvmTarget.name}Test/kotlin") - "android" -> commonTest.kotlin.srcDir("${project.buildDir}/generated/ksp/${jvmTarget.name}/${jvmTarget.name}DebugUnitTest/kotlin") + "android" -> { + commonTest.kotlin.srcDir("${project.buildDir}/generated/ksp/${jvmTarget.name}/${jvmTarget.name}DebugUnitTest/kotlin") + commonTest.kotlin.srcDir("${project.buildDir}/generated/ksp/${jvmTarget.name}/${jvmTarget.name}UnitTestDebug/kotlin") + } } configureKsp(project, ext) diff --git a/tests-projects/tests-android-new/build.gradle.kts b/tests-projects/tests-android-new/build.gradle.kts new file mode 100644 index 0000000..d5237ff --- /dev/null +++ b/tests-projects/tests-android-new/build.gradle.kts @@ -0,0 +1,68 @@ +plugins { + alias(kodeinGlobals.plugins.android.library) + alias(kodeinGlobals.plugins.kotlin.multiplatform) + id("org.kodein.mock.mockmp") +} + +repositories { + mavenLocal() + google() + mavenCentral() +} + +android { + namespace = "org.kodein.mock.tests_android" + compileSdk = 32 + + defaultConfig { + minSdk = 21 + targetSdk = 32 + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + } + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } +} + +kotlin { + android() + ios() + + sourceSets { + val commonMain by getting { + kotlin.srcDir("$rootDir/../../tests/tests-junit4/src/commonMain/kotlin") + dependencies { + implementation(libs.datetime) + } + } + val commonTest by getting { + kotlin.srcDir("$rootDir/../../tests/tests-junit4/src/commonTest/kotlin") + dependencies { + implementation(libs.coroutines.test) + } + } + + val androidUnitTest by getting { + dependencies { + implementation(kodeinGlobals.kotlin.test.junit) + } + } + } +} + +mockmp { + usesHelper = true +} + +// Showing tests in Gradle command line +afterEvaluate { + tasks.withType { + testLogging { + events("passed", "skipped", "failed", "standard_out", "standard_error") + showExceptions = true + showStackTraces = true + } + } +} diff --git a/tests-projects/tests-android-new/gradle.properties b/tests-projects/tests-android-new/gradle.properties new file mode 100644 index 0000000..17ff0a9 --- /dev/null +++ b/tests-projects/tests-android-new/gradle.properties @@ -0,0 +1,5 @@ +org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 + +android.useAndroidX=true +android.nonTransitiveRClass=true +kotlin.mpp.androidSourceSetLayoutVersion=2 diff --git a/tests-projects/tests-android-new/settings.gradle.kts b/tests-projects/tests-android-new/settings.gradle.kts new file mode 100644 index 0000000..2d5c155 --- /dev/null +++ b/tests-projects/tests-android-new/settings.gradle.kts @@ -0,0 +1,44 @@ +pluginManagement { + repositories { + mavenLocal() + gradlePluginPortal() + google() + mavenCentral() + } + + resolutionStrategy.eachPlugin { + if (target.id.id == "org.kodein.mock.mockmp") { + val rx = Regex("version = \"(.+)\"") + val match = file("$rootDir/../../build.gradle.kts").useLines { lines -> + lines.mapNotNull { rx.matchEntire(it.trim()) }.firstOrNull() + } ?: error("Could not find parent project version") + val mockmpVersion = match.groupValues[1] + + useModule("org.kodein.mock:mockmp-gradle-plugin:$mockmpVersion") + } + } +} + +@Suppress("UnstableApiUsage") +dependencyResolutionManagement { + repositories { + mavenLocal() + mavenCentral() + maven(url = "https://raw.githubusercontent.com/kosi-libs/kodein-internal-gradle-plugin/mvn-repo") + } + + versionCatalogs { + create("kodeinGlobals") { + val rx = Regex("classpath\\(\"org.kodein.internal.gradle:kodein-internal-gradle-settings:(.+)\"\\)") + val match = file("$rootDir/../../settings.gradle.kts").useLines { lines -> + lines.mapNotNull { rx.matchEntire(it.trim()) }.firstOrNull() + } ?: error("Could not find parent KIGP version") + val kigpVersion = match.groupValues[1] + + from("org.kodein.internal.gradle:kodein-internal-gradle-version-catalog:$kigpVersion") + } + create("libs") { + from(files("../../gradle/libs.versions.toml")) + } + } +} diff --git a/tests-projects/tests-android-new/src/androidMain/AndroidManifest.xml b/tests-projects/tests-android-new/src/androidMain/AndroidManifest.xml new file mode 100644 index 0000000..1f323ca --- /dev/null +++ b/tests-projects/tests-android-new/src/androidMain/AndroidManifest.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/tests-projects/tests-android-new/src/androidMain/res/mipmap-xxxhdpi/ic_launcher.webp b/tests-projects/tests-android-new/src/androidMain/res/mipmap-xxxhdpi/ic_launcher.webp new file mode 100644 index 0000000..aa7d642 Binary files /dev/null and b/tests-projects/tests-android-new/src/androidMain/res/mipmap-xxxhdpi/ic_launcher.webp differ diff --git a/tests-projects/tests-android-old/build.gradle.kts b/tests-projects/tests-android-old/build.gradle.kts index 8ea7c66..2f515c0 100644 --- a/tests-projects/tests-android-old/build.gradle.kts +++ b/tests-projects/tests-android-old/build.gradle.kts @@ -22,8 +22,8 @@ android { } compileOptions { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 } } diff --git a/tests-projects/tests-android-old/gradle.properties b/tests-projects/tests-android-old/gradle.properties index ada8099..2614e75 100644 --- a/tests-projects/tests-android-old/gradle.properties +++ b/tests-projects/tests-android-old/gradle.properties @@ -2,3 +2,4 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 android.useAndroidX=true android.nonTransitiveRClass=true +kotlin.mpp.androidSourceSetLayoutVersion1.nowarn=true