File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed
functions/helloworld/hello-http-gradle Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -20,9 +20,14 @@ repositories {
2020 mavenCentral()
2121}
2222
23+ configurations {
24+ invoker
25+ }
26+
2327dependencies {
2428 // Every function needs this dependency to get the Functions Framework API.
25- compileOnly ' com.google.cloud.functions:functions-framework-api:1.0.4'
29+ implementation ' com.google.cloud.functions:functions-framework-api:1.0.4'
30+ invoker ' com.google.cloud.functions.invoker:java-function-invoker:1.1.0'
2631
2732 // Function implementations can have additional dependencies like this.
2833 implementation ' com.google.code.gson:gson:2.8.8'
3944 // There must be a jar {} section, though the archiveBaseName does not have to be 'function'.
4045 archiveBaseName = ' function'
4146}
47+
48+ // Run your function locally:
49+ // ./gradlew runFunction -Prun.functionTarget=functions.HelloHttp -Prun.port=8080
50+ tasks. register(" runFunction" , JavaExec ) {
51+ main = ' com.google.cloud.functions.invoker.runner.Invoker'
52+ classpath(configurations. invoker)
53+ inputs. files(configurations. runtimeClasspath, sourceSets. main. output)
54+ args(
55+ ' --target' , project. findProperty(' run.functionTarget' ),
56+ ' --port' , project. findProperty(' run.port' ) ?: 8080
57+ )
58+ doFirst {
59+ args(' --classpath' , files(configurations. runtimeClasspath, sourceSets. main. output). asPath)
60+ }
61+ }
4262// [END functions_build_gradle]
You can’t perform that action at this time.
0 commit comments