Search in sources :

Example 16 with ConsoleLogger

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

the class FilterUtilsTest method verifyProjectFiltering.

private void verifyProjectFiltering(final String groupId, final String artifactId, final String inclusionPattern, final String exclusionPattern, final List<String> depTrail, final boolean verifyInclusion) {
    final ProjectWithArtifactMockControl pmac = new ProjectWithArtifactMockControl(groupId, artifactId, depTrail);
    mockManager.replayAll();
    // make sure the mock is satisfied...you can't disable this expectation.
    pmac.mac.artifact.getDependencyConflictId();
    final Set<MavenProject> projects = new HashSet<MavenProject>();
    projects.add(pmac);
    List<String> inclusions;
    if (inclusionPattern != null) {
        inclusions = Collections.singletonList(inclusionPattern);
    } else {
        inclusions = Collections.emptyList();
    }
    List<String> exclusions;
    if (exclusionPattern != null) {
        exclusions = Collections.singletonList(exclusionPattern);
    } else {
        exclusions = Collections.emptyList();
    }
    final Logger logger = new ConsoleLogger(Logger.LEVEL_DEBUG, "test");
    Set<MavenProject> result = FilterUtils.filterProjects(projects, inclusions, exclusions, depTrail != null, logger);
    if (verifyInclusion) {
        assertEquals(1, result.size());
        assertEquals(pmac.getId(), result.iterator().next().getId());
    } else {
        assertTrue(result.isEmpty());
    }
    mockManager.verifyAll();
    // get ready for multiple calls per test.
    mockManager.resetAll();
}
Also used : MavenProject(org.apache.maven.project.MavenProject) ConsoleLogger(org.codehaus.plexus.logging.console.ConsoleLogger) ConsoleLogger(org.codehaus.plexus.logging.console.ConsoleLogger) Logger(org.codehaus.plexus.logging.Logger) HashSet(java.util.HashSet)

Example 17 with ConsoleLogger

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

the class AddArtifactTaskTest method testShouldAddArchiveFileWithUnpackAndModes.

public void testShouldAddArchiveFileWithUnpackAndModes() throws ArchiveCreationException, AssemblyFormattingException, IOException {
    int directoryMode = TypeConversionUtils.modeToInt("777", new ConsoleLogger(Logger.LEVEL_DEBUG, "test"));
    int fileMode = TypeConversionUtils.modeToInt("777", new ConsoleLogger(Logger.LEVEL_DEBUG, "test"));
    mac.expectModeChange(-1, -1, directoryMode, fileMode, 2);
    mac.expectInterpolators();
    ArtifactMock artifactMock = new ArtifactMock(mockManager, "group", "artifact", "version", "jar", false);
    artifactMock.setNewFile();
    mac.expectGetDestFile(new File("junk"));
    try {
        mac.archiver.addArchivedFileSet((ArchivedFileSet) anyObject(), (Charset) anyObject());
    } catch (ArchiverException e) {
        fail("Should never happen.");
    }
    mockManager.replayAll();
    AddArtifactTask task = createTask(artifactMock.getArtifact());
    task.setUnpack(true);
    task.setDirectoryMode(directoryMode);
    task.setFileMode(fileMode);
    task.execute(mac.archiver, mac.configSource);
    mockManager.verifyAll();
}
Also used : ArchiverException(org.codehaus.plexus.archiver.ArchiverException) ConsoleLogger(org.codehaus.plexus.logging.console.ConsoleLogger) MockAndControlForAddArtifactTask(org.apache.maven.plugins.assembly.archive.task.testutils.MockAndControlForAddArtifactTask) ArtifactMock(org.apache.maven.plugins.assembly.archive.task.testutils.ArtifactMock) File(java.io.File)

Example 18 with ConsoleLogger

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

the class AnnouncementMailMojo method execute.

