Skip to content

Commit 59c6f47

Browse files
committed
Add Java 8 / gradle instructions
Adds instructions on how to use Java 8 with Gradle Signed-off-by: Alex Ellis (VMware) <[email protected]>
1 parent 9792ce9 commit 59c6f47

File tree

1 file changed

+36
-5
lines changed

1 file changed

+36
-5
lines changed

docs/cli/templates.md

+36-5
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,44 @@ npm i --save cheerio
129129

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

132-
## 4.0 Customise a template
132+
## 4.0 Java
133+
134+
A Java 8 template is provided which uses Gradle 4.8.1 as a build-system.
135+
136+
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.
137+
138+
* Write a function `java-function`:
139+
140+
```
141+
$ faas-cli new --lang java8 java-function
142+
```
143+
144+
* Write your code in:
145+
146+
./src/main/Handler.java
147+
148+
* Write `junit` tests in:
149+
150+
./src/tests/
151+
152+
* Update gradle config if needed in:
153+
154+
./build.gradle
155+
./settings.gradle
156+
157+
* Working with headers
158+
159+
You can use `getHeader(k)` on the Request interface to query a header.
160+
161+
To set a header such as content-type you can use `setHeader(k, v)` on the Response interface.
162+
163+
## 5.0 Customise a template
133164

134165
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.
135166

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

138-
### 4.1 Update the Dockerfile
169+
### 5.1 Update the Dockerfile
139170

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

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

146177
* 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
147178

148-
### 4.2 Update a template's configuration
179+
### 5.2 Update a template's configuration
149180

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

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

162-
### 4.3 Use your own templates
193+
### 5.3 Use your own templates
163194

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

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

168-
### 5.0 ARM / Raspberry Pi
199+
### 6.0 ARM / Raspberry Pi
169200

170201
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.
171202

0 commit comments

Comments
 (0)