Example usage for org.apache.maven.monitor.event EventDispatcher addEventMonitor

List of usage examples for org.apache.maven.monitor.event EventDispatcher addEventMonitor

Introduction

In this page you can find the example usage for org.apache.maven.monitor.event EventDispatcher addEventMonitor.

Prototype

void addEventMonitor(EventMonitor monitor);

Source Link

Usage

From source file:org.nuxeo.build.maven.MavenEmbedder.java

License:Open Source License

public void execute(List<MavenProject> projects, List<?> goals, EventMonitor eventMonitor,
        TransferListener transferListener, Properties properties, File executionRootDirectory)
        throws CycleDetectedException, LifecycleExecutionException, BuildFailureException,
        DuplicateProjectException, MissingProjectException {
    ReactorManager rm = new ReactorManager(projects);

    EventDispatcher eventDispatcher = new DefaultEventDispatcher();

    eventDispatcher.addEventMonitor(eventMonitor);

    // If this option is set the exception seems to be hidden ...

    // rm.setFailureBehavior( ReactorManager.FAIL_AT_END );

    rm.setFailureBehavior(ReactorManager.FAIL_FAST);

    MavenSession session = new MavenSession(embedder.getContainer(), settings, localRepository, eventDispatcher,
            rm, goals, executionRootDirectory.getAbsolutePath(), properties, new Date());

    session.setUsingPOMsFromFilesystem(true);

    if (transferListener != null) {
        wagonManager.setDownloadMonitor(transferListener);
    }//from   www  .j a v a  2s .  com

    // ----------------------------------------------------------------------
    // Maven should not be using system properties internally but because
    // it does for now I'll just take properties that are handed to me
    // and set them so that the plugin expression evaluator will work
    // as expected.
    // ----------------------------------------------------------------------

    if (properties != null) {
        for (Iterator<?> i = properties.keySet().iterator(); i.hasNext();) {
            String key = (String) i.next();

            String value = properties.getProperty(key);

            System.setProperty(key, value);
        }
    }

    lifecycleExecutor.execute(session, rm, session.getEventDispatcher());
}