Gradle Kotlin DSL

Gradle Kotlin DSL #

Filetree: #

  • build.gradle.kts
  • settings.gradle.kts
  • keycloak-changelog.yml
  • 01_create_realm.yml

build.gradle.kts

plugins {
  id("de.klg71.keycloakmigrationplugin") version "x.x.x"
}
repositories { 
  jcenter()
}

tasks {
    register<KeycloakMigrationTask>("keycloakMigrateLocal") {
      migrationFile = "keycloak-changelog.yml"
      adminUser = "admin"
      adminPassword = "adminPassword"
      baseUrl = "http://localhost:8080"
      realm = "master"
      waitForKeycloak(keycloakBaseUrl)
      parameters = mapOf(
              "USER_NAME" to "testUser",
              "PASSWORD" to "password"
      )
      waitForKeycloak = false
      waitForKeycloakTimeout = 0L // infinit wait time
    }
}

settings.gradle.kts

rootProject.name = "keycloak-migration"

keycloak-changelog.yml

includes:
  - path: 01_create_realm.yml

01_create_realm.yml

id: create-realm
author: lmeisege
changes:
  - addRealm:
      name: kubernetes
  - updateRealm:
      id: kubernetes
      rememberMe: true
      ssoSessionIdleTimeout: 36000

Execute #

gradle keycloakMigrateLocal

Available migrations are listed here: Migrations