Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
35/100
Loại issue
Tài liệu
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
java, kotlin
Lĩnh vực
documentation

Hướng nghiên cứu

Bắt đầu từ ví dụ Gradle trong tài liệu và so sánh với cấu hình build.gradle.kts được cung cấp. Cập nhật tài liệu để bao gồm dạng Kotlin DSL và fallback khi thiếu runFunction.target, sau đó xác minh rằng ví dụ tương thích với các phiên bản Kotlin và Gradle đã nêu.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

enhancement

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<JavaExec>("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]`
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

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

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

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của GoogleCloudPlatform/functions-framework-java

Tất cả issue của GoogleCloudPlatform/functions-framework-java

Issue tương tự

Thêm issue về Java

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.