Search in sources :

Example 1 with ConsoleLogger

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

the class AssemblyProxyArchiverTest method addFile_NoPerms_CallAcceptFilesOnlyOnce.

@Test
public void addFile_NoPerms_CallAcceptFilesOnlyOnce() throws IOException, ArchiverException {
    EasyMockSupport mm = new EasyMockSupport();
    final Archiver delegate = mm.createMock(Archiver.class);
    delegate.addFile((File) anyObject(), (String) anyObject());
    EasyMock.expectLastCall().anyTimes();
    delegate.setForced(true);
    EasyMock.expectLastCall().anyTimes();
    final CounterSelector counter = new CounterSelector(true);
    final List<FileSelector> selectors = new ArrayList<FileSelector>();
    selectors.add(counter);
    mm.replayAll();
    final AssemblyProxyArchiver archiver = new AssemblyProxyArchiver("", delegate, null, selectors, null, new File("."), new ConsoleLogger(Logger.LEVEL_DEBUG, "test"));
    archiver.setForced(true);
    final File inputFile = fileManager.createTempFile();
    archiver.addFile(inputFile, "file.txt");
    assertEquals(1, counter.getCount());
    mm.verifyAll();
}
Also used : EasyMockSupport(org.easymock.classextension.EasyMockSupport) 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) File(java.io.File) Test(org.junit.Test)

Example 2 with ConsoleLogger

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

the class DependencySetAssemblyPhaseTest method testExecute_ShouldAddOneDependencyFromProject.

public void testExecute_ShouldAddOneDependencyFromProject() throws AssemblyFormattingException, ArchiveCreationException, IOException, InvalidAssemblerConfigurationException, DependencyResolutionException {
    final String outputLocation = "/out";
    final MavenProject project = newMavenProject("group", "project", "0");
    final ArtifactMock projectArtifactMock = new ArtifactMock(mm, "group", "project", "0", "jar", false);
    project.setArtifact(projectArtifactMock.getArtifact());
    final DependencySet ds = new DependencySet();
    ds.setUseProjectArtifact(false);
    ds.setOutputDirectory(outputLocation);
    ds.setOutputFileNameMapping("${artifact.artifactId}");
    ds.setUnpack(false);
    ds.setScope(Artifact.SCOPE_COMPILE);
    ds.setFileMode(Integer.toString(10, 8));
    final Assembly assembly = new Assembly();
    assembly.setId("test");
    assembly.setIncludeBaseDirectory(false);
    assembly.addDependencySet(ds);
    final MockAndControlForAddDependencySetsTask macTask = new MockAndControlForAddDependencySetsTask(mm, project);
    final ArtifactMock artifactMock = new ArtifactMock(mm, "group", "dep", "1", "jar", false);
    System.out.println("On test setup, hashcode for dependency artifact: " + artifactMock.getArtifact().hashCode());
    macTask.expectCSGetRepositories(null, null);
    macTask.expectGetDestFile(new File("junk"));
    // macTask.expectAddFile( artifactFile, "out/dep", 10 );
    project.setArtifacts(Collections.singleton(artifactMock.getArtifact()));
    macTask.expectCSGetFinalName("final-name");
    final Logger logger = new ConsoleLogger(Logger.LEVEL_DEBUG, "test");
    final MavenProject depProject = newMavenProject("group", "dep", "1");
    macTask.expectBuildFromRepository(depProject);
    macTask.expectResolveDependencySets();
    mm.replayAll();
    createPhase(macTask, logger, macTask.dependencyResolver).execute(assembly, macTask.archiver, macTask.configSource);
    mm.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) 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) Assembly(org.apache.maven.plugins.assembly.model.Assembly)

Example 3 with ConsoleLogger

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

the class AddDependencySetsTaskTest method testGetDependencyArtifacts_ShouldGetOneDependencyArtifact.

