
Library facilitates accessing `BuildConfiguration` details in shared code, supporting dependency injection. Integrates smoothly using Hilt, enhancing multiplatform project manageability.
A Kotlin Multiplatform library for utilizing BuildConfiguration details from common code.
// 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"
}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 |
// 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
}
}
}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.gitIf you've already cloned the repository, run:
$ git checkout master
$ git pull
$ git submodule update --initIn order to keep submodules updated when pulling the latest code, run:
$ git pull --recurse-submodulesA Kotlin Multiplatform library for utilizing BuildConfiguration details from common code.
// 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"
}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 |
// 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
}
}
}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.gitIf you've already cloned the repository, run:
$ git checkout master
$ git pull
$ git submodule update --initIn order to keep submodules updated when pulling the latest code, run:
$ git pull --recurse-submodules