Skip to content

Latest commit

 

History

History
154 lines (125 loc) · 4.84 KB

README.md

File metadata and controls

154 lines (125 loc) · 4.84 KB

component-build-configuration

badge-license badge-latest-release

badge-kotlin

badge-platform-android badge-platform-jvm badge-platform-js badge-platform-js-node badge-platform-linux badge-platform-macos badge-platform-ios badge-platform-tvos badge-platform-watchos badge-platform-wasm badge-platform-windows badge-support-android-native badge-support-apple-silicon badge-support-js-ir badge-support-linux-arm badge-support-linux-mips

A Kotlin Multiplatform library for utilizing BuildConfiguration details from common code.

Get Started

// build.gradle.kts
dependencies {
    implementation("io.matthewnelson.kotlin-components:build-configuration:3.0.5")
}
// build.gradle
dependencies {
    implementation "io.matthewnelson.kotlin-components:build-configuration:3.0.5"
}

Kotlin Version Compatibility

Note: as of 2.0.0, the experimental memory model for KotlinNative is enabled.

build-configuration kotlin
3.0.5 1.8.0
3.0.4 1.7.20
3.0.3 1.6.21
3.0.2 1.6.21
3.0.1 1.6.21
3.0.0 1.6.10
2.0.0 1.6.10
1 1.5.31

Usage (Android example using Hilt dependency injection)

// module :app

import io.matthewnelson.component.build.configuration.BuildConfiguration

@Module
@InstallIn(SingletonComponent::class)
object AppModule {
    
    @Provides
    @Singleton
    fun provideBuildConfig(): BuildConfiguration =
        BuildConfiguration(
            applicationId = BuildConfig.APPLICATION_ID,
            versionName = BuildConfig.VERSION_NAME,
            versionCode = BuildConfig.VERSION_CODE,
            isDebug = BuildConfig.DEBUG,
            variant = BuildConfig.BUILD_TYPE,
            flavor = BuildConfig.FLAVOR,
        )
    
    @Provides
    fun provideMyMultiPlatformClass(
        buildConfiguration: BuildConfiguration
    ): MyMultiPlatformClass =
        MyMultiPlatformClass(buildConfiguration)
}

// module :core (kotlin multiplatform project where class is in commonMain)
class MyMultiPlatformClass(private val config: BuildConfiguration) {
    
    fun doSomethingWithString(string: String): String {
        if (config.isDebug) {
            // do this
        } else {
            // do that
        }
    }
}

Git

This project utilizes git submodules. You will need to initialize them when cloning the repository via:

$ git clone --recursive https://github.com/05nelsonm/component-build-configuration.git

If you've already cloned the repository, run:

$ git checkout master
$ git pull
$ git submodule update --init

In order to keep submodules updated when pulling the latest code, run:

$ git pull --recurse-submodules