Search in sources :

Example 16 with FileSet

use of org.apache.maven.plugins.assembly.model.FileSet in project maven-plugins by apache.

the class ModuleSetAssemblyPhaseTest method testCreateFileSet_ShouldUseModuleDirOnlyWhenOutDirIsNull.

public void testCreateFileSet_ShouldUseModuleDirOnlyWhenOutDirIsNull() throws AssemblyFormattingException {
    final EasyMockSupport mm = new EasyMockSupport();
    final Model model = new Model();
    model.setArtifactId("artifact");
    final MavenProject project = new MavenProject(model);
    final MockAndControlForAddArtifactTask macTask = new MockAndControlForAddArtifactTask(mm, project);
    macTask.expectGetFinalName(null);
    final FileSet fs = new FileSet();
    final ModuleSources sources = new ModuleSources();
    sources.setIncludeModuleDirectory(true);
    final File basedir = fileManager.createTempDir();
    final MavenProject artifactProject = new MavenProject(new Model());
    artifactProject.setFile(new File(basedir, "pom.xml"));
    final ArtifactMock artifactMock = new ArtifactMock(mm, "group", "artifact", "version", "jar", false);
    artifactProject.setArtifact(artifactMock.getArtifact());
    DefaultAssemblyArchiverTest.setupInterpolators(macTask.configSource);
    mm.replayAll();
    final FileSet result = createPhase(new ConsoleLogger(Logger.LEVEL_DEBUG, "test"), null).createFileSet(fs, sources, artifactProject, macTask.configSource);
    assertEquals("artifact/", result.getOutputDirectory());
    mm.verifyAll();
}
Also used : MockAndControlForAddArtifactTask(org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddArtifactTask) EasyMockSupport(org.easymock.classextension.EasyMockSupport) MavenProject(org.apache.maven.project.MavenProject) FileSet(org.apache.maven.plugins.assembly.model.FileSet) ConsoleLogger(org.codehaus.plexus.logging.console.ConsoleLogger) Model(org.apache.maven.model.Model) ArtifactMock(org.apache.maven.plugins.assembly.archive.task.testutils.ArtifactMock) ModuleSources(org.apache.maven.plugins.assembly.model.ModuleSources) File(java.io.File)

Example 17 with FileSet

use of org.apache.maven.plugins.assembly.model.FileSet in project maven-plugins by apache.

the class ModuleSetAssemblyPhaseTest method testAddModuleSourceFileSets_ShouldAddOneSourceDirectory.

public void testAddModuleSourceFileSets_ShouldAddOneSourceDirectory() throws ArchiveCreationException, AssemblyFormattingException {
    final EasyMockSupport mm = new EasyMockSupport();
    final MockAndControlForAddFileSetsTask macTask = new MockAndControlForAddFileSetsTask(mm, fileManager);
    final MavenProject project = createProject("group", "artifact", "version", null);
    macTask.expectGetProject(project);
    final ArtifactMock artifactMock = new ArtifactMock(mm, "group", "artifact", "version", "jar", false);
    project.setArtifact(artifactMock.getArtifact());
    final Set<MavenProject> projects = singleton(project);
    final ModuleSources sources = new ModuleSources();
    final FileSet fs = new FileSet();
    fs.setDirectory("/src");
    fs.setDirectoryMode("777");
    fs.setFileMode("777");
    sources.addFileSet(fs);
    macTask.expectGetArchiveBaseDirectory();
    final int mode = TypeConversionUtils.modeToInt("777", new ConsoleLogger(Logger.LEVEL_DEBUG, "test"));
    final int[] modes = { -1, -1, mode, mode };
    macTask.expectAdditionOfSingleFileSet(project, "final-name", false, modes, 1, true, false);
    DefaultAssemblyArchiverTest.setupInterpolators(macTask.configSource);
    mm.replayAll();
    final Logger logger = new ConsoleLogger(Logger.LEVEL_DEBUG, "test");
    createPhase(logger, null).addModuleSourceFileSets(sources, projects, macTask.archiver, macTask.configSource);
    mm.verifyAll();
}
Also used : EasyMockSupport(org.easymock.classextension.EasyMockSupport) MavenProject(org.apache.maven.project.MavenProject) FileSet(org.apache.maven.plugins.assembly.model.FileSet) ConsoleLogger(org.codehaus.plexus.logging.console.ConsoleLogger) ArtifactMock(org.apache.maven.plugins.assembly.archive.task.testutils.ArtifactMock) MockAndControlForAddFileSetsTask(org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddFileSetsTask) ModuleSources(org.apache.maven.plugins.assembly.model.ModuleSources) ConsoleLogger(org.codehaus.plexus.logging.console.ConsoleLogger) Logger(org.codehaus.plexus.logging.Logger)

Example 18 with FileSet

use of org.apache.maven.plugins.assembly.model.FileSet in project maven-plugins by apache.

the class AddFileSetsTaskTest method testGetFileSetDirectory_ShouldReturnDirFromBasedirAndSourceDir.

public void testGetFileSetDirectory_ShouldReturnDirFromBasedirAndSourceDir() throws ArchiveCreationException, AssemblyFormattingException {
    final File dir = fileManager.createTempDir();
    final String srcPath = "source";
    final File srcDir = new File(dir, srcPath);
    final FileSet fs = new FileSet();
    fs.setDirectory(srcPath);
    final File result = new AddFileSetsTask(new ArrayList<FileSet>()).getFileSetDirectory(fs, dir, null);
    assertEquals(srcDir.getAbsolutePath(), result.getAbsolutePath());
}
Also used : FileSet(org.apache.maven.plugins.assembly.model.FileSet) ArrayList(java.util.ArrayList) MockAndControlForAddFileSetsTask(org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddFileSetsTask) File(java.io.File)

Example 19 with FileSet

use of org.apache.maven.plugins.assembly.model.FileSet in project maven-plugins by apache.

the class AddFileSetsTaskTest method testGetFileSetDirectory_ShouldReturnAbsoluteSourceDir.

public void testGetFileSetDirectory_ShouldReturnAbsoluteSourceDir() throws ArchiveCreationException, AssemblyFormattingException {
    final File dir = fileManager.createTempDir();
    final FileSet fs = new FileSet();
    fs.setDirectory(dir.getAbsolutePath());
    final File result = new AddFileSetsTask(new ArrayList<FileSet>()).getFileSetDirectory(fs, null, null);
    assertEquals(dir.getAbsolutePath(), result.getAbsolutePath());
}
Also used : FileSet(org.apache.maven.plugins.assembly.model.FileSet) ArrayList(java.util.ArrayList) MockAndControlForAddFileSetsTask(org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddFileSetsTask) File(java.io.File)

Example 20 with FileSet

use of org.apache.maven.plugins.assembly.model.FileSet in project maven-plugins by apache.

the class DefaultAssemblyReader method includeSiteInAssembly.

@Override
public void includeSiteInAssembly(final Assembly assembly, final AssemblerConfigurationSource configSource) throws InvalidAssemblerConfigurationException {
    final File siteDirectory = configSource.getSiteDirectory();
    if (!siteDirectory.exists()) {
        throw new InvalidAssemblerConfigurationException("site did not exist in the target directory - " + "please run site:site before creating the assembly");
    }
    getLogger().info("Adding site directory to assembly : " + siteDirectory);
    final FileSet siteFileSet = new FileSet();
    siteFileSet.setDirectory(siteDirectory.getPath());
    siteFileSet.setOutputDirectory("/site");
    assembly.addFileSet(siteFileSet);
}
Also used : FileSet(org.apache.maven.plugins.assembly.model.FileSet) InvalidAssemblerConfigurationException(org.apache.maven.plugins.assembly.InvalidAssemblerConfigurationException) File(java.io.File)

Aggregations

FileSet (org.apache.maven.plugins.assembly.model.FileSet)27 File (java.io.File)19 MavenProject (org.apache.maven.project.MavenProject)14 Model (org.apache.maven.model.Model)11 MockAndControlForAddFileSetsTask (org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddFileSetsTask)11 Assembly (org.apache.maven.plugins.assembly.model.Assembly)9 ConsoleLogger (org.codehaus.plexus.logging.console.ConsoleLogger)8 ArrayList (java.util.ArrayList)6 FileOutputStream (java.io.FileOutputStream)4 OutputStreamWriter (java.io.OutputStreamWriter)4 StringWriter (java.io.StringWriter)4 Writer (java.io.Writer)4 ArtifactMock (org.apache.maven.plugins.assembly.archive.task.testutils.ArtifactMock)4 Component (org.apache.maven.plugins.assembly.model.Component)4 ModuleSources (org.apache.maven.plugins.assembly.model.ModuleSources)4 AssemblyXpp3Writer (org.apache.maven.plugins.assembly.model.io.xpp3.AssemblyXpp3Writer)4 ComponentXpp3Writer (org.apache.maven.plugins.assembly.model.io.xpp3.ComponentXpp3Writer)4 EasyMockSupport (org.easymock.classextension.EasyMockSupport)4 StringReader (java.io.StringReader)3 MockAndControlForAddArtifactTask (org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddArtifactTask)3