Skip to content

Commit

Permalink
Fix java8 template to support resources
Browse files Browse the repository at this point in the history
With this change all resources within function's
`src/main/resources` will be added to function.jar. Before that
they used to be omited. The distribution, created after `gradle
build` was modifying the jars, excluding all resources. Fixed
that by deleting this distribution and creating a controlled one
with `gradle distZip`

Signed-off-by: Ivana Yovcheva (VMware) <iyovcheva@vmware.com>
  • Loading branch information
ivanayov committed Oct 15, 2018
1 parent 6b7a4a5 commit 27b2e10
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
6 changes: 5 additions & 1 deletion template/java8/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ WORKDIR /home/app

COPY . /home/app/

RUN gradle build
# The distribution created by `gradle build` is modifying the jars, excluding all resources.
# For that reason it is removed and created with `gradle distZip`
RUN gradle build \
&& rm /home/app/entrypoint/build/distributions/entrypoint* \
&& gradle distZip

FROM openjdk:8u121-jdk-alpine as ship
RUN apk --no-cache add curl \
Expand Down
11 changes: 11 additions & 0 deletions template/java8/entrypoint/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ plugins {
// Apply the application plugin to add support for building an application
id 'application'

// Apply the distribution plugin to add resources to entrypoint dist
id 'distribution'

}

// Define the main class for the application
Expand All @@ -29,6 +32,14 @@ dependencies {
compile project(':function')
}

sourceSets {
main {
resources {
srcDirs "src/main/resources"
}
}
}

jar {
manifest {
attributes 'Implementation-Title': 'OpenFaaS Function',
Expand Down

0 comments on commit 27b2e10

Please sign in to comment.