Skip to content
This repository was archived by the owner on Mar 31, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions plugin/src/it/basic-using-docker-directory/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM scratch
MAINTAINER David Flemström <dflemstr@spotify.com>

ENV BASE /opt/base

COPY target/docker/lib $BASE/lib

ADD src/main/docker/foo.txt $BASE/
82 changes: 82 additions & 0 deletions plugin/src/it/basic-using-docker-directory/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
-/-/-
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.
-\-\-
-->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.spotify.it</groupId>
<artifactId>basic</artifactId>
<version>1.0-SNAPSHOT</version>

<description>A simple IT verifying the basic use case.</description>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<!-- an arbitrary dependency we can make this test copy to the target/docker/ directory -->
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.4</version>
</dependency>

</dependencies>

<build>
<plugins>

<!-- Copy Maven dependencies into target/lib/ -->
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<overWriteReleases>false</overWriteReleases>
<includeScope>runtime</includeScope>
<outputDirectory>${project.build.directory}/docker/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
<version>@project.version@</version>
<executions>
<execution>
<id>default</id>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# a text file to copy over
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.foo;


public class Foo {
public static void main(String[] args) {
// don't do anything.
}
}
21 changes: 21 additions & 0 deletions plugin/src/it/basic-using-docker-directory/verify.groovy
Original file line number Diff line number Diff line change
@@ -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()
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
}
Expand Down