Building of Java project with no dependencies (#165)

* Bug: Fix building of Java project with no deps

Currently there is no way to perform a Docker `COPY` where the source
directory has no files, i.e. no way to ignore the error. So this change
puts all the dependencies into the /function/target directory whereas
they were in the /function/target/dependency directory before. This has
the benefit of knowing that the COPY command will always succeed even if
there are no dependencies as atleast the function jar itself will be in
/function/target directory.

* Add fail-never to first maven invocation

This is important as if the pom.xml has a compilation step, for example,
generate some source for me from my proto files in my src/main/resource
directory, this would fail as we have not copied the source directory in
yet.
This commit is contained in:
Mukhtar Haji
2017-07-31 00:32:12 +01:00
committed by Travis Reeder
parent 53cbe2d5a4
commit e69ceebed4

View File

@@ -71,7 +71,6 @@ func (lh *JavaLangHelper) Cmd() string {
func (lh *JavaLangHelper) DockerfileCopyCmds() []string {
return []string{
"COPY --from=build-stage /function/target/*.jar /function/app/",
"COPY --from=build-stage /function/target/dependency/*.jar /function/lib/",
}
}
@@ -80,7 +79,8 @@ func (lh *JavaLangHelper) DockerfileBuildCmds() []string {
return []string{
fmt.Sprintf("ENV MAVEN_OPTS %s", mavenOpts()),
"ADD pom.xml /function/pom.xml",
"RUN [\"mvn\", \"package\", \"dependency:copy-dependencies\", \"-DincludeScope=runtime\", \"-DskipTests=true\", \"-Dmdep.prependGroupId=true\"]",
"RUN [\"mvn\", \"package\", \"dependency:copy-dependencies\", \"-DincludeScope=runtime\", " +
"\"-DskipTests=true\", \"-Dmdep.prependGroupId=true\", \"-DoutputDirectory=target\", \"--fail-never\"]",
"ADD src /function/src",
"RUN [\"mvn\", \"package\"]",
}