public void testGetDependencyArtifacts_ShouldGetOneDependencyArtifact() throws ArchiveCreationException, InvalidAssemblerConfigurationException {
    final MavenProject project = new MavenProject(new Model());
    final MockAndControlForAddDependencySetsTask macTask = new MockAndControlForAddDependencySetsTask(mockManager);
    final ArtifactMock artifactMock = new ArtifactMock(mockManager, "group", "artifact", "version", "jar", false);
    project.setArtifacts(Collections.singleton(artifactMock.getArtifact()));
    final DependencySet dependencySet = new DependencySet();
    final Logger logger = new ConsoleLogger(Logger.LEVEL_DEBUG, "test");
    mockManager.replayAll();
    final AddDependencySetsTask task = new AddDependencySetsTask(Collections.singletonList(dependencySet), Collections.singleton(artifactMock.getArtifact()), project, macTask.projectBuilder, logger);
    final Set<Artifact> result = task.resolveDependencyArtifacts(dependencySet);
    assertNotNull(result);
    assertEquals(1, result.size());
    assertSame(artifactMock.getArtifact(), result.iterator().next());
    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) Artifact(org.apache.maven.artifact.Artifact) MockAndControlForAddDependencySetsTask(org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddDependencySetsTask)

Example 4 with ConsoleLogger

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

the class AddDependencySetsTaskTest method testAddDependencySet_ShouldNotAddDependenciesWhenProjectHasNone.

public void testAddDependencySet_ShouldNotAddDependenciesWhenProjectHasNone() throws AssemblyFormattingException, ArchiveCreationException, InvalidAssemblerConfigurationException {
    final MavenProject project = new MavenProject(new Model());
    final MockAndControlForAddDependencySetsTask macTask = new MockAndControlForAddDependencySetsTask(mockManager);
    final DependencySet ds = new DependencySet();
    ds.setOutputDirectory("/out");
    mockManager.replayAll();
    final Logger logger = new ConsoleLogger(Logger.LEVEL_DEBUG, "test");
    final AddDependencySetsTask task = new AddDependencySetsTask(Collections.singletonList(ds), null, project, macTask.projectBuilder, logger);
    task.addDependencySet(ds, null, 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) ConsoleLogger(org.codehaus.plexus.logging.console.ConsoleLogger) Logger(org.codehaus.plexus.logging.Logger) MockAndControlForAddDependencySetsTask(org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddDependencySetsTask)

Example 5 with ConsoleLogger

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

the class AddDependencySetsTaskTest method testGetDependencyArtifacts_ShouldIgnoreTransitivePathFilteringWhenIncludeNotTransitive.

public void testGetDependencyArtifacts_ShouldIgnoreTransitivePathFilteringWhenIncludeNotTransitive() throws ArchiveCreationException, InvalidAssemblerConfigurationException {
    final MavenProject project = new MavenProject(new Model());
    final Set<Artifact> artifacts = new HashSet<Artifact>();
    final ArtifactMock am = new ArtifactMock(mockManager, "group", "artifact", "1.0", "jar", false);
    artifacts.add(am.getArtifact());
    final ArtifactMock am2 = new ArtifactMock(mockManager, "group2", "artifact2", "1.0", "jar", false);
    artifacts.add(am2.getArtifact());
    final DependencySet dependencySet = new DependencySet();
    dependencySet.addInclude("group:artifact");
    dependencySet.setUseTransitiveFiltering(false);
    final Logger logger = new ConsoleLogger(Logger.LEVEL_DEBUG, "test");
    mockManager.replayAll();
    final AddDependencySetsTask task = new AddDependencySetsTask(Collections.singletonList(dependencySet), artifacts, project, null, logger);
    final Set<Artifact> result = task.resolveDependencyArtifacts(dependencySet);
    assertNotNull(result);
    assertEquals(1, result.size());
    assertSame(am.getArtifact(), result.iterator().next());
    mockManager.verifyAll();
}
Also used : 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) Artifact(org.apache.maven.artifact.Artifact) HashSet(java.util.HashSet) MockAndControlForAddDependencySetsTask(org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddDependencySetsTask)

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