[Gradle] Implement initial ExternalAndroidTargetIT
Using AGP version 8.2.0-alpha09: Covering the external Android target maintained and developed by Google. The initial tests are intended to give basic coverage of basic functionality (such as build and running tests), as well as checking compatibility between AGP and KGP ^KT-59578 Verification Pending
This commit is contained in:
committed by
Space Team
parent
39e9996940
commit
3366366361
+91
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.gradle.android
|
||||
|
||||
import org.gradle.util.GradleVersion
|
||||
import org.jetbrains.kotlin.gradle.idea.tcs.IdeaKotlinSourceDependency.Type.Regular
|
||||
import org.jetbrains.kotlin.gradle.idea.testFixtures.tcs.*
|
||||
import org.jetbrains.kotlin.gradle.testbase.*
|
||||
import org.jetbrains.kotlin.gradle.util.jetbrainsAnnotationDependencies
|
||||
import org.jetbrains.kotlin.gradle.util.kotlinStdlibDependencies
|
||||
import org.jetbrains.kotlin.gradle.util.resolveIdeDependencies
|
||||
|
||||
@GradleTestVersions(minVersion = TestVersions.Gradle.G_8_1)
|
||||
@AndroidTestVersions(minVersion = TestVersions.AGP.AGP_82)
|
||||
@AndroidGradlePluginTests
|
||||
class ExternalAndroidTargetIT : KGPBaseTest() {
|
||||
|
||||
@GradleAndroidTest
|
||||
fun `test - simple project - build`(
|
||||
gradleVersion: GradleVersion, androidVersion: String, jdkVersion: JdkVersions.ProvidedJdk,
|
||||
) {
|
||||
project(
|
||||
"externalAndroidTarget-simple",
|
||||
gradleVersion,
|
||||
buildOptions = defaultBuildOptions.copy(androidVersion = androidVersion),
|
||||
buildJdk = jdkVersion.location
|
||||
) {
|
||||
build("assemble") {
|
||||
assertTasksExecuted(":bundleAndroidMainAar")
|
||||
assertFileInProjectExists("build/outputs/aar/externalAndroidTarget-simple.aar")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@GradleAndroidTest
|
||||
fun `test - simple project - testOnJvm`(
|
||||
gradleVersion: GradleVersion, androidVersion: String, jdkVersion: JdkVersions.ProvidedJdk,
|
||||
) {
|
||||
project(
|
||||
"externalAndroidTarget-simple",
|
||||
gradleVersion,
|
||||
buildOptions = defaultBuildOptions.copy(androidVersion = androidVersion),
|
||||
buildJdk = jdkVersion.location
|
||||
) {
|
||||
build("testAndroidTestOnJvm") {
|
||||
assertOutputContains("AndroidTestOnJvm")
|
||||
assertOutputContains("useCommonMain: CommonMain")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@GradleAndroidTest
|
||||
fun `test - simple project - ide dependency resolution`(
|
||||
gradleVersion: GradleVersion, androidVersion: String, jdkVersion: JdkVersions.ProvidedJdk,
|
||||
) {
|
||||
project(
|
||||
"externalAndroidTarget-simple",
|
||||
gradleVersion,
|
||||
buildOptions = defaultBuildOptions.copy(androidVersion = androidVersion),
|
||||
buildJdk = jdkVersion.location
|
||||
) {
|
||||
resolveIdeDependencies { dependencies ->
|
||||
dependencies["androidMain"].assertMatches(
|
||||
kotlinStdlibDependencies,
|
||||
jetbrainsAnnotationDependencies,
|
||||
dependsOnDependency(":/commonMain")
|
||||
)
|
||||
|
||||
dependencies["androidTestOnJvm"].assertMatches(
|
||||
kotlinStdlibDependencies,
|
||||
jetbrainsAnnotationDependencies,
|
||||
dependsOnDependency(":/commonTest"),
|
||||
binaryCoordinates("junit:junit:4.13.2"),
|
||||
binaryCoordinates("org.hamcrest:hamcrest-core:1.3"),
|
||||
|
||||
/*
|
||||
Actually the idiomatic expectation would be two friendSourceDependencies being sent instead of the
|
||||
projectArtifactDependency below.
|
||||
|
||||
friendSourceDependency(":/commonMain"),
|
||||
friendSourceDependency(":/androidMain"),
|
||||
*/
|
||||
projectArtifactDependency(Regular, ":", FilePathRegex(".*/androidMain/full.jar"))
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
@@ -48,6 +48,7 @@ interface TestVersions {
|
||||
const val AGP_74 = "7.4.0"
|
||||
const val AGP_80 = "8.0.0-beta05"
|
||||
const val AGP_81 = "8.1.0-alpha08"
|
||||
const val AGP_82 = "8.2.0-alpha09"
|
||||
|
||||
const val MIN_SUPPORTED = AGP_42 // KotlinAndroidPlugin.minimalSupportedAgpVersion
|
||||
const val MAX_SUPPORTED = AGP_74 // Update once Gradle MAX_SUPPORTED version will be bumped
|
||||
@@ -67,6 +68,7 @@ interface TestVersions {
|
||||
AGP_74(AGP.AGP_74, GradleVersion.version(Gradle.G_7_5), GradleVersion.version(Gradle.G_7_6), JavaVersion.VERSION_11),
|
||||
AGP_80(AGP.AGP_80, GradleVersion.version(Gradle.G_8_0), GradleVersion.version(Gradle.G_8_0), JavaVersion.VERSION_17),
|
||||
AGP_81(AGP.AGP_81, GradleVersion.version(Gradle.G_8_1), GradleVersion.version(Gradle.G_8_1), JavaVersion.VERSION_17),
|
||||
AGP_82(AGP.AGP_82, GradleVersion.version(Gradle.G_8_1), GradleVersion.version(Gradle.G_8_1), JavaVersion.VERSION_17),
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -113,7 +113,9 @@ internal val DEFAULT_KOTLIN_SETTINGS_FILE =
|
||||
"com.android.asset-pack-bundle",
|
||||
"com.android.lint",
|
||||
"com.android.instantapp",
|
||||
"com.android.feature" -> useModule("com.android.tools.build:gradle:${'$'}android_tools_version")
|
||||
"com.android.feature",
|
||||
"com.android.kotlin.multiplatform.library"
|
||||
-> useModule("com.android.tools.build:gradle:${'$'}android_tools_version")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
plugins {
|
||||
kotlin("multiplatform")
|
||||
id("com.android.kotlin.multiplatform.library")
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
google()
|
||||
}
|
||||
|
||||
kotlin {
|
||||
linuxX64()
|
||||
linuxArm64()
|
||||
|
||||
androidExperimental {
|
||||
compileSdk = 33
|
||||
namespace = "org.jetbrains.sample"
|
||||
|
||||
withAndroidTestOnJvm()
|
||||
sourceSets.getByName("androidTestOnJvm").dependencies {
|
||||
implementation("junit:junit:4.13.2")
|
||||
}
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
|
||||
class AndroidMain(val context: Context) {
|
||||
fun useContext() {
|
||||
context.getSystemService(Context.LOCATION_SERVICE)
|
||||
}
|
||||
|
||||
fun useLog() {
|
||||
Log.d("test", CommonMain.toString())
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun useCommonMain() {
|
||||
println("useCommonMain: ${CommonMain}")
|
||||
}
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
import org.junit.Test
|
||||
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
class AndroidTestOnJvm {
|
||||
@Test
|
||||
fun run() {
|
||||
AndroidMain.useCommonMain()
|
||||
org.junit.Assert.assertEquals("CommonMain", CommonMain.toString())
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
object CommonMain {
|
||||
override fun toString(): String {
|
||||
return "CommonMain"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user