You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Running a function with Gradle & Kotlin (build.gradle.kts) #35
Thanks for putting all this together! I was trying to get the local invoker working on my local machine, which is setup using kotlin (1.3.72) and gradle (6.4.1) via the build.gradle.kts file.
The Gradle example in the documentation uses a format that doesn't seem compatible with the build.gradle.kts file, so I'm hoping sharing that particular configuration helps people set up their project.
Apart from the particular formatting for the .kts version, I did have to add one thing:
I had to add the elvis operator ?: "" for ``--target, otherwise you cannot build the project due to Illegal null value provided in this collection: [--target, null, --port, 8080]`
Reacted by breucode, Amit Upadhyay, Antonio Zugaldia, Wing-Hong Andrew Ko, iury souza, sakebook, Michael Whyte, steffen-wohlleben, Audrius, David Merrick and 15 more
Reacted by Jobin Lawrance, Myles Woerner and Pablo A Martínez Andrés
Reacted by Myles Woerner, Shibasis Patnaik, BrynjulvBrynjulvsen, Shalom Halbert, Zack Manning and Pablo A Martínez Andrés
@jasperroel
Hey there,
Where is val invoker by configurations.creating coming from? I can't resolve the example of yours because I have no idea what invoker is.
Did you add the implementation line that imports the dependencies? implementation("com.google.cloud.functions:functions-framework-api:1.0.1") (or even 1.0.4, I see there have been some updates since then).
This worked fine for me, too without specifying a new configuration. One only needs a configuration with resolve=false:
dependencies {
implementation(Libs.gfun)
compileOnly(Libs.gfunInvoker) // for running the function locally
}
tasks.register<JavaExec>("runFunction") {
main ="com.google.cloud.functions.invoker.runner.Invoker"
classpath(configurations.compileOnly)
inputs.files(configurations.runtimeClasspath.get(), sourceSets.main.get().output)
args(
"--target", "<My Target class>",
"--port", 8080// hard-coded port
)
doFirst {
args("--classpath", files(configurations.runtimeClasspath.get(), sourceSets.main.get().output).asPath)
}
}
where Libs.gfun is "com.google.cloud.functions:functions-framework-api:1.0.4" or the latest version
and Libs.gfunInvoker is "com.google.cloud.functions.invoker:java-function-invoker:1.0.2" or the latest version
Activity
xetra11 commentedon Mar 19, 2021
@jasperroel
Hey there,
Where is
val invoker by configurations.creatingcoming from? I can't resolve the example of yours because I have no idea whatinvokeris.jasperroel commentedon Apr 1, 2021
@xetra11
Good question, honestly don't know anymore.
My example is "just" the
.ktstranslation of this regularbuild.gradlescript here: https://github.com/GoogleCloudPlatform/functions-framework-java#configuration-in-buildgradleDid you add the
implementationline that imports the dependencies?implementation("com.google.cloud.functions:functions-framework-api:1.0.1")(or even1.0.4, I see there have been some updates since then).i-walker commentedon May 17, 2021
This worked fine for me, too without specifying a new configuration. One only needs a configuration with
resolve=false:dependencies { implementation(Libs.gfun) compileOnly(Libs.gfunInvoker) // for running the function locally } tasks.register<JavaExec>("runFunction") { main = "com.google.cloud.functions.invoker.runner.Invoker" classpath(configurations.compileOnly) inputs.files(configurations.runtimeClasspath.get(), sourceSets.main.get().output) args( "--target", "<My Target class>", "--port", 8080 // hard-coded port ) doFirst { args("--classpath", files(configurations.runtimeClasspath.get(), sourceSets.main.get().output).asPath) } }where Libs.gfun is "com.google.cloud.functions:functions-framework-api:1.0.4" or the latest version
and Libs.gfunInvoker is "com.google.cloud.functions.invoker:java-function-invoker:1.0.2" or the latest version