Search in sources :

Example 6 with ModuleSources

use of org.apache.maven.plugins.assembly.model.ModuleSources 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 7 with ModuleSources

use of org.apache.maven.plugins.assembly.model.ModuleSources 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 8 with ModuleSources

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

the class ModuleSetAssemblyPhaseTest method testIsDeprecatedModuleSourcesConfigPresent_ShouldCatchInclude.

public void testIsDeprecatedModuleSourcesConfigPresent_ShouldCatchInclude() {
    final ModuleSources sources = new ModuleSources();
    sources.addInclude("**/included.txt");
    final ModuleSetAssemblyPhase phase = createPhase(new ConsoleLogger(Logger.LEVEL_DEBUG, "test"), null);
    assertTrue(phase.isDeprecatedModuleSourcesConfigPresent(sources));
}
Also used : ConsoleLogger(org.codehaus.plexus.logging.console.ConsoleLogger) ModuleSources(org.apache.maven.plugins.assembly.model.ModuleSources)

Example 9 with ModuleSources

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

the class ModuleSetAssemblyPhaseTest method testIsDeprecatedModuleSourcesConfigPresent_ShouldCatchOutputDir.

public void testIsDeprecatedModuleSourcesConfigPresent_ShouldCatchOutputDir() {
    final ModuleSources sources = new ModuleSources();
    sources.setOutputDirectory("outdir");
    final ModuleSetAssemblyPhase phase = createPhase(new ConsoleLogger(Logger.LEVEL_DEBUG, "test"), null);
    assertTrue(phase.isDeprecatedModuleSourcesConfigPresent(sources));
}
Also used : ConsoleLogger(org.codehaus.plexus.logging.console.ConsoleLogger) ModuleSources(org.apache.maven.plugins.assembly.model.ModuleSources)

Aggregations

ModuleSources (org.apache.maven.plugins.assembly.model.ModuleSources)9 ConsoleLogger (org.codehaus.plexus.logging.console.ConsoleLogger)9 ArtifactMock (org.apache.maven.plugins.assembly.archive.task.testutils.ArtifactMock)4 FileSet (org.apache.maven.plugins.assembly.model.FileSet)4 MavenProject (org.apache.maven.project.MavenProject)4 EasyMockSupport (org.easymock.classextension.EasyMockSupport)4 File (java.io.File)3 Model (org.apache.maven.model.Model)3 MockAndControlForAddArtifactTask (org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddArtifactTask)3 MockAndControlForAddFileSetsTask (org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddFileSetsTask)1 Logger (org.codehaus.plexus.logging.Logger)1