Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Gradle Kotlin DSL compatibility #1009

Open
Petikoch opened this issue May 22, 2019 · 4 comments
Open

Improve Gradle Kotlin DSL compatibility #1009

Petikoch opened this issue May 22, 2019 · 4 comments

Comments

@Petikoch
Copy link

Petikoch commented May 22, 2019

Hi!

I'm switching over in my Gradle build files from Groovy (build.groovy) to the Gradle Kotlin DSL (build.groovy.kts).

(using Gradle 5.4.1)

It is not obvious IMHO, that the Groovy version of the appengine configuration section (build.gradle)

appengine {
  tools {
    // configure the Cloud Sdk tooling
  }
  stage {
    // configure staging for deployment
  }
  deploy {
    // configure deployment
  }
}

must be written (AFAIK) like this, using the Gradle Kotlin DSL (build.gradle.kts)

import com.google.cloud.tools.gradle.appengine.appyaml.AppEngineAppYamlExtension

// ...

the<AppEngineAppYamlExtension>().apply {
  tools {
    // configure the Cloud Sdk tooling
  }
  stage {
    // configure staging for deployment
  }
  deploy {
    // configure deployment
  }
}

Could you add some Gradle Kotlin DSL examples somewhere in the https://github.com/GoogleCloudPlatform/app-gradle-plugin/blob/master/USER_GUIDE.md ?

Thanks a lot and best regards,
Peti

@Petikoch Petikoch changed the title Could you add some examples for Gradle Kotlin Script based Gradle Files (.gradle.kts) Could you add some examples using the "new" Gradle Kotlin DSL (.gradle.kts) ? May 23, 2019
@Petikoch Petikoch changed the title Could you add some examples using the "new" Gradle Kotlin DSL (.gradle.kts) ? Could you add some examples using the "new" Gradle Kotlin DSL syntax (.gradle.kts) ? May 23, 2019
@loosebazooka
Copy link
Contributor

This is strange, I would ideally like the kts version to be more straight forward. Are we doing something weird in our config that makes it hard to do this?

@Petikoch
Copy link
Author

I don't know @loosebazooka ... I'm not an expert on that.
Maybe one of the Gradle Guru's like @eskatos can help?

@kulmanf
Copy link

kulmanf commented Apr 26, 2020

import com.google.cloud.tools.gradle.appengine.appyaml.AppEngineAppYamlExtension

apply(plugin = "com.google.cloud.tools.appengine")

buildscript {
    repositories {
        mavenCentral()
    }

    dependencies {
        classpath("com.google.cloud.tools:appengine-gradle-plugin:2.2.0")
    }
}

// AppEngine Configuration
configure<AppEngineAppYamlExtension> {
    tools {
        // configure the Cloud Sdk tooling
        setCloudSdkHome(File("C:/Program Files (x86)/Google/Cloud SDK/google-cloud-sdk"))
        cloudSdkVersion = "290.0.0"
    }
    stage {
        // configure staging for deployment
    }
    deploy {
        // configure deployment
        projectId = "noneofyourbusiness"
        version = "gradle-deployed-prod"
    }
}

Here is my working configuration. It has been a very frustrating experience.

Things that could be done to improve the compatibility with the Kotlin DSL

  • configure<AppEngine> { ... } instead of configure<AppEngineAppYamlExtension> { ... }
  • Allow cloudSdkHome instead of setCloudSdkHome( ... )
  • Documentation/Examples for Kotlin

@rock3r
Copy link

rock3r commented Jun 22, 2020

You can have a nicer API by providing an extension function like the one the application plugin has:

fun org.gradle.api.Project.`application`(configure: org.gradle.api.plugins.JavaApplication.() -> Unit): Unit =
    (this as org.gradle.api.plugins.ExtensionAware).extensions.configure("application", configure)

@meltsufin meltsufin changed the title Could you add some examples using the "new" Gradle Kotlin DSL syntax (.gradle.kts) ? Improve Gradle Kotlin DSL compatibility Aug 5, 2022
@JoeWang1127 JoeWang1127 transferred this issue from GoogleCloudPlatform/app-gradle-plugin Jan 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants