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

google.java.functions-framework builder does not support Gradle Kotlin DSL build.gradle.kts #406

Open
1 of 6 tasks
StephenWithPH opened this issue Apr 25, 2024 · 5 comments
Labels
kind/enhancement New feature or request

Comments

@StephenWithPH
Copy link

StephenWithPH commented Apr 25, 2024

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 ([email protected]) ===
[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 the gcr.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:

  1. gradle init per above, choosing Application, Kotlin, Java 21, Single application project, Kotlin DSL, no new apis/behaviors
  2. "flatten" the generated code by moving src up out of app and removing the include from settings.gradle. Note that this is to avoid masking the error.
  3. 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:

return "", gcp.UserErrorf("function has neither pom.xml nor already-built jar file; %s", description)

Earlier in that func classpath, the Gradle check only checks for (Groovy DSL syntax) build.gradle, neglecting to check for build.gradle.kts:

buildGradleExists, err := ctx.FileExists("build.gradle")


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.

@StephenWithPH StephenWithPH added the kind/bug Something isn't working label Apr 25, 2024
@SandeepTuniki
Copy link
Collaborator

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.

@StephenWithPH
Copy link
Author

@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 .

@SandeepTuniki
Copy link
Collaborator

SandeepTuniki commented May 28, 2024

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.

@StephenWithPH
Copy link
Author

@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?

@SandeepTuniki SandeepTuniki added kind/enhancement New feature or request and removed kind/bug Something isn't working labels May 30, 2024
@SandeepTuniki
Copy link
Collaborator

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants
@StephenWithPH @SandeepTuniki and others