From 27b2e104479c334131aed0c56f6e5ca2adff48df Mon Sep 17 00:00:00 2001 From: "Ivana Yovcheva (VMware)" Date: Tue, 2 Oct 2018 18:07:46 +0300 Subject: [PATCH] Fix java8 template to support resources 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) --- template/java8/Dockerfile | 6 +++++- template/java8/entrypoint/build.gradle | 11 +++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/template/java8/Dockerfile b/template/java8/Dockerfile index c994a52a..18db2826 100644 --- a/template/java8/Dockerfile +++ b/template/java8/Dockerfile @@ -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 \ diff --git a/template/java8/entrypoint/build.gradle b/template/java8/entrypoint/build.gradle index d059c573..e9ec4e84 100644 --- a/template/java8/entrypoint/build.gradle +++ b/template/java8/entrypoint/build.gradle @@ -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 @@ -29,6 +32,14 @@ dependencies { compile project(':function') } +sourceSets { + main { + resources { + srcDirs "src/main/resources" + } + } +} + jar { manifest { attributes 'Implementation-Title': 'OpenFaaS Function',