public void execute() throws MojoExecutionException {
    // Fail build fast if it is using deprecated parameters
    if (templateOutputDirectory != null) {
        throw new MojoExecutionException("You are using the old parameter 'templateOutputDirectory'. " + "You must use 'announcementDirectory' instead.");
    }
    // Run only at the execution root
    if (runOnlyAtExecutionRoot && !isThisTheExecutionRoot()) {
        getLog().info("Skipping the announcement mail in this project because it's not the Execution Root");
    } else {
        File file = new File(announcementDirectory, announcementFile);
        ConsoleLogger logger = new ConsoleLogger(Logger.LEVEL_INFO, "base");
        if (getLog().isDebugEnabled()) {
            logger.setThreshold(Logger.LEVEL_DEBUG);
        }
        mailer.enableLogging(logger);
        mailer.setSmtpHost(getSmtpHost());
        mailer.setSmtpPort(getSmtpPort());
        mailer.setSslMode(sslMode, startTls);
        if (username != null) {
            mailer.setUsername(username);
        }
        if (password != null) {
            mailer.setPassword(password);
        }
        mailer.initialize();
        if (getLog().isDebugEnabled()) {
            getLog().debug("fromDeveloperId: " + getFromDeveloperId());
        }
        if (file.isFile()) {
            getLog().info("Connecting to Host: " + getSmtpHost() + ":" + getSmtpPort());
            sendMessage();
        } else {
            throw new MojoExecutionException("Announcement file " + file + " not found...");
        }
    }
}
Also used : MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) ConsoleLogger(org.codehaus.plexus.logging.console.ConsoleLogger) File(java.io.File)

Example 19 with ConsoleLogger

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

the class ProjectUtilsTest method testGetProjectModules_ShouldIncludeDirectModuleOfMasterProject.

public void testGetProjectModules_ShouldIncludeDirectModuleOfMasterProject() throws IOException {
    final MavenProject master = createTestProject("test", "testGroup", "1.0");
    master.setFile(new File("pom.xml"));
    master.getModel().addModule("module");
    final MavenProject module = createTestProject("module", "testGroup", "1.0");
    module.setFile(new File("module/pom.xml"));
    final List<MavenProject> projects = new ArrayList<MavenProject>(2);
    projects.add(master);
    projects.add(module);
    final Set<MavenProject> result = ProjectUtils.getProjectModules(master, projects, true, new ConsoleLogger(Logger.LEVEL_INFO, "test"));
    assertNotNull(result);
    assertEquals(1, result.size());
    assertEquals(module.getId(), result.iterator().next().getId());
}
Also used : MavenProject(org.apache.maven.project.MavenProject) ConsoleLogger(org.codehaus.plexus.logging.console.ConsoleLogger) ArrayList(java.util.ArrayList) File(java.io.File)

Example 20 with ConsoleLogger

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

the class ProjectUtilsTest method testGetProjectModules_ShouldIncludeInDirectModuleOfMasterWhenIncludeSubModulesIsTrue.

public void testGetProjectModules_ShouldIncludeInDirectModuleOfMasterWhenIncludeSubModulesIsTrue() throws IOException {
    final MavenProject master = createTestProject("test", "testGroup", "1.0");
    master.setFile(new File("project/pom.xml"));
    master.getModel().addModule("module");
    final MavenProject module = createTestProject("module", "testGroup", "1.0");
    module.getModel().addModule("submodule");
    module.setFile(new File("project/module/pom.xml"));
    final MavenProject subModule = createTestProject("sub-module", "testGroup", "1.0");
    subModule.setFile(new File("project/module/submodule/pom.xml"));
    final List<MavenProject> projects = new ArrayList<MavenProject>(3);
    projects.add(master);
    projects.add(module);
    projects.add(subModule);
    final Set<MavenProject> result = ProjectUtils.getProjectModules(master, projects, true, new ConsoleLogger(Logger.LEVEL_INFO, "test"));
    assertNotNull(result);
    assertEquals(2, result.size());
    final List<MavenProject> verify = new ArrayList<MavenProject>(projects);
    verify.remove(master);
    verifyProjectsPresent(verify, result);
}
Also used : MavenProject(org.apache.maven.project.MavenProject) ConsoleLogger(org.codehaus.plexus.logging.console.ConsoleLogger) ArrayList(java.util.ArrayList) File(java.io.File)

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