Skip to content

Instantly share code, notes, and snippets.

@wangyung
Created January 9, 2025 03:35
Show Gist options
  • Save wangyung/27b996f957e404cd8e2ba69cd3f76764 to your computer and use it in GitHub Desktop.
Save wangyung/27b996f957e404cd8e2ba69cd3f76764 to your computer and use it in GitHub Desktop.
Tips of using extra in gradle kts

Tips of using extra in build.gradle.kts

we can use extra.apply to set bunch of properties rather than using many by extra. For example,

// in top of build.gradle.kts
extra.apply {
    set("openApiVersion", "123")
    set("ktorVersion", "3.0")
}

then we can get those extra values in other kts file.

// In other build.gradle.kts

val ktorVersion = rootProject.extra["ktorVersion"] // ktorVersion would be "3.0"
val openApiVersion = rootProject.extra["openApiVersion"] // openApiVersion would be "123"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment