Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output to dir is now an archive. #139

Merged
merged 3 commits into from
May 15, 2015
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/assemblies/rootWar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
<outputFileNameMapping>ROOT.war</outputFileNameMapping>
</dependencySet>
</dependencySets>
</assembly>
</assembly>
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -9,8 +13,6 @@
import org.junit.Before;
import org.junit.Test;

import static org.junit.Assert.*;

public class DockerAssemblyConfigurationSourceTest {

private AssemblyConfiguration assemblyConfig;
Expand All @@ -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
Expand Down Expand Up @@ -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) {
Expand Down