|
|
@ -1,5 +1,6 @@ |
|
|
|
package org.jetbrains.compose.resources |
|
|
|
package org.jetbrains.compose.resources |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.android.build.api.dsl.KotlinMultiplatformAndroidTarget |
|
|
|
import org.gradle.api.Project |
|
|
|
import org.gradle.api.Project |
|
|
|
import org.gradle.api.provider.Provider |
|
|
|
import org.gradle.api.provider.Provider |
|
|
|
import org.gradle.api.tasks.SourceSet |
|
|
|
import org.gradle.api.tasks.SourceSet |
|
|
@ -13,7 +14,9 @@ import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType |
|
|
|
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet |
|
|
|
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet |
|
|
|
import org.jetbrains.kotlin.gradle.plugin.KotlinTarget |
|
|
|
import org.jetbrains.kotlin.gradle.plugin.KotlinTarget |
|
|
|
import org.jetbrains.kotlin.gradle.plugin.extraProperties |
|
|
|
import org.jetbrains.kotlin.gradle.plugin.extraProperties |
|
|
|
|
|
|
|
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinAndroidTarget |
|
|
|
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJsCompilation |
|
|
|
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJsCompilation |
|
|
|
|
|
|
|
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinMetadataTarget |
|
|
|
import org.jetbrains.kotlin.gradle.plugin.mpp.resources.KotlinTargetResourcesPublication |
|
|
|
import org.jetbrains.kotlin.gradle.plugin.mpp.resources.KotlinTargetResourcesPublication |
|
|
|
import java.io.File |
|
|
|
import java.io.File |
|
|
|
|
|
|
|
|
|
|
@ -29,13 +32,11 @@ internal fun Project.configureMultimoduleResources( |
|
|
|
|
|
|
|
|
|
|
|
val moduleIsolationDirectory = config.getModuleResourcesDir(project) |
|
|
|
val moduleIsolationDirectory = config.getModuleResourcesDir(project) |
|
|
|
|
|
|
|
|
|
|
|
val platformsForSkip = listOf( |
|
|
|
|
|
|
|
KotlinPlatformType.common, KotlinPlatformType.androidJvm |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
kotlinExtension.targets |
|
|
|
kotlinExtension.targets |
|
|
|
.matching { target -> target.platformType !in platformsForSkip } |
|
|
|
.matching { target -> !target.skipResourcesConfiguration() } |
|
|
|
.all { target -> configureTargetResources(target, moduleIsolationDirectory) } |
|
|
|
.all { target -> configureTargetResources(target, moduleIsolationDirectory) } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//configure ANDROID resources |
|
|
|
//configure ANDROID resources |
|
|
|
onAgpApplied { agpId -> |
|
|
|
onAgpApplied { agpId -> |
|
|
|
configureAndroidComposeResources(agpId, moduleIsolationDirectory) |
|
|
|
configureAndroidComposeResources(agpId, moduleIsolationDirectory) |
|
|
@ -92,6 +93,25 @@ private fun Project.configureTargetResources( |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun KotlinTarget.skipResourcesConfiguration(): Boolean = when { |
|
|
|
|
|
|
|
this is KotlinMetadataTarget -> true |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//android resources should be configured via AGP |
|
|
|
|
|
|
|
this is KotlinAndroidTarget -> true |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//new AGP library target |
|
|
|
|
|
|
|
this.isMultiplatformAndroidTarget() -> true |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
else -> false |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Suppress("UnstableApiUsage") |
|
|
|
|
|
|
|
private fun KotlinTarget.isMultiplatformAndroidTarget(): Boolean = try { |
|
|
|
|
|
|
|
this is KotlinMultiplatformAndroidTarget |
|
|
|
|
|
|
|
} catch (e: NoClassDefFoundError) { |
|
|
|
|
|
|
|
false |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private val platformsForSetupKmpResources = listOf( |
|
|
|
private val platformsForSetupKmpResources = listOf( |
|
|
|
KotlinPlatformType.native, KotlinPlatformType.js, KotlinPlatformType.wasm |
|
|
|
KotlinPlatformType.native, KotlinPlatformType.js, KotlinPlatformType.wasm |
|
|
|
) |
|
|
|
) |
|
|
|