Skip to content

Commit

Permalink
Merge pull request #9 from UbiqueInnovation/feature/no-extension-import
Browse files Browse the repository at this point in the history
avoids the need to import extension properties
  • Loading branch information
fbzli authored Oct 7, 2024
2 parents 4900396 + e6b994d commit f6d352c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
package ch.ubique.gradle.alpaka

import ch.ubique.gradle.alpaka.config.AlpakaPluginConfig
import ch.ubique.gradle.alpaka.extensions.applicationvariant.launcherIconLabel
import ch.ubique.gradle.alpaka.extensions.capitalize
import ch.ubique.gradle.alpaka.extensions.getMergedManifestFile
import ch.ubique.gradle.alpaka.extensions.listFilesOrEmpty
Expand All @@ -23,6 +22,7 @@ import org.gradle.api.file.Directory
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.plugins.ExtensionAware
import org.gradle.api.provider.Provider
import org.gradle.kotlin.dsl.launcherIconLabel
import org.jetbrains.kotlin.gradle.plugin.extraProperties
import java.io.File
import ch.ubique.gradle.alpaka.extensions.productflavor.launcherIconLabel as flavorLauncherIconLabel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,13 @@ import com.android.build.api.dsl.ApplicationVariantDimension
import org.gradle.api.plugins.ExtensionAware
import org.jetbrains.kotlin.gradle.plugin.extraProperties

private fun <T> ApplicationVariantDimension.setProperty(key: String, value: T) {
internal fun <T> ApplicationVariantDimension.setProperty(key: String, value: T) {
val extensionAware = this as ExtensionAware
extensionAware.extraProperties[key] = value
}

private fun <T> ApplicationVariantDimension.getProperty(key: String): T {
@Suppress("UNCHECKED_CAST")
internal fun <T> ApplicationVariantDimension.getProperty(key: String): T {
val extensionAware = this as ExtensionAware
return extensionAware.extraProperties[key] as T
}

var ApplicationVariantDimension.launcherIconLabel: String?
get() = getProperty("launcherIconLabel")
set(value) = setProperty("launcherIconLabel", value)

var ApplicationVariantDimension.alpakaUploadKey: String?
get() = getProperty("alpakaUploadKey")
set(value) = setProperty("alpakaUploadKey", value)
13 changes: 13 additions & 0 deletions alpaka/plugin/src/main/java/org/gradle/kotlin/dsl/AlpakaDsl.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.gradle.kotlin.dsl

import ch.ubique.gradle.alpaka.extensions.applicationvariant.getProperty
import ch.ubique.gradle.alpaka.extensions.applicationvariant.setProperty
import com.android.build.api.dsl.ApplicationVariantDimension

var ApplicationVariantDimension.launcherIconLabel: String?
get() = getProperty("launcherIconLabel")
set(value) = setProperty("launcherIconLabel", value)

var ApplicationVariantDimension.alpakaUploadKey: String?
get() = getProperty("alpakaUploadKey")
set(value) = setProperty("alpakaUploadKey", value)
3 changes: 0 additions & 3 deletions examplekts/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import ch.ubique.gradle.alpaka.extensions.applicationvariant.alpakaUploadKey
import ch.ubique.gradle.alpaka.extensions.applicationvariant.launcherIconLabel

plugins {
alias(libs.plugins.androidApplication)
alias(libs.plugins.kotlinAndroid)
Expand Down

0 comments on commit f6d352c

Please sign in to comment.