Validate consuming a project with multiplatform resources
^KT-65540
This commit is contained in:
committed by
Space Team
parent
0f20e39475
commit
01ff4a597a
+90
@@ -0,0 +1,90 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2024 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.mpp.resources
|
||||||
|
|
||||||
|
import org.gradle.util.GradleVersion
|
||||||
|
import org.jetbrains.kotlin.gradle.testbase.*
|
||||||
|
import org.jetbrains.kotlin.konan.target.HostManager
|
||||||
|
import org.junit.jupiter.api.DisplayName
|
||||||
|
import java.nio.file.Path
|
||||||
|
|
||||||
|
@MppGradlePluginTests
|
||||||
|
@AndroidTestVersions(minVersion = TestVersions.AGP.AGP_73)
|
||||||
|
@DisplayName("Test consumption of dependencies with multiplatform resources in a regular project")
|
||||||
|
class MultiplatformResourcesDependencyIT : KGPBaseTest() {
|
||||||
|
|
||||||
|
@DisplayName("Assembling a project with a project dependency and published dependency with multiplatform resources")
|
||||||
|
@GradleAndroidTest
|
||||||
|
fun test(
|
||||||
|
gradleVersion: GradleVersion,
|
||||||
|
androidVersion: String,
|
||||||
|
providedJdk: JdkVersions.ProvidedJdk,
|
||||||
|
) {
|
||||||
|
publishAndPrepareDependencyProjects(
|
||||||
|
gradleVersion,
|
||||||
|
providedJdk,
|
||||||
|
androidVersion,
|
||||||
|
) { localRepoDir ->
|
||||||
|
project(
|
||||||
|
"multiplatformResources/dependency",
|
||||||
|
gradleVersion,
|
||||||
|
buildJdk = providedJdk.location,
|
||||||
|
localRepoDir = localRepoDir,
|
||||||
|
) {
|
||||||
|
includeOtherProjectAsSubmodule(
|
||||||
|
"multiplatformResources/publication",
|
||||||
|
newSubmoduleName = "project",
|
||||||
|
isKts = true,
|
||||||
|
)
|
||||||
|
buildWithAGPVersion(
|
||||||
|
"assemble",
|
||||||
|
androidVersion = androidVersion,
|
||||||
|
defaultBuildOptions = defaultBuildOptions,
|
||||||
|
) {
|
||||||
|
assertTasksExecuted(
|
||||||
|
":compileKotlinJvm",
|
||||||
|
":compileKotlinLinuxX64",
|
||||||
|
":compileKotlinWasmJs",
|
||||||
|
":compileKotlinWasmWasi",
|
||||||
|
":project:compileKotlinJvm",
|
||||||
|
":project:compileKotlinLinuxX64",
|
||||||
|
":project:compileKotlinWasmJs",
|
||||||
|
":project:compileKotlinWasmWasi",
|
||||||
|
)
|
||||||
|
if (HostManager.host.family.isAppleFamily) {
|
||||||
|
assertTasksExecuted(
|
||||||
|
":compileKotlinIosArm64",
|
||||||
|
":compileKotlinIosSimulatorArm64",
|
||||||
|
":project:compileKotlinIosArm64",
|
||||||
|
":project:compileKotlinIosSimulatorArm64",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun publishAndPrepareDependencyProjects(
|
||||||
|
gradleVersion: GradleVersion,
|
||||||
|
providedJdk: JdkVersions.ProvidedJdk,
|
||||||
|
androidVersion: String,
|
||||||
|
withRepositoryRoot: (Path) -> (Unit),
|
||||||
|
) {
|
||||||
|
project(
|
||||||
|
"multiplatformResources/publication",
|
||||||
|
gradleVersion,
|
||||||
|
buildJdk = providedJdk.location,
|
||||||
|
) {
|
||||||
|
buildWithAGPVersion(
|
||||||
|
":publishAllPublicationsToMavenRepository",
|
||||||
|
androidVersion,
|
||||||
|
defaultBuildOptions,
|
||||||
|
)
|
||||||
|
withRepositoryRoot(projectPath.resolve("build/repo"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+4
-1
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.gradle.mpp.resources
|
package org.jetbrains.kotlin.gradle.mpp.resources
|
||||||
|
|
||||||
|
import org.gradle.testkit.runner.BuildResult
|
||||||
import org.jetbrains.kotlin.gradle.testbase.BuildOptions
|
import org.jetbrains.kotlin.gradle.testbase.BuildOptions
|
||||||
import org.jetbrains.kotlin.gradle.testbase.TestProject
|
import org.jetbrains.kotlin.gradle.testbase.TestProject
|
||||||
import org.jetbrains.kotlin.gradle.testbase.build
|
import org.jetbrains.kotlin.gradle.testbase.build
|
||||||
@@ -18,10 +19,12 @@ fun TestProject.buildWithAGPVersion(
|
|||||||
task: String,
|
task: String,
|
||||||
androidVersion: String,
|
androidVersion: String,
|
||||||
defaultBuildOptions: BuildOptions,
|
defaultBuildOptions: BuildOptions,
|
||||||
|
assertions: BuildResult.() -> Unit = {},
|
||||||
) {
|
) {
|
||||||
build(
|
build(
|
||||||
task,
|
task,
|
||||||
buildOptions = defaultBuildOptions.copy(androidVersion = androidVersion)
|
buildOptions = defaultBuildOptions.copy(androidVersion = androidVersion),
|
||||||
|
assertions = assertions,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+52
@@ -0,0 +1,52 @@
|
|||||||
|
@file:OptIn(ComposeKotlinGradlePluginApi::class)
|
||||||
|
|
||||||
|
import org.gradle.api.provider.Provider
|
||||||
|
import org.jetbrains.kotlin.gradle.ComposeKotlinGradlePluginApi
|
||||||
|
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
|
||||||
|
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinAndroidTarget
|
||||||
|
import org.jetbrains.kotlin.gradle.plugin.mpp.resources.KotlinTargetResourcesPublication
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
|
group = "test"
|
||||||
|
version = "1.0"
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
kotlin("multiplatform")
|
||||||
|
id("com.android.application")
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
google()
|
||||||
|
mavenCentral()
|
||||||
|
mavenLocal()
|
||||||
|
}
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
androidTarget {
|
||||||
|
publishAllLibraryVariants()
|
||||||
|
compilations.all {
|
||||||
|
kotlinOptions.jvmTarget = "1.8"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
jvm()
|
||||||
|
linuxX64()
|
||||||
|
wasmJs()
|
||||||
|
wasmWasi()
|
||||||
|
iosArm64()
|
||||||
|
iosSimulatorArm64()
|
||||||
|
|
||||||
|
sourceSets.commonMain {
|
||||||
|
dependencies {
|
||||||
|
implementation("test:publication:+")
|
||||||
|
implementation(project(":project"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
android {
|
||||||
|
namespace = "test.dependency"
|
||||||
|
compileSdk = 34
|
||||||
|
defaultConfig {
|
||||||
|
minSdk = 24
|
||||||
|
}
|
||||||
|
}
|
||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<application
|
||||||
|
android:allowBackup="false"
|
||||||
|
android:supportsRtl="true">
|
||||||
|
<activity
|
||||||
|
android:name=".MainActivity"
|
||||||
|
android:exported="true">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
</application>
|
||||||
|
</manifest>
|
||||||
Reference in New Issue
Block a user