GoogleCloudPlatform / functions-framework-java

FaaS (Function as a service) framework for writing portable Java functions
Apache License 2.0
130 stars 63 forks source link

Deploying google cloud function as a JAR with gen2 #260

Open fancywriter opened 6 months ago

fancywriter commented 6 months ago

Hello! I tried to follow this tutorial to deploy JAR without any sort of Maven/Gradle plugins (was going to try both uber and thin, so far thin with "hello world" code worked). https://cloud.google.com/functions/docs/concepts/java-deploy#build_and_deploy_an_uber_jar

However, if I add --gen2 option, it doesn't seem to work.

$ gcloud functions deploy gcloud-functions-example-gen2 --gen2 --runtime=java17 --source=./deployment/ --entry-point com.example.HelloHttpFunction --trigger-http --region europe-west1 
ERROR: (gcloud.functions.deploy) Invalid value for [--source]: Provided source directory does not have file [pom.xml] which is required for [java17]. Did you specify the right source?

It complains about mission pom.xml, which I obviously do not have, I have only

$ ls deployment/
gcloud-functions-example.jar
$ jar -tf deployment/gcloud-functions-example.jar 
META-INF/MANIFEST.MF
com/
com/example/
com/example/HelloHttpFunction.class
com/example/HelloHttpFunction.tasty

Is this not supported for gen2 deliberately or could it be a bug/missing feature?

What I wish eventually is to deploy thin JAR with only my code with changes often... using some fat libraries which change rarely. Is this even possible? Documentation page was not 100% clear about that. It says that I have to add line to Manifest

Class-Path: libs/dep1.jar libs/dep2.jar

What happens with these two lib/dev1.jar and lib/dev2.jar files? Are they deployed just once and reused on further redeployments? Are they redeployed if their checksum is changed (let's say if I upgrade library)?