gcp-cloudfunction-gradle-plugin

Gradle plugin to work with GCP Cloud Functions

View on GitHub

Google Cloud Function Gradle Plugin

This is a Gradle Plugin that makes it easy to test a Java based Google Cloud Function locally for Gradle based projects.

Using the Plugin

Add the plugin to the build.gradle file the following way:

plugins{
  id 'java'
  id "io.github.bijukunjummen.cloudfunction"
}

Note that the plugin depends on java plugin being present.

Provide details of the endpoint that the function exposes:

cloudFunctionRun {
  target = "functions.HelloHttp"
  port = 8080
}

This snippet indicates that the function being exposed is from functions.HelloHttp class, and the endpoint should be available locally at port 8080.

A local version of the function can now be started up this way:

./gradlew cloudFunctionRun

Samples

Here are two sample projects which use the plugin:

  1. Http Cloud Function
  2. Pub/Sub Cloud Function