diff --git a/platforms/gradle/better-gradle-properties/api/better-gradle-properties.api b/platforms/gradle/better-gradle-properties/api/better-gradle-properties.api index 3a61de4ea..17d0b889a 100644 --- a/platforms/gradle/better-gradle-properties/api/better-gradle-properties.api +++ b/platforms/gradle/better-gradle-properties/api/better-gradle-properties.api @@ -48,6 +48,7 @@ public final class foundry/gradle/properties/PropertyResolver { public final fun optionalStringValue (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String; public static synthetic fun optionalStringValue$default (Lfoundry/gradle/properties/PropertyResolver;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String; public final fun providerFor (Ljava/lang/String;)Lorg/gradle/api/provider/Provider; + public final fun requiredStringProvider (Ljava/lang/String;)Lorg/gradle/api/provider/Provider; public final fun stringValue (Ljava/lang/String;)Ljava/lang/String; public final fun stringValue (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String; } diff --git a/platforms/gradle/better-gradle-properties/src/main/kotlin/foundry/gradle/properties/PropertyResolver.kt b/platforms/gradle/better-gradle-properties/src/main/kotlin/foundry/gradle/properties/PropertyResolver.kt index 0740b86c2..73e428927 100644 --- a/platforms/gradle/better-gradle-properties/src/main/kotlin/foundry/gradle/properties/PropertyResolver.kt +++ b/platforms/gradle/better-gradle-properties/src/main/kotlin/foundry/gradle/properties/PropertyResolver.kt @@ -111,6 +111,15 @@ public class PropertyResolver( ?: error("No property for '$key' found and no default value was provided.") } + public fun requiredStringProvider(key: String): Provider { + return optionalStringProvider(key) + .orElse( + providers.provider { + error("No property for '$key' found and no default value was provided.") + } + ) + } + public fun optionalStringValue(key: String, defaultValue: String? = null): String? { return providerFor(key).orNull ?: defaultValue } diff --git a/platforms/gradle/foundry-gradle-plugin/src/main/kotlin/foundry/gradle/FoundryGradleUtil.kt b/platforms/gradle/foundry-gradle-plugin/src/main/kotlin/foundry/gradle/FoundryGradleUtil.kt index bf0fa29e1..f71d3b88d 100644 --- a/platforms/gradle/foundry-gradle-plugin/src/main/kotlin/foundry/gradle/FoundryGradleUtil.kt +++ b/platforms/gradle/foundry-gradle-plugin/src/main/kotlin/foundry/gradle/FoundryGradleUtil.kt @@ -91,21 +91,21 @@ internal fun robolectricJars(gradleUserHomeDir: File, createDirsIfMissing: Boole } } -public fun Project.supportedLanguages(supportedLanguages: SupportedLanguagesEnum): List { +public fun Project.supportedLanguages( + supportedLanguages: SupportedLanguagesEnum +): Provider> { val foundryProperties = project.foundryProperties - val gaLanguages = foundryProperties.supportedLanguages.split(",") + val gaLanguages = foundryProperties.supportedLanguages.map { it.split(",") } - val internalLanguages = foundryProperties.supportedLanguagesInternal.split(",") + val internalLanguages = foundryProperties.supportedLanguagesInternal.map { it.split(",") } - val betaLanguages = foundryProperties.supportedLanguagesBeta.split(",") + val betaLanguages = foundryProperties.supportedLanguagesBeta.map { it.split(",") } return when (supportedLanguages) { - SupportedLanguagesEnum.GA -> gaLanguages.toList().filter { it.isNotBlank() } - SupportedLanguagesEnum.INTERNAL -> - internalLanguages.union(gaLanguages).toList().filter { it.isNotBlank() } - SupportedLanguagesEnum.BETA -> - betaLanguages.union(gaLanguages).toList().filter { it.isNotBlank() } - } + SupportedLanguagesEnum.GA -> gaLanguages + SupportedLanguagesEnum.INTERNAL -> internalLanguages.zip(gaLanguages, List::union) + SupportedLanguagesEnum.BETA -> betaLanguages.zip(gaLanguages, List::union) + }.map { it.filter { it.isNotBlank() } } } public enum class SupportedLanguagesEnum { diff --git a/platforms/gradle/foundry-gradle-plugin/src/main/kotlin/foundry/gradle/FoundryProperties.kt b/platforms/gradle/foundry-gradle-plugin/src/main/kotlin/foundry/gradle/FoundryProperties.kt index 34ae584d5..f6d17f814 100644 --- a/platforms/gradle/foundry-gradle-plugin/src/main/kotlin/foundry/gradle/FoundryProperties.kt +++ b/platforms/gradle/foundry-gradle-plugin/src/main/kotlin/foundry/gradle/FoundryProperties.kt @@ -141,16 +141,16 @@ internal constructor( get() = booleanProperty("foundry.config.noPlatform") /** Property corresponding to the supported languages in GA builds */ - public val supportedLanguages: String - get() = stringProperty("foundry.android.supportedLanguages") + public val supportedLanguages: Provider + get() = resolver.requiredStringProvider("foundry.android.supportedLanguages") /** Property corresponding to the supported languages in Internal builds */ - public val supportedLanguagesInternal: String - get() = stringProperty("foundry.android.supportedLanguagesInternal") + public val supportedLanguagesInternal: Provider + get() = resolver.requiredStringProvider("foundry.android.supportedLanguagesInternal") /** Property corresponding to the supported languages in Beta builds */ - public val supportedLanguagesBeta: String - get() = stringProperty("foundry.android.supportedLanguagesBeta") + public val supportedLanguagesBeta: Provider + get() = resolver.requiredStringProvider("foundry.android.supportedLanguagesBeta") /** * Property corresponding to the file path of a custom versions.json file for use with