Search in sources :

Example 46 with ConsoleLogger

use of org.codehaus.plexus.logging.console.ConsoleLogger in project maven-plugins by apache.

the class AddDependencySetsTaskTest method verifyOneDependencyAdded.

private void verifyOneDependencyAdded(final String outputLocation, final boolean unpack) throws AssemblyFormattingException, ArchiveCreationException, IOException, InvalidAssemblerConfigurationException {
    final MavenProject project = new MavenProject(new Model());
    final DependencySet ds = new DependencySet();
    ds.setOutputDirectory(outputLocation);
    ds.setOutputFileNameMapping("artifact");
    ds.setUnpack(unpack);
    ds.setScope(Artifact.SCOPE_COMPILE);
    ds.setDirectoryMode(Integer.toString(10, 8));
    ds.setFileMode(Integer.toString(10, 8));
    final MockAndControlForAddDependencySetsTask macTask = new MockAndControlForAddDependencySetsTask(mockManager, new MavenProject(new Model()));
    final ArtifactMock artifactMock = new ArtifactMock(mockManager, "group", "artifact", "version", "jar", false);
    final File artifactFile = artifactMock.setNewFile();
    if (unpack) {
        macTask.expectAddArchivedFileSet();
    // macTask.expectModeChange( -1, -1, 10, 10, 2 );
    } else {
        macTask.expectAddFile(artifactFile, outputLocation + "/artifact", 10);
    }
    macTask.expectGetDestFile(new File("junk"));
    macTask.expectCSGetFinalName("final-name");
    macTask.expectCSGetRepositories(null, null);
    final MavenProject depProject = new MavenProject(new Model());
    macTask.expectBuildFromRepository(depProject);
    macTask.expectGetMode(0222, 0222);
    final Logger logger = new ConsoleLogger(Logger.LEVEL_DEBUG, "test");
    final AddDependencySetsTask task = new AddDependencySetsTask(Collections.singletonList(ds), Collections.singleton(artifactMock.getArtifact()), project, macTask.projectBuilder, logger);
    DefaultAssemblyArchiverTest.setupInterpolators(macTask.configSource);
    mockManager.replayAll();
    task.addDependencySet(ds, macTask.archiver, macTask.configSource);
    mockManager.verifyAll();
}
Also used : MockAndControlForAddDependencySetsTask(org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddDependencySetsTask) MavenProject(org.apache.maven.project.MavenProject) ConsoleLogger(org.codehaus.plexus.logging.console.ConsoleLogger) Model(org.apache.maven.model.Model) DependencySet(org.apache.maven.plugins.assembly.model.DependencySet) ArtifactMock(org.apache.maven.plugins.assembly.archive.task.testutils.ArtifactMock) ConsoleLogger(org.codehaus.plexus.logging.console.ConsoleLogger) Logger(org.codehaus.plexus.logging.Logger) File(java.io.File) MockAndControlForAddDependencySetsTask(org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddDependencySetsTask)

Example 47 with ConsoleLogger

use of org.codehaus.plexus.logging.console.ConsoleLogger in project maven-plugins by apache.

the class AddFileSetsTaskTest method testAddFileSet_ShouldAddDirectory.

public void testAddFileSet_ShouldAddDirectory() throws ArchiveCreationException, AssemblyFormattingException {
    final FileSet fs = new FileSet();
    final String dirname = "dir";
    fs.setDirectory(dirname);
    fs.setOutputDirectory("dir2");
    // ensure this exists, so the directory addition will proceed.
    final File srcDir = new File(macTask.archiveBaseDir, dirname);
    srcDir.mkdirs();
    final int[] modes = { -1, -1, -1, -1 };
    macTask.expectAdditionOfSingleFileSet(null, null, true, modes, 1, true, false);
    // macTask.expectGetProject( null );
    final MavenProject project = new MavenProject(new Model());
    DefaultAssemblyArchiverTest.setupInterpolators(macTask.configSource);
    mockManager.replayAll();
    final AddFileSetsTask task = new AddFileSetsTask(new ArrayList<FileSet>());
    task.setLogger(new ConsoleLogger(Logger.LEVEL_DEBUG, "test"));
    task.setProject(project);
    task.addFileSet(fs, macTask.archiver, macTask.configSource, macTask.archiveBaseDir);
    mockManager.verifyAll();
}
Also used : FileSet(org.apache.maven.plugins.assembly.model.FileSet) MavenProject(org.apache.maven.project.MavenProject) ConsoleLogger(org.codehaus.plexus.logging.console.ConsoleLogger) Model(org.apache.maven.model.Model) MockAndControlForAddFileSetsTask(org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddFileSetsTask) File(java.io.File)

Example 48 with ConsoleLogger

use of org.codehaus.plexus.logging.console.ConsoleLogger in project maven-plugins by apache.

the class AddFileSetsTaskTest method testAddFileSet_ShouldAddDirectoryUsingSourceDirNameForDestDir.

