Package org.sonatype.maven.shell.maven

Examples of org.sonatype.maven.shell.maven.MavenRuntime


            config.setLogFile(logFile);
        }

        customize(config);

        MavenRuntime runtime = maven.create(config);
        MavenExecutionRequest request = runtime.create();

        if (offline != null) {
            request.setOffline(offline);
        }
        if (goals != null) {
            request.setGoals(goals);
        }
        if (batch != null) {
            request.setInteractiveMode(!batch);
        }
        if (resumeFrom != null) {
            request.setResumeFrom(resumeFrom);
        }
        if (toolChainsFile != null) {
            request.setUserToolchainsFile(toolChainsFile);
        }
        if (showErrors != null) {
            request.setShowErrors(showErrors);
        }
        if (nonRecursive != null) {
            request.setRecursive(!nonRecursive);
        }
        if (updateSnapshots != null) {
            request.setUpdateSnapshots(updateSnapshots);
        }
        if (noSnapshotUpdates != null) {
            request.setNoSnapshotUpdates(noSnapshotUpdates);
        }
        if (selectedProjects != null) {
            request.setSelectedProjects(selectedProjects);
        }

        if (strictChecksums) {
            request.setGlobalChecksumPolicy(CHECKSUM_POLICY_FAIL);
        }
        if (laxChecksums) {
            request.setGlobalChecksumPolicy(CHECKSUM_POLICY_WARN);
        }

        if (failFast) {
            request.setReactorFailureBehavior(REACTOR_FAIL_FAST);
        }
        else if (failAtEnd) {
            request.setReactorFailureBehavior(REACTOR_FAIL_AT_END);
        }
        else if (failNever) {
            request.setReactorFailureBehavior(REACTOR_FAIL_NEVER);
        }

        if (alsoMake && !alsoMakeDependents) {
            request.setMakeBehavior(REACTOR_MAKE_UPSTREAM);
        }
        else if (!alsoMake && alsoMakeDependents) {
            request.setMakeBehavior(REACTOR_MAKE_DOWNSTREAM);
        }
        else if (alsoMake && alsoMakeDependents) {
            request.setMakeBehavior(REACTOR_MAKE_BOTH);
        }

        // Customize the plugin groups
        request.addPluginGroup("org.apache.maven.plugins");
        request.addPluginGroup("org.codehaus.mojo");
        request.addPluginGroup("com.sonatype.maven.plugins");
        request.addPluginGroup("org.sonatype.maven.plugins");

        // Setup output colorization
        StreamSet current = StreamJack.current();
        StreamSet streams;
        if (color == null || color) {
            // Complain if the user asked for color and its not supported
            if (color != null && !io.getTerminal().isAnsiSupported()) {
                log.warn("ANSI color is not supported by the current terminal");
            }
            streams = new StreamSet(current.in, new ColorizingStream(current.out), new ColorizingStream(current.err));
        }
        else {
            streams = current;
        }
        config.setStreams(streams);

        StreamJack.register(streams);

        // Execute Maven
        int result = 0;
        try {
            result = runtime.execute(request);
        }
        finally {
            StreamJack.deregister();
            // HACK: Not sure why, but we need to reset the terminal after some mvn builds
            io.getTerminal().reset();
View Full Code Here

TOP

Related Classes of org.sonatype.maven.shell.maven.MavenRuntime

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.