### BuildKonfig Gradle Plugin Configuration (Kotlin DSL) Source: https://github.com/yshrsmz/buildkonfig/blob/master/README.md This snippet provides the equivalent setup for the BuildKonfig Gradle plugin using Kotlin DSL. It shows how to declare dependencies in the buildscript, apply plugins using the `plugins` block, and configure `packageName` and `defaultConfigs` with type-safe field definitions. This setup also generates a Kotlin object with defined build fields. ```Kotlin import com.codingfeline.buildkonfig.compiler.FieldSpec.Type.STRING buildscript { repositories { mavenCentral() } dependencies { classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.0") classpath("com.codingfeline.buildkonfig:buildkonfig-gradle-plugin:latest_version") } } plugins { kotlin("multiplatform") id("com.codingfeline.buildkonfig") } kotlin { // your target config... androidTarget() iosX64('ios') } buildkonfig { packageName = "com.example.app" // objectName = "YourAwesomeConfig" // exposeObjectWithName = "YourAwesomePublicConfig" defaultConfigs { buildConfigField(STRING, "name", "value") } } ``` -------------------------------- ### BuildKonfig Gradle Plugin Configuration (Groovy DSL) Source: https://github.com/yshrsmz/buildkonfig/blob/master/README.md This snippet demonstrates the basic setup for the BuildKonfig Gradle plugin using Groovy DSL. It includes adding the plugin to the buildscript classpath, applying the plugin, and defining `packageName` and `defaultConfigs` with a sample string field. This configuration generates a Kotlin object with specified build fields. ```Groovy buildScript { repositories { mavenCentral() } dependencies { classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.0' classpath 'com.codingfeline.buildkonfig:buildkonfig-gradle-plugin:latest_version' } } apply plugin: 'org.jetbrains.kotlin.multiplatform' apply plugin: 'com.codingfeline.buildkonfig' kotlin { // your target config... androidTarget() iosX64('ios') } buildkonfig { packageName = 'com.example.app' // objectName = 'YourAwesomeConfig' // exposeObjectWithName = 'YourAwesomePublicConfig' defaultConfigs { buildConfigField 'STRING', 'name', 'value' } } ``` -------------------------------- ### Example of Generated BuildKonfig Kotlin Object Source: https://github.com/yshrsmz/buildkonfig/blob/master/README.md This snippet illustrates the structure of the Kotlin object automatically generated by the BuildKonfig plugin based on the Gradle configuration. It shows how the `packageName` and `defaultConfigs` translate into a simple internal object with properties accessible in the commonMain source set. ```Kotlin // commonMain package com.example.app internal object BuildKonfig { val name: String = "value" } ``` -------------------------------- ### Configure BuildKonfig with Default and Target-Specific Fields Source: https://github.com/yshrsmz/buildkonfig/blob/master/README.md These examples illustrate how to configure the BuildKonfig plugin using both Groovy and Kotlin DSLs. They cover setting a package name, defining default build configuration fields, and specifying target-specific fields for platforms like Android and iOS, including support for build flavors. ```Groovy // ./mpp_project/build.gradle buildkonfig { packageName = 'com.example.app' // default config is required defaultConfigs { buildConfigField 'STRING', 'name', 'value' } // flavor is passed as a first argument of defaultConfigs defaultConfigs("dev") { buildConfigField 'STRING', 'name', 'devValue' } targetConfigs { android { buildConfigField 'STRING', 'name2', 'value2' } ios { buildConfigField 'STRING', 'name', 'valueIos' } } // flavor is passed as a first argument of targetConfigs targetConfigs("dev") { ios { buildConfigField 'STRING', 'name', 'devValueIos' } } } ``` ```Kotlin import com.codingfeline.buildkonfig.compiler.FieldSpec.Type.STRING import com.codingfeline.buildkonfig.gradle.TargetConfigDsl buildkonfig { packageName = "com.example.app" // default config is required defaultConfigs { buildConfigField(STRING, "name", "value") } // flavor is passed as a first argument of defaultConfigs defaultConfigs("dev") { buildConfigField(STRING, "name", "devValue") } targetConfigs { create("android") { buildConfigField(STRING, "name2", "value2") } create("ios") { buildConfigField(STRING, "name", "valueIos") } } // flavor is passed as a first argument of targetConfigs targetConfigs("dev") { create("ios") { buildConfigField(STRING, "name", "devValueIos") } } } ``` -------------------------------- ### Run BuildKonfig Sample Projects Source: https://github.com/yshrsmz/buildkonfig/blob/master/README.md These shell commands demonstrate how to publish the BuildKonfig plugin to a local Maven repository and then run the sample projects. The `generateBuildKonfig` task will create the build configuration files in the specified sample directory, allowing users to test the plugin's functionality. ```Shell # Publish the latest version of the plugin to test maven repository(./build/localMaven) $ ./gradlew publishAllPublicationsToTestMavenRepository -PRELEASE_SIGNING_ENABLED=false # Try out the samples. # BuildKonfig will be generated in ./sample/build/buildkonfig $ ./gradlew -p sample generateBuildKonfig ``` -------------------------------- ### BuildKonfig Project Release Git Commands Source: https://github.com/yshrsmz/buildkonfig/blob/master/RELEASING.md A sequence of Git commands used to manage version control during the release process for the BuildKonfig project. This includes committing release preparations, tagging the version, preparing for the next development iteration, and pushing changes and tags to the remote repository. This process is part of a larger release flow that involves updating `gradle.properties`, `CHANGELOG.md`, and `README.md`, and promoting artifacts on Sonatype. ```Shell git commit -am "Prepare for release vX.Y.Z." git tag -a vX.Y.Z -m "Version X.Y.Z" git commit -am "Prepare for next development iteration" git push && git push --tags ``` -------------------------------- ### BuildKonfig Gradle Plugin Configuration Options Source: https://github.com/yshrsmz/buildkonfig/blob/master/README.md Documents the available configuration properties for the BuildKonfig Gradle plugin, including `packageName`, `objectName`, `exposeObjectWithName`, `defaultConfigs`, and `targetConfigs`. ```APIDOC packageName: Sets the package name where BuildKonfig is being placed. Required. objectName: Sets the name of the generated object. Defaults to BuildKonfig. exposeObjectWithName: Sets the name of the generated object, and make it public. defaultConfigs: Sets values which you want to have in common. Required. targetConfigs: Sets target specific values as closure. You can overwrite values specified in defaultConfigs. ``` -------------------------------- ### BuildKonfig `buildConfigField` Methods Source: https://github.com/yshrsmz/buildkonfig/blob/master/README.md Details the `buildConfigField` methods used to add new values or overwrite existing ones, including overloads for `nullable` and `const` declarations. ```APIDOC buildConfigField(type: String, name: String, value: String): Adds new value or overwrite existing one. buildConfigField(type: String, name: String, value: String, nullable: Boolean = false, const: Boolean = false): In addition to above method, this can configure nullable and const declarations. ``` -------------------------------- ### Generated Android Kotlin BuildKonfig Object Source: https://github.com/yshrsmz/buildkonfig/blob/master/README.md Illustrates the `actual` implementation of the `BuildKonfig` object generated for the `androidMain` source set, including target-specific values defined in `targetConfigs`. ```Kotlin // androidMain package com.example.app internal actual object BuildKonfig { actual val name: String = "value" actual val nullableField: String? = "NonNull-value" val name2: String = "value2" } ``` -------------------------------- ### Generated iOS Kotlin BuildKonfig Object Source: https://github.com/yshrsmz/buildkonfig/blob/master/README.md Presents the `actual` implementation of the `BuildKonfig` object generated for the `iosMain` source set, reflecting target-specific and default values as configured. ```Kotlin // iosMain package com.example.app internal actual object BuildKonfig { actual val name: String = "valueForNative" actual val nullableField: String? = null } ``` -------------------------------- ### Define BuildKonfig Flavor in gradle.properties Source: https://github.com/yshrsmz/buildkonfig/blob/master/README.md This snippet shows how to define a build flavor for BuildKonfig within the `gradle.properties` file. This flavor can then be used to apply specific configurations during the build process, allowing for environment-specific settings. ```Gradle Properties buildkonfig.flavor=dev ``` -------------------------------- ### BuildKonfig Value Overwriting Precedence Source: https://github.com/yshrsmz/buildkonfig/blob/master/README.md This snippet outlines the hierarchy of value precedence when multiple BuildKonfig configurations define the same field. Flavored target configurations take the highest priority, followed by non-flavored target configurations, then flavored default configurations, and finally default configurations. ```Plain Text Flavored TargetConfig > TargetConfig > Flavored DefaultConfig > DefaultConfig ``` -------------------------------- ### Configure Target-Dependent Values with BuildKonfig (Gradle DSL) Source: https://github.com/yshrsmz/buildkonfig/blob/master/README.md Demonstrates how to configure target-dependent values in a Kotlin Multiplatform project using BuildKonfig's `targetConfigs`. It shows setting up `defaultConfigs` and overriding values for `android` and `ios` targets using both Groovy and Kotlin Gradle DSLs. ```Groovy buildScript { repositories { mavenCentral() } dependencies { classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.0' classpath 'com.codingfeline.buildkonfig:buildkonfig-gradle-plugin:latest_version' } } apply plugin: 'org.jetbrains.kotlin.multiplatform' apply plugin: 'com.codingfeline.buildkonfig' kotlin { // your target config... androidTarget() iosX64('ios') } buildkonfig { packageName = 'com.example.app' // default config is required defaultConfigs { buildConfigField 'STRING', 'name', 'value' buildConfigField 'STRING', 'nullableField', null, nullable: true } targetConfigs { // this name should be the same as target names you specified android { buildConfigField 'STRING', 'name2', 'value2' buildConfigField 'STRING', 'nullableField', 'NonNull-value', nullable: true } ios { buildConfigField 'STRING', 'name', 'valueForNative' } } } ``` ```Kotlin import com.codingfeline.buildkonfig.compiler.FieldSpec.Type.STRING buildscript { repositories { mavenCentral() } dependencies { classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.0") classpath("com.codingfeline.buildkonfig:buildkonfig-gradle-plugin:latest_version") } } plugins { kotlin("multiplatform") id("com.codingfeline.buildkonfig") } kotlin { // your target config... androidTarget() iosX64('ios') } buildkonfig { packageName = "com.example.app" // default config is required defaultConfigs { buildConfigField(STRING, "name", "value") } targetConfigs { // names in create should be the same as target names you specified create("android") { buildConfigField(STRING, "name2", "value2") buildConfigField(STRING, "nullableField", "NonNull-value", nullable = true) } create("ios") { buildConfigField(STRING, "name", "valueForNative") } } } ``` -------------------------------- ### Generated Common Kotlin BuildKonfig Object Source: https://github.com/yshrsmz/buildkonfig/blob/master/README.md Shows the `expect` declaration of the `BuildKonfig` object generated in `commonMain` by the BuildKonfig plugin, defining the common properties expected across all targets. ```Kotlin // commonMain package com.example.app internal expect object BuildKonfig { val name: String val nullableField: String? } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.