diff --git a/src/main/java/org/jolokia/docker/maven/assembly/DockerAssemblyManager.java b/src/main/java/org/jolokia/docker/maven/assembly/DockerAssemblyManager.java index 54b96edc5..bfca91dcc 100644 --- a/src/main/java/org/jolokia/docker/maven/assembly/DockerAssemblyManager.java +++ b/src/main/java/org/jolokia/docker/maven/assembly/DockerAssemblyManager.java @@ -102,10 +102,17 @@ private File createTarball(BuildDirs buildDirs, File extraDir) throws MojoExecut try { TarArchiver archiver = (TarArchiver) archiverManager.getArchiver("tar"); archiver.setLongfile(TarLongFileMode.posix); - archiver.addFileSet(DefaultFileSet.fileSet(buildDirs.getOutputDirectory())); +// archiver.addFileSet(DefaultFileSet.fileSet(buildDirs.getOutputDirectory())); + archiver.addArchivedFileSet(new File(buildDirs.getOutputDirectory(),"maven.tgz"),"maven/"); + if (extraDir != null) { archiver.addFileSet(DefaultFileSet.fileSet(extraDir)); - } + + } + if( extraDir == null || ! new File(extraDir,"Dockerfile").exists()) + {//only add docker file if not in extra + archiver.addFile(new File(buildDirs.getOutputDirectory(),"Dockerfile"), "Dockerfile"); + } archiver.setDestFile(archive); archiver.createArchive(); return archive; @@ -154,7 +161,7 @@ private void createAssemblyDirArchive(AssemblyConfiguration assemblyConfig, Mojo try { assembly.setId("docker"); - assemblyArchiver.createArchive(assembly, "maven", "dir", source, false); + assemblyArchiver.createArchive(assembly, "maven", "tgz", source, false); } catch (ArchiveCreationException | AssemblyFormattingException e) { throw new MojoExecutionException( "Failed to create assembly for docker image: " + e.getMessage(), e ); } catch (InvalidAssemblerConfigurationException e) { diff --git a/src/main/resources/assemblies/rootWar.xml b/src/main/resources/assemblies/rootWar.xml index e462d82ea..e2f4e23a5 100644 --- a/src/main/resources/assemblies/rootWar.xml +++ b/src/main/resources/assemblies/rootWar.xml @@ -12,4 +12,4 @@ ROOT.war - \ No newline at end of file + diff --git a/src/test/java/org/jolokia/docker/maven/assembly/DockerAssemblyConfigurationSourceTest.java b/src/test/java/org/jolokia/docker/maven/assembly/DockerAssemblyConfigurationSourceTest.java index 3aae4ce98..55aba86d2 100644 --- a/src/test/java/org/jolokia/docker/maven/assembly/DockerAssemblyConfigurationSourceTest.java +++ b/src/test/java/org/jolokia/docker/maven/assembly/DockerAssemblyConfigurationSourceTest.java @@ -1,5 +1,9 @@ package org.jolokia.docker.maven.assembly; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import java.io.File; import org.apache.maven.project.MavenProject; @@ -9,8 +13,6 @@ import org.junit.Before; import org.junit.Test; -import static org.junit.Assert.*; - public class DockerAssemblyConfigurationSourceTest { private AssemblyConfiguration assemblyConfig; @@ -27,12 +29,12 @@ public void setup() { @Test public void testCreateSourceAbsolute() { - testCreateSource(buildParameters(".", "/src/docker", "/output/docker")); + testCreateSource(buildParameters(".", "/src/docker".replace("/", File.separator), "/output/docker".replace("/", File.separator))); } @Test public void testCreateSourceRelative() { - testCreateSource(buildParameters(".","src/docker", "output/docker")); + testCreateSource(buildParameters(".","src/docker".replace("/", File.separator), "output/docker".replace("/", File.separator))); } @Test @@ -69,18 +71,18 @@ private void testCreateSource(MojoParameters params) { String[] descriptors = source.getDescriptors(); String[] descriptorRefs = source.getDescriptorReferences(); - assertEquals(1, descriptors.length); - assertEquals(EnvUtil.prepareAbsoluteSourceDirPath(params, "assembly.xml").getAbsolutePath(), descriptors[0]); + assertEquals("count of descriptors", 1, descriptors.length); + assertEquals("directory of assembly", EnvUtil.prepareAbsoluteSourceDirPath(params, "assembly.xml").getAbsolutePath(), descriptors[0]); - assertEquals(1, descriptorRefs.length); - assertEquals("project", descriptorRefs[0]); + assertEquals("count of descriptors references", 1, descriptorRefs.length); + assertEquals("reference must be project", "project", descriptorRefs[0]); - assertFalse(source.isIgnorePermissions()); + assertFalse("We must not ignore permissions problems", source.isIgnorePermissions()); String outputDir = params.getOutputDirectory(); - assertTrue(startsWithDir(outputDir, source.getOutputDirectory())); - assertTrue(startsWithDir(outputDir, source.getWorkingDirectory())); - assertTrue(startsWithDir(outputDir, source.getTemporaryRootDirectory())); + assertTrue("validate start of output Directory is same than outputdir", startsWithDir(outputDir, source.getOutputDirectory())); + assertTrue("validate start of working Directory is same than outputdir",startsWithDir(outputDir, source.getWorkingDirectory())); + assertTrue("validate start of temporary directory is same than outputdir", startsWithDir(outputDir, source.getTemporaryRootDirectory())); } private boolean containsDir(String outputDir, File path) {