Skip to content
This repository has been archived by the owner on Mar 13, 2021. It is now read-only.

A Cloud Native Buildpack for riff java functions

License

Notifications You must be signed in to change notification settings

projectriff/java-function-buildpack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

java-function-buildpack Build Status

The Java Function Buildpack is a Cloud Native Buildpack V3 that provides the riff Java Function Invoker to functions.

This buildpack is designed to work in collaboration with other buildpacks, which are tailored to support (and know how to build / run) languages supported by riff.

In Plain English

In a nutshell, when combined with the other buildpacks present in the riff builder what this means (and especially when dealing with the riff CLI which takes care of the creation of the riff.toml file for you):

  • The presence of a pom.xml or build.gradle file will result in the compilation and execution of a java function, thanks to the java invoker
    1. the --handler flag is optional in certain cases, as documented by the java invoker
  • Ambiguity in the detection process will result in a build failure
  • The presence of the --invoker flag will entirely bypass the detection mechanism and force a given language/invoker

Detailed Buildpack Behavior

Detection Phase

Detection passes if

  • a $APPLICATION_ROOT/riff.toml exists and
  • the build plan already contains a jvm-application key (typically because a JVM based application was detected by the java buildpack)

If detection passes, the buildpack will contribute an openjdk-jre key with launch metadata to instruct the openjdk-buildpack to provide a JRE. It will also add a riff-invoker-java key and handler metadata extracted from the riff metadata.

If several languages are detected simultaneously, the detect phase errors out. The override key in riff.toml can be used to bypass detection and force the use of a particular invoker.

Build Phase

If a java build has been detected

  • Contributes the riff Java Invoker to a launch layer, set as the main java entry point with function.uri = <build-directory>?handler=<handler> set as an environment variable.

The function behavior is exposed via standard buildpack process types:

  • Contributes web process
  • Contributes function process

Bindings

The buildpack optionally accepts the following bindings during the build phase:

Type: dependency-mapping
Key Value Description
<dependency-digest> <uri> If needed, the buildpack will fetch the dependency with digest <dependency-digest> from <uri>

How to Build

Prerequisites

To build the java-function-buildpack you'll need

  • Go 1.13+
  • to run acceptance tests:
    • a running local docker daemon
  • for local function builds
    • the pack command line tool

You can build the buildpack by running

make

This will package (with pre-downloaded cache layers) the buildpack in the artifactory/io/projectriff/java/io.projectriff.java/latest directory. That can be used as a uri in a builder.toml file of a builder (see https://github.com/projectriff/builder)

License

This buildpack is released under version 2.0 of the Apache License.