bmuschko / gradle-cargo-plugin

Gradle plugin that provides deployment capabilities to local and remote containers via Cargo
Apache License 2.0
258 stars 63 forks source link

gradle syntax how to convert to gradle kotlin script #195

Open lenvonsam opened 5 years ago

lenvonsam commented 5 years ago

how to convert cargo gradle config syntax to build.gradle.kts file?

henrik242 commented 4 years ago

@bmuschko Would you be able to provide kotlin-dsl samples as well?

bmuschko commented 4 years ago

You may have seen that I am actively looking for someone to take on the development of this plugin in the README file. I won't have the time to contribute additional samples in the Kotlin DSL but I'd be more than open to access pull requests if someone wants to take on the work. The Gradle Docker plugin does something similar so a solution could use the same kind of approach.

jutoft commented 4 years ago

We tried to use this plugin in kotlin and got this issue:

It fails with a class cast exception in com.bmuschko.gradle.cargo.convention.CargoPluginExtension#deployable:

deployable(delegateClosureOf<Deployable> {
    context = "our-deployable"
})

It expects a DeployableClosureDelegate, but got a delegate closure (which is Gradle-Kotlin's strongly-typed variant of Groovy closures). However, com.bmuschko.gradle.cargo.convention.CargoPluginExtension.DeployableClosureDelegate is a private class so we cannot instantiate it.

henrik242 commented 4 years ago

Try using the Kotlin DSL Groovy Builder, that worked for us.

jruuttun commented 4 years ago

Try using the Kotlin DSL Groovy Builder, that worked for us.

A limited example workaround using withGroovyBuilder as suggested by @henrik242:

configure<CargoPluginExtension> {
  containerId = "tomcat8x"
  port = 7070
  withGroovyBuilder {
    "deployable" {
      "setContext"("example")
    }
    "remote" {
      "setHostname"("myhost")
      "setUsername"("someuser")
      "setPassword"("xxx")
    }
  }
}