5

Google Cloud Function Gradle Plugin

 2 years ago
source link: http://www.java-allandsundry.com/2022/07/google-cloud-function-gradle-plugin.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

 It is easy to develop a Google Cloud Function using Java with Gradle as the build tool. It is however not so simple to test it locally.

The current recommended approach to testing especially with gradle is very complicated. It requires pulling in Invoker libraries and adding a custom task to run the invoker function.

I have now authored a gradle plugin which makes local testing way more easier!

Problem

The way the Invoker is added in for a Cloud Function Gradle project looks like this today:
This has a lot of opaque details, for eg, what does the configurations of invoker even mean, what is the magical task that is being registered?
Now contrast it with the approach with the plugin:
All the boiler plate is now gone, configuration around the function class, which port to start it up on much more simplified. Adding this new plugin contributes a task that can be invoked the following way:
./gradlew cloudFunctionRun
It would start up an endpoint using which the function can be tested locally.

Conclusion

It may be far easier to see fully working samples incorporating this plugin. These samples are available here —

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK