google.java.functions-framework builder does not support Gradle Kotlin DSL build.gradle.kts
StephenWithPH opened this issue · 5 comments
Describe the bug
Having created a project via gradle init
(Gradle 8.7) and chosen the Kotlin DSL, the following error ultimately surfaces:
[builder] Done "./gradlew clean assemble -x test --build-cache --quiet" (1m6.044632762s)
[builder] === Java - Functions Framework (google.java.functions-framework@1.1.0) ===
[builder] --------------------------------------------------------------------------------
[builder] failed to build: (error ID: 0f436744):
[builder] function has neither pom.xml nor already-built jar file; directory has these entries: .git, .gitattributes, .github, .gitignore, .gradle, README.md, build, build.gradle.kts, gradle, gradlew, gradlew.bat, settings.gradle.kts, src
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
- Cloud Functions
- Cloud Run
- Cloud Build
- App Engine Standard
- App Engine Flex
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/behaviors- "flatten" the generated code by moving
src
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:
function has neither pom.xml nor already-built jar file
The error appears to come from:
Earlier in that func classpath
, the Gradle check only checks for (Groovy DSL syntax) build.gradle
, neglecting to check for build.gradle.kts
:
Note that a fix to support build.gradle.kts
went into the google.java
builder in 37ecf33 , but that did not touch the functions-framework builder.
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 #26 and 37ecf33 .
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.