public void testAddFileSet_ShouldAddDirectoryUsingSourceDirNameForDestDir() throws ArchiveCreationException, AssemblyFormattingException {
    final FileSet fs = new FileSet();
    final String dirname = "dir";
    fs.setDirectory(dirname);
    final File archiveBaseDir = fileManager.createTempDir();
    // ensure this exists, so the directory addition will proceed.
    final File srcDir = new File(archiveBaseDir, dirname);
    srcDir.mkdirs();
    final int[] modes = { -1, -1, -1, -1 };
    macTask.expectAdditionOfSingleFileSet(null, null, true, modes, 1, true, false);
    // macTask.expectGetProject( null );
    final MavenProject project = new MavenProject(new Model());
    DefaultAssemblyArchiverTest.setupInterpolators(macTask.configSource);
    mockManager.replayAll();
    final AddFileSetsTask task = new AddFileSetsTask(new ArrayList<FileSet>());
    task.setLogger(new ConsoleLogger(Logger.LEVEL_DEBUG, "test"));
    task.setProject(project);
    task.addFileSet(fs, macTask.archiver, macTask.configSource, archiveBaseDir);
    mockManager.verifyAll();
}
Also used : FileSet(org.apache.maven.plugins.assembly.model.FileSet) MavenProject(org.apache.maven.project.MavenProject) ConsoleLogger(org.codehaus.plexus.logging.console.ConsoleLogger) Model(org.apache.maven.model.Model) MockAndControlForAddFileSetsTask(org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddFileSetsTask) File(java.io.File)

Example 49 with ConsoleLogger

use of org.codehaus.plexus.logging.console.ConsoleLogger in project maven-plugins by apache.

the class AssemblyProxyArchiverTest method addDirectory_NoPerms_CallAcceptFilesOnlyOnce.

@Test
public void addDirectory_NoPerms_CallAcceptFilesOnlyOnce() throws IOException, ArchiverException {
    final Archiver delegate = new JarArchiver();
    final File output = fileManager.createTempFile();
    delegate.setDestFile(output);
    final CounterSelector counter = new CounterSelector(true);
    final List<FileSelector> selectors = new ArrayList<FileSelector>();
    selectors.add(counter);
    final AssemblyProxyArchiver archiver = new AssemblyProxyArchiver("", delegate, null, selectors, null, new File("."), new ConsoleLogger(Logger.LEVEL_DEBUG, "test"));
    archiver.setForced(true);
    final File dir = fileManager.createTempDir();
    FileUtils.cleanDirectory(dir);
    fileManager.createFile(dir, "file.txt", "This is a test.");
    archiver.addDirectory(dir);
    archiver.createArchive();
    assertEquals(1, counter.getCount());
}
Also used : ConsoleLogger(org.codehaus.plexus.logging.console.ConsoleLogger) FileSelector(org.codehaus.plexus.components.io.fileselectors.FileSelector) ArrayList(java.util.ArrayList) TrackingArchiver(org.codehaus.plexus.archiver.diags.TrackingArchiver) JarArchiver(org.codehaus.plexus.archiver.jar.JarArchiver) Archiver(org.codehaus.plexus.archiver.Archiver) JarArchiver(org.codehaus.plexus.archiver.jar.JarArchiver) File(java.io.File) Test(org.junit.Test)

Example 50 with ConsoleLogger

use of org.codehaus.plexus.logging.console.ConsoleLogger in project maven-plugins by apache.

the class DependencySetAssemblyPhaseTest method testExecute_ShouldNotAddDependenciesWhenProjectHasNone.

public void testExecute_ShouldNotAddDependenciesWhenProjectHasNone() throws AssemblyFormattingException, ArchiveCreationException, IOException, InvalidAssemblerConfigurationException, DependencyResolutionException {
    final Assembly assembly = new Assembly();
    assembly.setId("test");
    assembly.setIncludeBaseDirectory(false);
    final Logger logger = new ConsoleLogger(Logger.LEVEL_DEBUG, "test");
    final MockAndControlForAddDependencySetsTask macTask = new MockAndControlForAddDependencySetsTask(mm, null);
    macTask.expectResolveDependencySets();
    mm.replayAll();
    createPhase(macTask, logger, macTask.dependencyResolver).execute(assembly, null, macTask.configSource);
    mm.verifyAll();
}
Also used : MockAndControlForAddDependencySetsTask(org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddDependencySetsTask) ConsoleLogger(org.codehaus.plexus.logging.console.ConsoleLogger) ConsoleLogger(org.codehaus.plexus.logging.console.ConsoleLogger) Logger(org.codehaus.plexus.logging.Logger) Assembly(org.apache.maven.plugins.assembly.model.Assembly)

Aggregations

ConsoleLogger (org.codehaus.plexus.logging.console.ConsoleLogger)59 MavenProject (org.apache.maven.project.MavenProject)36 File (java.io.File)32 EasyMockSupport (org.easymock.classextension.EasyMockSupport)21 Model (org.apache.maven.model.Model)20 ArtifactMock (org.apache.maven.plugins.assembly.archive.task.testutils.ArtifactMock)20 Logger (org.codehaus.plexus.logging.Logger)16 MockAndControlForAddArtifactTask (org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddArtifactTask)12 Assembly (org.apache.maven.plugins.assembly.model.Assembly)12 DependencySet (org.apache.maven.plugins.assembly.model.DependencySet)10 MockAndControlForAddDependencySetsTask (org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddDependencySetsTask)9 ModuleSources (org.apache.maven.plugins.assembly.model.ModuleSources)9 ArrayList (java.util.ArrayList)8 FileSet (org.apache.maven.plugins.assembly.model.FileSet)8 ModuleBinaries (org.apache.maven.plugins.assembly.model.ModuleBinaries)7 FileItem (org.apache.maven.plugins.assembly.model.FileItem)5 MockAndControlForAddFileSetsTask (org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddFileSetsTask)4 HashSet (java.util.HashSet)3 Artifact (org.apache.maven.artifact.Artifact)3 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)2