diff --git a/plugin/src/it/basic-using-docker-directory/Dockerfile b/plugin/src/it/basic-using-docker-directory/Dockerfile new file mode 100644 index 00000000..28a18141 --- /dev/null +++ b/plugin/src/it/basic-using-docker-directory/Dockerfile @@ -0,0 +1,8 @@ +FROM scratch +MAINTAINER David Flemström + +ENV BASE /opt/base + +COPY target/docker/lib $BASE/lib + +ADD src/main/docker/foo.txt $BASE/ \ No newline at end of file diff --git a/plugin/src/it/basic-using-docker-directory/pom.xml b/plugin/src/it/basic-using-docker-directory/pom.xml new file mode 100644 index 00000000..4eca588d --- /dev/null +++ b/plugin/src/it/basic-using-docker-directory/pom.xml @@ -0,0 +1,82 @@ + + + + + 4.0.0 + + com.spotify.it + basic + 1.0-SNAPSHOT + + A simple IT verifying the basic use case. + + + UTF-8 + + + + + + commons-lang + commons-lang + 2.4 + + + + + + + + + + maven-dependency-plugin + + + initialize + + copy-dependencies + + + false + runtime + ${project.build.directory}/docker/lib + + + + + + + @project.groupId@ + @project.artifactId@ + @project.version@ + + + default + + build + + + + + + + diff --git a/plugin/src/it/basic-using-docker-directory/src/main/docker/foo.txt b/plugin/src/it/basic-using-docker-directory/src/main/docker/foo.txt new file mode 100644 index 00000000..a3f81e37 --- /dev/null +++ b/plugin/src/it/basic-using-docker-directory/src/main/docker/foo.txt @@ -0,0 +1 @@ +# a text file to copy over \ No newline at end of file diff --git a/plugin/src/it/basic-using-docker-directory/src/main/java/com/foo/Foo.java b/plugin/src/it/basic-using-docker-directory/src/main/java/com/foo/Foo.java new file mode 100644 index 00000000..43d072b8 --- /dev/null +++ b/plugin/src/it/basic-using-docker-directory/src/main/java/com/foo/Foo.java @@ -0,0 +1,8 @@ +package com.foo; + + +public class Foo { + public static void main(String[] args) { + // don't do anything. + } +} diff --git a/plugin/src/it/basic-using-docker-directory/verify.groovy b/plugin/src/it/basic-using-docker-directory/verify.groovy new file mode 100644 index 00000000..0395ec6e --- /dev/null +++ b/plugin/src/it/basic-using-docker-directory/verify.groovy @@ -0,0 +1,21 @@ +/* + * -/-/- + * Dockerfile Maven Plugin + * %% + * Copyright (C) 2015 - 2016 Spotify AB + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * -\-\- + */ +File imageIdFile = new File(basedir, "target/docker/image-id") +assert imageIdFile.isFile() diff --git a/plugin/src/main/java/com/spotify/plugin/dockerfile/AbstractDockerMojo.java b/plugin/src/main/java/com/spotify/plugin/dockerfile/AbstractDockerMojo.java index fe895b7f..c73b9571 100644 --- a/plugin/src/main/java/com/spotify/plugin/dockerfile/AbstractDockerMojo.java +++ b/plugin/src/main/java/com/spotify/plugin/dockerfile/AbstractDockerMojo.java @@ -293,10 +293,19 @@ private void writeTestMetadata() throws MojoExecutionException { for (String name : dockerInfoDirectory.list()) { final File sourceFile = new File(dockerInfoDirectory, name); final File targetFile = new File(testMetadataDir, name); - try { - Files.copy(sourceFile, targetFile); - } catch (IOException e) { - throw new MojoExecutionException("Could not copy files", e); + if (sourceFile.isDirectory()) { + getLog().warn("A directory was found inside the docker info directory at " + + dockerInfoDirectory.getAbsolutePath() + + " - this usually indicates that you have used this directory for something other" + + " than this plugin. " + + "For proper functionality, please configure the `dockerfile.dockerInfoDirectory`" + + " property to something that is only used by this plugin."); + } else { + try { + Files.copy(sourceFile, targetFile); + } catch (IOException e) { + throw new MojoExecutionException("Could not copy files", e); + } } } }