Giter VIP home page Giter VIP logo

05nelsonm / component-build-configuration Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 3.0 166 KB

BuildConfiguration information for use in multi-module, or Kotlin Multiplatform common code

Home Page: https://kotlin-components.matthewnelson.io

License: Apache License 2.0

Kotlin 100.00%
kotlin kotlin-multiplatform kotlin-multiplatform-library kotlin-multiplatform-mobile kotlin-android android android-library android-lib android-libraries android-libs

component-build-configuration's Introduction

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

component-build-configuration's People

Contributors

05nelsonm avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

woren asvitzer

component-build-configuration's Issues

Use `explicitApi`

Use explicitApi() for library modules

// build.gradle.kts

plugins {
    id(pluginId.kmp.configuration)
    id(pluginId.kmp.publish)
}

kmpConfiguration {
    setupMultiplatform(
        // ...
        kotlin = {
            explicitApi()
        }
    )
}

Add kotlin std lib matrix to readme

Add a matrix to the README detailing which versions of component-build-configuration are compatible with which kotlin std lib versions

ex:

build-config kotlin
1 1.5.31

Prettify `toString()` output

BuildConfiguration is currently a data class, so it comes with the standard output. This should be prettified so a clean output can be had for use in things such as filing bug reports.

Build Configuration [
    applicationId: com.example.app
    version: 1.2.0
    versionCode: 100200
    debug: true
    variant: development
    flavor: global
]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.