Search in sources :

Example 51 with ConsoleLogger

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

the class RepositoryAssemblyPhaseTest method testExecute_ShouldNotIncludeRepositoryIfNonSpecifiedInAssembly.

public void testExecute_ShouldNotIncludeRepositoryIfNonSpecifiedInAssembly() throws ArchiveCreationException, AssemblyFormattingException, InvalidAssemblerConfigurationException {
    final EasyMockSupport mm = new EasyMockSupport();
    final MockAndControlForRepositoryAssembler macRepo = new MockAndControlForRepositoryAssembler(mm);
    final MockAndControlForArchiver macArchiver = new MockAndControlForArchiver(mm);
    final MockAndControlForConfigSource macCS = new MockAndControlForConfigSource(mm);
    final File tempRoot = fileManager.createTempDir();
    macCS.expectGetTemporaryRootDirectory(tempRoot);
    final Assembly assembly = new Assembly();
    assembly.setId("test");
    mm.replayAll();
    createPhase(macRepo.repositoryAssembler, new ConsoleLogger(Logger.LEVEL_DEBUG, "test")).execute(assembly, macArchiver.archiver, macCS.configSource);
    mm.verifyAll();
}
Also used : EasyMockSupport(org.easymock.classextension.EasyMockSupport) ConsoleLogger(org.codehaus.plexus.logging.console.ConsoleLogger) File(java.io.File) Assembly(org.apache.maven.plugins.assembly.model.Assembly)

Example 52 with ConsoleLogger

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

the class RepositoryAssemblyPhaseTest method testExecute_ShouldIncludeOneRepository.

public void testExecute_ShouldIncludeOneRepository() throws ArchiveCreationException, AssemblyFormattingException, InvalidAssemblerConfigurationException {
    final EasyMockSupport mm = new EasyMockSupport();
    final MockAndControlForRepositoryAssembler macRepo = new MockAndControlForRepositoryAssembler(mm);
    final MockAndControlForArchiver macArchiver = new MockAndControlForArchiver(mm);
    final MockAndControlForConfigSource macCS = new MockAndControlForConfigSource(mm);
    final File tempRoot = fileManager.createTempDir();
    macCS.expectGetTemporaryRootDirectory(tempRoot);
    macCS.expectGetProject(new MavenProject(new Model()));
    macCS.expectGetFinalName("final-name");
    macCS.expectInterpolators();
    final Assembly assembly = new Assembly();
    assembly.setId("test");
    final Repository repo = new Repository();
    repo.setOutputDirectory("out");
    repo.setDirectoryMode("777");
    repo.setFileMode("777");
    final int mode = TypeConversionUtils.modeToInt("777", new ConsoleLogger(Logger.LEVEL_DEBUG, "test"));
    final File outDir = new File(tempRoot, "out");
    macArchiver.expectModeChange(-1, -1, mode, mode, true);
    macArchiver.expectAddDirectory(outDir, "out/", null, null);
    macRepo.expectAssemble();
    assembly.addRepository(repo);
    mm.replayAll();
    createPhase(macRepo.repositoryAssembler, new ConsoleLogger(Logger.LEVEL_DEBUG, "test")).execute(assembly, macArchiver.archiver, macCS.configSource);
    mm.verifyAll();
}
Also used : EasyMockSupport(org.easymock.classextension.EasyMockSupport) Repository(org.apache.maven.plugins.assembly.model.Repository) MavenProject(org.apache.maven.project.MavenProject) ConsoleLogger(org.codehaus.plexus.logging.console.ConsoleLogger) Model(org.apache.maven.model.Model) File(java.io.File) Assembly(org.apache.maven.plugins.assembly.model.Assembly)

Example 53 with ConsoleLogger

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

the class AddDependencySetsTaskTest method testAddDependencySet_ShouldNotAddDependenciesWhenProjectIsStubbed.

