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

Overview

component-build-configuration

A small library supporting Kotlin Multiplatform for utilizing BuildConfiguration details from common code and across modules.

A full list of other kotlin-components projects and their supported Kotlin Multiplatform frameworks can be found HERE

Get Started

// build.gradle.kts

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

dependencies {
    implementation "io.matthewnelson.kotlin-components:build-configuration:1"
}

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,
            platform = BuildConfiguration.Platform.Android(),
            variant = BuildConfig.BUILD_TYPE // overloaded to be either "debug" or "release" depending on `isDebug`
        )
    
    @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
        }
    }
    
    fun doSomethingBasedOnPlatform(string: String) {
        when (config.platform) {
            is Platform.Android -> { /* do something */ }
            is Platform.Jvm -> { /* do something */ }
            is Platform.Js -> { /* do something */ }
            is Platform.Darwin -> { /* do something */ }
            is Platform.Linux -> { /* do something */ }
            is Platform.Mingw -> { /* do something */ }
        }
    }
}

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-request.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
You might also like...
Design patterns are typical solutions to common problems in software design

Design patterns are typical solutions to common problems in software design. Each pattern is like a blueprint that you can customize to solve a particular design problem in your code.

Advent of Code 2021 in Kotlin Multiplatform!

Advent of Code 2021 in Kotlin Multiplatform Structure Each day comes with two parts for you to solve. You'll find a ready-to go and test templates to

Samples demonstrating the features and use of Koala Plot, a Compose Multiplatform based charting and plotting library written in Kotlin.

Koala Plot Samples This repository houses samples demonstrating the use and features of Koala Plot libraries. How to run Build koalaplot-core with the

A collection of custom Android/Kotlin lint checks we use in our Android and Kotlin code bases at Slack.

slack-lints This repository contains a collection of custom Android/Kotlin lint checks we use in our Android and Kotlin code bases at Slack. This repo

Ein LabyMod-Module für SimpleCloud

LabyMod Module Ein LabyMod-Module für SimpleCloud Download · Report Bug · SimpleCloud · LabyMod Docs Was kann dieses Module? Das ist ein CloudModule f

Repository for the Android app core module.

EU Digital COVID Certificate App Core - Android About • Development • Documentation • Support • Contribute • Contributors • Licensing About This repos

A minimalistic Face Recognition module which can be easily incorporated in any Android project.
A minimalistic Face Recognition module which can be easily incorporated in any Android project.

Real Time Face Recognition with TfLite A minimalistic Face Recognition module which can be easily incorporated in any Android project. Key Features Fa

SIMNumberSetter - A small Xposed module to set the SIM card's phone subscriber number
SIMNumberSetter - A small Xposed module to set the SIM card's phone subscriber number

SIM Number Setter SIM Number Setter is a small Xposed module that invokes normal

Comments
  • Update Kotlin-Components

    Update Kotlin-Components

    Updates Kotlin-Components, which:

    • Refactors KmpTargets
    • Refactors source set names
    • Adds support for remaining platforms
    • Removes gradle property kotlin.mpp.enableCompatibilityMetadataVariant=true in favor of Kotlin 1.6.21's hierarchical support
    opened by 05nelsonm 0
  • Add kotlin std lib matrix to readme

    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 |

    documentation 
    opened by 05nelsonm 0
  • Prettify `toString()` output

    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
    ]
    
    enhancement 
    opened by 05nelsonm 0
Releases(3.0.3)
SimpleCloud-haste-module - SimpleCloud module for uploading the logs of your services to hastebin

SimpleCloud Haste Module A SimpleCloud Module for uploading the current logs of

NeverStopGaming.net 5 Mar 6, 2022
Movo (Movie Information) is an android application to find out all the Movie Information and Details.

Movo About The Project Screen.Recording.2022-08-12.at.08.53.46_1.mp4 Movo (Movie Information) is an android application to find out all the Movie Info

Reihan Fatilla 4 Sep 28, 2022
An android app built using Kotlin following Multi-Module Clean Architecture MVVM

Notflix ??️ Work In Progress ?? An android app built using Kotlin that consumes TMDB API to display current trending, upcoming and popular movies ?? a

Victor Kabata 290 Dec 30, 2022
This project shows trending github repositories using MVI (Model View Intent) using kotlin flows and multi module clean architecture

GithubTrendingMVIFlow Build Architecture: This project shows trending github repositories using MVI (Model View Intent) using kotlin flows and multi m

Zulqurnain Haider 0 Jun 2, 2022
Easy Note: Building a Notes app using MVVM, JetPack Compose with a clean multi-module architecture approach.

Easy Note Easy Note: Notes app using JetPack Compose and MVVM with a clean architecture approach. This app shows the usage of the new Navigation Archi

Akhilesh Patil 10 Dec 17, 2022
A simple xposed module that helps you use your AdGuard subscription in multiple devices

DualGuard A simple xposed module that helps you use your AdGuard subscription in multiple (>3) devices. Monstor ahead! / 警告 This is NOT a module that

null 7 Oct 2, 2022
Android common lib demo, include ImageCache, HttpCache, DropDownListView, DownloadManager, install apk silent and so on, you can find description

android-demo 关于我,欢迎关注 微博:Trinea 主页:trinea.cn 邮箱:trinea.cn#gmail.com 微信:codek2 依赖:trinea-android-common android-auto-scroll-view-pager viewpager-indica

Trinea 1.1k Dec 30, 2022
Proguard configurations for common Android libraries

android-proguard-snippets Example Proguard configurations for common Android libraries. This project assumes that your ProGuard configuration is based

Kevin Schultz 4.6k Dec 30, 2022
Warscape core library. Includes common models for sharing between platforms.

warscope-core This repository uses for sharing common models between backend and frontend sides. Implementation $version available at top of README.md

Warscape 5 Oct 8, 2021
AndroidEssentials is an android library that creates helper functions for performing common tasks in Android

AndroidEssentials is an android library that creates helper functions for performing common tasks in Android such as managing preferences, managing files, showing alerts, showing toasts, checking user country & checking network connection of users. All the methods of the class are static and should be accessed directly from the AndroidEssentials class.

Isaac Sichangi 3 Jul 7, 2022