GoogleCloudPlatform / GoogleCloudPlatform/functions-framework-java

Running a function with Gradle & Kotlin (build.gradle.kts)

Đang mở
#35 3 bình luận 34 reaction 0 người được giao Xem trên GitHub
enhancement
Ngôn ngữ chính
Java
Star
154
Fork
63
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

Thanks for putting all this together! I was trying to get the local invoker working on my local machine, which is setup using kotlin (`1.3.72`) and gradle (`6.4.1`) via the `build.gradle.kts` file.

The Gradle example in the documentation uses a format that doesn't seem compatible with the `build.gradle.kts` file, so I'm hoping sharing that particular configuration helps people set up their project.

# `build.gradle.kts`
```
val invoker by configurations.creating

dependencies {
implementation("com.google.cloud.functions:functions-framework-api:1.0.1")
invoker("com.google.cloud.functions.invoker:java-function-invoker:1.0.0-alpha-2-rc5")
}

task("runFunction") {
main = "com.google.cloud.functions.invoker.runner.Invoker"
classpath(invoker)
inputs.files(configurations.runtimeClasspath, sourceSets["main"].output)
args(
"--target", project.findProperty("runFunction.target") ?: "",
"--port", project.findProperty("runFunction.port") ?: 8080
)
doFirst {
args("--classpath", files(configurations.runtimeClasspath, sourceSets["main"].output).asPath)
}
}

```

Apart from the particular formatting for the `.kts` version, I did have to add one thing:
- I had to add the elvis operator `?: ""` for ``--target`, otherwise you cannot build the project due to `Illegal null value provided in this collection: [--target, null, --port, 8080]`

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.