Open StephenWithPH opened 7 months ago
Hi @StephenWithPH, thank you for spotting this issue, and for providing the detailed analysis.
I can reproduce this issue on my end. I'm working on a fix for this.
In the meantime, could you share the test app that you created? If possible, could you share it as a Github repo? I am specifically interested in the build.gradle.kts
& settings.gradle
files in your app.
@SandeepTuniki ... that's great to hear! Thank you for picking this one up.
You can see a repro (same code works with Groovy DSL and fails with Kotlin DSL) at https://github.com/StephenWithPH/buildpack-kotlin-dsl-repro .
Hi @StephenWithPH, thanks for the extra details! I dug into this and found that the fix is a bit more involved than just adding a check to the build.gradle.kts
file. This is actually a feature we haven't fully implemented yet—Cloud Functions doesn't currently support Kotlin DSL.
We've got this on our radar for future updates, but for now, I'd recommend using either Maven or Gradle with Groovy DSL. We've got some helpful guides on that here: https://cloud.google.com/functions/docs/create-deploy-http-java.
@SandeepTuniki ... the non-functions-framework builder for Java does handle Kotlin DSL. See https://github.com/GoogleCloudPlatform/buildpacks/issues/26 and https://github.com/GoogleCloudPlatform/buildpacks/commit/37ecf33ead9b4feb296fd15b25a0d1f16825cc30 .
Possible to crib from that in the functions-framework Java builder?
@StephenWithPH Yes, I went through that issue and PR already while investigating. We found that changes for Functions are not as straightforward as the earlier ones. This feature is on our roadmap, but I can't provide a specific timeline right now due to other pressing priorities. Rest assured, I'll share updates as soon as we have a clearer picture.
Describe the bug Having created a project via
gradle init
(Gradle 8.7) and chosen the Kotlin DSL, the following error ultimately surfaces:Creating a project via
gradle init
and choosing the Groovy DSL leads to a buildable project.Note that it seems necessary to "flatten" the project out of its default, multi-module shape. I don't believe this is relevant to the above, but will be necessary to avoid masking the error above.
Additional context How are you using GCP buildpacks?
pack
and thegcr.io/buildpacks/builder
Did this used to work? (Yes/No) Unknown
What language is your project primarily written in? (Python/Java/Node.js/Go/etc.) Kotlin
Steps To Reproduce Steps to reproduce the behavior:
gradle init
per above, choosingApplication
,Kotlin
, Java21
,Single application project
,Kotlin
DSL,no
new apis/behaviorssrc
up out ofapp
and removing theinclude
fromsettings.gradle
. Note that this is to avoid masking the error.pack build \ --builder gcr.io/buildpacks/builder:latest \ --env GOOGLE_FUNCTION_SIGNATURE_TYPE=http \ --env GOOGLE_FUNCTION_TARGET=org.example.App \ --env GOOGLE_RUNTIME_VERSION=21 \ my-first-function
Expected behavior It builds.
Actual behavior It gives the error above:
The error appears to come from:
https://github.com/GoogleCloudPlatform/buildpacks/blob/5bbd4eb223214116d2257d134c98067fc8ba1b69/cmd/java/functions_framework/main.go#L146
Earlier in that
func classpath
, the Gradle check only checks for (Groovy DSL syntax)build.gradle
, neglecting to check forbuild.gradle.kts
:https://github.com/GoogleCloudPlatform/buildpacks/blob/5bbd4eb223214116d2257d134c98067fc8ba1b69/cmd/java/functions_framework/main.go#L119
Note that a fix to support
build.gradle.kts
went into thegoogle.java
builder in https://github.com/GoogleCloudPlatform/buildpacks/commit/37ecf33ead9b4feb296fd15b25a0d1f16825cc30 , but that did not touch the functions-framework builder.