Gradle usage
When consuming the published plugin, add Maven Central to plugin resolution first.
pluginManagement { repositories { gradlePluginPortal() mavenCentral() }}Apply the Kayan plugin alongside any supported Kotlin plugin, then declare the generated package, selected flavor, input files, optional format selection, and schema.
plugins { // Use any supported Kotlin plugin: // kotlin("multiplatform"), kotlin("jvm"), or kotlin("android") kotlin("multiplatform") version "<kotlin-version>" id("io.github.mohamadjaara.kayan") version "<kayan-version>"}
kayan { packageName.set("sample.generated") flavor.set("prod") baseConfigFile.set( layout.projectDirectory.file("default.json") ) customConfigFile.set( layout.projectDirectory.file("custom-overrides.json") ) // Required when using .yaml or .yml inputs unless configFormat is AUTO. // configFormat.set(io.kayan.ConfigFormat.YAML) // configFormat.set(io.kayan.ConfigFormat.AUTO) className.set("SampleConfig")
schema { string("brand_name", "BRAND_NAME") string("bundle_id", "BUNDLE_ID", required = true) boolean("feature_search_enabled", "FEATURE_SEARCH_ENABLED") stringList("support_links", "SUPPORT_LINKS") }}Kayan writes generated source under build/generated/kayan/kotlin and adds that
directory to commonMain for KMP or main for JVM and Android.
Kayan is for non-sensitive values that may appear in generated Kotlin, build outputs, and Gradle configuration. Store secrets elsewhere.
Defaults
Section titled “Defaults”Kayan uses these Gradle conventions unless you override them:
| Property | Default |
|---|---|
baseConfigFile |
default.json |
configFormat |
ConfigFormat.JSON |
validationMode |
KayanValidationMode.SUBSET |
className |
KayanConfig |
jsonSchemaOutputFile |
build/generated/kayan/schema/kayan.schema.json |
markdownSchemaOutputFile |
build/generated/kayan/schema/SCHEMA.md |
packageName, flavor, and schema must be configured by the consuming build.
File formats
Section titled “File formats”Use .json files with ConfigFormat.JSON and .yaml / .yml files with
ConfigFormat.YAML. ConfigFormat.AUTO can infer the parser from file
extensions. When both base and custom files are present, AUTO requires both
files to use the same concrete format.
Related configuration
Section titled “Related configuration”- Use Target-specific generation for KMP
expect/actualgeneration and Android flavor-specific source sets. - Use Multi-module shared config when several modules share one root config file and schema.
- Use Validation to choose between subset and strict key validation.