// TODO: Find a better way of testing the project-stubbing behavior when a ProjectBuildingException takes place.
public void testAddDependencySet_ShouldNotAddDependenciesWhenProjectIsStubbed() throws AssemblyFormattingException, ArchiveCreationException, InvalidAssemblerConfigurationException, IOException {
    final MavenProject project = new MavenProject(new Model());
    final ProjectBuildingException pbe = new ProjectBuildingException("test", "Test error.", new Throwable());
    final MockAndControlForAddDependencySetsTask macTask = new MockAndControlForAddDependencySetsTask(mockManager, new MavenProject(new Model()));
    final String gid = "org.test";
    final String aid = "test-dep";
    final String version = "2.0-SNAPSHOT";
    final String type = "jar";
    final File file = new File("dep-artifact.jar");
    final ArtifactMock depMock = new ArtifactMock(mockManager, gid, aid, version, type, true);
    depMock.setBaseVersion(version);
    depMock.setFile(file);
    final File destFile = new File("assembly-dep-set.zip");
    macTask.expectGetDestFile(destFile);
    macTask.expectBuildFromRepository(pbe);
    macTask.expectCSGetRepositories(null, null);
    macTask.expectCSGetFinalName("final-name");
    macTask.expectAddFile(file, "out/" + aid + "-" + version + "." + type);
    macTask.expectGetMode(0222, 0222);
    final DependencySet ds = new DependencySet();
    ds.setOutputDirectory("/out");
    DefaultAssemblyArchiverTest.setupInterpolators(macTask.configSource);
    mockManager.replayAll();
    final Logger logger = new ConsoleLogger(Logger.LEVEL_DEBUG, "test");
    final AddDependencySetsTask task = new AddDependencySetsTask(Collections.singletonList(ds), Collections.singleton(depMock.getArtifact()), project, macTask.projectBuilder, logger);
    task.addDependencySet(ds, macTask.archiver, macTask.configSource);
    mockManager.verifyAll();
}
Also used : MockAndControlForAddDependencySetsTask(org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddDependencySetsTask) ProjectBuildingException(org.apache.maven.project.ProjectBuildingException) 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 54 with ConsoleLogger

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

the class AddDependencySetsTaskTest method testAddDependencySet_ShouldInterpolateDefaultOutputFileNameMapping.

public void testAddDependencySet_ShouldInterpolateDefaultOutputFileNameMapping() throws AssemblyFormattingException, ArchiveCreationException, InvalidAssemblerConfigurationException, IOException {
    final String outDir = "tmp/";
    final String mainAid = "main";
    final String mainGid = "org.maingrp";
    final String mainVer = "9";
    final String depAid = "dep";
    final String depGid = "org.depgrp";
    final String depVer = "1";
    final String depExt = "war";
    final DependencySet ds = new DependencySet();
    ds.setOutputDirectory(outDir);
    ds.setDirectoryMode(Integer.toString(10, 8));
    ds.setFileMode(Integer.toString(10, 8));
    final Model mainModel = new Model();
    mainModel.setArtifactId(mainAid);
    mainModel.setGroupId(mainGid);
    mainModel.setVersion(mainVer);
    final MavenProject mainProject = new MavenProject(mainModel);
    final ArtifactMock mainArtifactMock = new ArtifactMock(mockManager, mainGid, mainAid, mainVer, "jar", false);
    mainProject.setArtifact(mainArtifactMock.getArtifact());
    final Model depModel = new Model();
    depModel.setArtifactId(depAid);
    depModel.setGroupId(depGid);
    depModel.setVersion(depVer);
    depModel.setPackaging(depExt);
    final MavenProject depProject = new MavenProject(depModel);
    final ArtifactMock depArtifactMock = new ArtifactMock(mockManager, depGid, depAid, depVer, depExt, false);
    final File newFile = depArtifactMock.setNewFile();
    depProject.setArtifact(depArtifactMock.getArtifact());
    final MockAndControlForAddDependencySetsTask macTask = new MockAndControlForAddDependencySetsTask(mockManager, mainProject);
    macTask.expectBuildFromRepository(depProject);
    macTask.expectCSGetFinalName(mainAid + "-" + mainVer);
    macTask.expectCSGetRepositories(null, null);
    macTask.expectGetDestFile(new File("junk"));
    macTask.expectAddFile(newFile, outDir + depAid + "-" + depVer + "." + depExt, 10);
    // macTask.expectGetSession( null );
    macTask.expectGetMode(0222, 0222);
    DefaultAssemblyArchiverTest.setupInterpolators(macTask.configSource);
    mockManager.replayAll();
    final Logger logger = new ConsoleLogger(Logger.LEVEL_DEBUG, "test");
    final AddDependencySetsTask task = new AddDependencySetsTask(Collections.singletonList(ds), Collections.singleton(depArtifactMock.getArtifact()), depProject, macTask.projectBuilder, logger);
    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 55 with ConsoleLogger

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

the class DefaultAssemblyReader method getLogger.

@Override
protected Logger getLogger() {
    Logger logger = super.getLogger();
    if (logger == null) {
        logger = new ConsoleLogger(Logger.LEVEL_INFO, "assemblyReader-internal");
        enableLogging(logger);
    }
    return logger;
}
Also used : ConsoleLogger(org.codehaus.plexus.logging.console.ConsoleLogger) ConsoleLogger(org.codehaus.plexus.logging.console.ConsoleLogger) Logger(org.codehaus.plexus.logging.Logger)

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