Skip to content

Commit

Permalink
Add Java 8 / gradle instructions
Browse files Browse the repository at this point in the history
Adds instructions on how to use Java 8 with Gradle

Signed-off-by: Alex Ellis (VMware) <[email protected]>
  • Loading branch information
alexellis committed Jul 16, 2018
1 parent 9792ce9 commit 59c6f47
Showing 1 changed file with 36 additions and 5 deletions.
41 changes: 36 additions & 5 deletions docs/cli/templates.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,44 @@ npm i --save cheerio

You can now add a `require('cheerio')` statement into your function and make use of this library.

## 4.0 Customise a template
## 4.0 Java

A Java 8 template is provided which uses Gradle 4.8.1 as a build-system.

Support is made available for external code repositories via the build.gradle file where you specify dependencies to fetch from repositories or JAR files to be added via the build.

* Write a function `java-function`:

```
$ faas-cli new --lang java8 java-function
```

* Write your code in:

./src/main/Handler.java

* Write `junit` tests in:

./src/tests/

* Update gradle config if needed in:

./build.gradle
./settings.gradle

* Working with headers

You can use `getHeader(k)` on the Request interface to query a header.

To set a header such as content-type you can use `setHeader(k, v)` on the Response interface.

## 5.0 Customise a template

It is recommended that you use the official templates as they are provided and if there is a short-coming that you raise a GitHub issue so we can improve the templates for everyone.

All templates are driven by a Dockerfile and can be customised by editing the files found in the ./template folder.

### 4.1 Update the Dockerfile
### 5.1 Update the Dockerfile

There are several reasons why you may want to update your Dockerfile, just edit `./template/<language_name>/Dockerfile`.

Expand All @@ -145,7 +176,7 @@ There are several reasons why you may want to update your Dockerfile, just edit

* Try a new version of a base-image - it may be that the project is showing support for Node.js LTS, but you want the cutting-edge version, you can do that too

### 4.2 Update a template's configuration
### 5.2 Update a template's configuration

The name of a template is read from a "template.yml" file kept within the template folder: `./template/<language_name>/template.yml`

Expand All @@ -159,13 +190,13 @@ fprocess: dotnet ./root.dll
* `language` is the display name used for `faas-cli new --list`.
* `fprocess` provides the process to run for each invocation - i.e. your function

### 4.3 Use your own templates
### 5.3 Use your own templates

You can use your own Git repository for a custom or forked set of templates. This can be public or private.

See `faas-cli template pull` for more information.

### 5.0 ARM / Raspberry Pi
### 6.0 ARM / Raspberry Pi

Templates for ARM and Raspberry Pi are provided on a best-effort basis. If you can help with maintenance please let the project contributors know.

Expand Down

0 comments on commit 59c6f47

Please sign in to comment.