Example usage for org.apache.maven.plugin MojoExecutionException MojoExecutionException

List of usage examples for org.apache.maven.plugin MojoExecutionException MojoExecutionException

Introduction

In this page you can find the example usage for org.apache.maven.plugin MojoExecutionException MojoExecutionException.

Prototype

public MojoExecutionException(String message, Throwable cause) 

Source Link

Document

Construct a new MojoExecutionException exception wrapping an underlying Throwable and providing a message.

Usage

From source file:com.bhaweb.maven.plugin.artifactory.RepoAction.java

License:Apache License

public void execute() throws MojoExecutionException {
    try {/*www.ja  va2s.c o  m*/
        writeToFile(getRepoName() + getResult());
    } catch (IOException e) {
        throw new MojoExecutionException("Error writing to file: " + outputFile.getAbsolutePath(), e);
    }
}

From source file:com.bicosyes.simpleGwt.SimpleGwtDelete.java

License:Apache License

public void execute() throws MojoExecutionException {
    String activeModule = "";

    try {//w w  w  . ja v a2s  .c  o m
        for (Object module : modules) {
            activeModule = (String) module;
            if (delete || deletes != null) {
                getLog().info("Trying to delete GWT stuff like you suggest, master");
                deleteGWTstuff(outputDirectory, activeModule, deletes);
            }
        }
    } catch (Exception e) {
        throw new MojoExecutionException("Error compiling module " + activeModule, e);
    }
}

From source file:com.blackducksoftware.integration.maven.BuildInfoFileGenerator.java

License:Apache License

private void createBDIOFile(final DependencyNode rootDependencyNode) throws MojoExecutionException {
    try {/*  w ww.  ja  va  2 s.  c  om*/
        final File file = new File(target, helper.getBDIOFileName(project));
        logger.info(MSG_FILE_TO_GENERATE + file.getCanonicalPath());

        try (final OutputStream outputStream = new FileOutputStream(file)) {
            final BdioConverter bdioConverter = new BdioConverter();
            final CommonBomFormatter commonBomFormatter = new CommonBomFormatter(bdioConverter);
            commonBomFormatter.writeProject(outputStream, project.getName(), rootDependencyNode);
        }
    } catch (final IOException e) {
        throw new MojoExecutionException(EXCEPTION_MSG_FILE_NOT_CREATED, e);
    }
}

From source file:com.blackducksoftware.integration.maven.BuildInfoHubDeployment.java

License:Apache License

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    final String pluginTaskString = "BlackDuck Software " + helper.getBDIOFileName(project)
            + " file deployment";
    logger.info(pluginTaskString + " starting...");

    final HubServerConfigBuilder builder = new HubServerConfigBuilder();
    builder.setHubUrl(hubUrl);// w  w  w. ja  v a 2s . c  o m
    builder.setUsername(hubUser);
    builder.setPassword(hubPassword);
    builder.setTimeout(hubTimeout);
    builder.setProxyHost(hubProxyHost);
    builder.setProxyPort(hubProxyPort);
    builder.setIgnoredProxyHosts(hubNoProxyHosts);
    builder.setProxyUsername(hubProxyUser);
    builder.setProxyPassword(hubProxyPassword);

    final ValidationResults<GlobalFieldKey, HubServerConfig> results = builder.build();

    if (results.isSuccess()) {
        try {
            final HubServerConfig config = results.getConstructedObject();
            uploadFileToHub(config);
        } catch (final URISyntaxException e) {
            throw new MojoExecutionException("Hub URI invalid", e);
        } catch (final IllegalArgumentException | BDRestException | EncryptionException | IOException e) {
            throw new MojoExecutionException("Cannot communicate with hub server.", e);
        } catch (final ResourceDoesNotExistException e) {
            throw new MojoExecutionException("Cannot upload the file to the hub server.", e);
        }
    } else {
        logErrors(results);
    }
    logger.info(pluginTaskString + " finished...");
}

From source file:com.blackducksoftware.integration.maven.goal.BuildBOMGoal.java

License:Apache License

private void waitForHub() throws MojoFailureException, MojoExecutionException {
    if (getDeployHubBdio() && !waitedForHub) {
        try {/*  w w  w.j  a  v  a  2 s.com*/
            BUILD_TOOL_HELPER.waitForHub(getHubServicesFactory(), getHubProjectName(), getHubVersionName(),
                    getHubScanTimeout());
            waitedForHub = true;
        } catch (final IntegrationException e) {
            throw new MojoExecutionException(String.format(BOM_WAIT_ERROR, e.getMessage()), e);
        }
    }
}

From source file:com.blazebit.jbake.mojo.BuildMojo.java

License:Apache License

protected void bake() throws MojoExecutionException {
    setup();//from  ww w  . j av  a2  s .co  m

    try {
        oven.bake();
    } catch (Throwable ex) {
        destroy();
        throw new MojoExecutionException("Failure when running: ", ex);
    }
}

From source file:com.blazebit.jbake.mojo.BuildMojo.java

License:Apache License

protected void setup() throws MojoExecutionException {
    if (oven != null) {
        return;//from  w ww.java  2 s  .  c o  m
    }

    try {
        Orient.instance().startup();
        this.oven = new Oven(inputDirectory, outputDirectory, createConfiguration(), clearCache);
        oven.setupPaths();
    } catch (Throwable ex) {
        destroy();
        throw new MojoExecutionException("Failure when running: ", ex);
    }
}

From source file:com.blazebit.jbake.mojo.ServeMojo.java

License:Apache License

@Override
public void execute() throws MojoExecutionException {
    final Server server = new Server();
    SelectChannelConnector connector = new SelectChannelConnector();
    connector.setHost(listenAddress);/*from  ww  w . j a v  a2  s .c  o  m*/
    connector.setPort(port);
    server.setConnectors(new Connector[] { connector });

    ResourceHandler externalResourceHandler = new ResourceHandler();
    externalResourceHandler.setResourceBase(outputDirectory.getPath());
    externalResourceHandler.setWelcomeFiles(new String[] { "index.html" });

    HandlerCollection handlers = new HandlerCollection();
    handlers.setHandlers(new Handler[] { externalResourceHandler });
    server.setHandler(handlers);

    outputDirectory.mkdirs();

    try {
        server.start();
    } catch (Exception ex) {
        throw new MojoExecutionException("Could not start server!", ex);
    }

    try {
        super.execute();
    } finally {
        try {
            server.stop();
        } catch (Exception ex) {
            getLog().warn("Error on stopping server", ex);
        }
    }
}

From source file:com.blazebit.jbake.mojo.WatchMojo.java

License:Apache License

@Override
public void execute() throws MojoExecutionException {
    setup();//from ww  w.  j av  a 2  s.  c o m

    // Shutdown hook just to be safe
    Runtime.getRuntime().addShutdownHook(new Thread() {
        @Override
        public void run() {
            watcherService.shutdown();
        }
    });

    watcherService.addListener(inputDirectory.toPath(), new WatcherListener() {

        @Override
        public void refreshQueued() {
            // We don't really care about the queuing event
        }

        @Override
        public void refresh() {
            onChange(null);
        }

        @Override
        public void created(Path path) {
            onChange(path);
        }

        @Override
        public void deleted(Path path) {
            onChange(path);
        }

        @Override
        public void modified(Path path) {
            onChange(path);
        }
    });

    // Initial baking
    bake();

    getLog().info("Watching for changes in: " + inputDirectory.getPath());
    getLog().info("Stop with Ctrl + C");

    try {
        while (true) {
            try {
                Thread.sleep(DEFAULT_SLEEP);
                watcherService.processEvents();
                if (status != Status.OK) {
                    getLog().info("Refreshing");
                    if (status == Status.CONFIG_CHANGED) {
                        rebuild();
                    }

                    bake();
                    status = Status.OK;
                }
            } catch (InterruptedException e) {
                // Ctrl + C received
                return;
            }
        }
    } catch (Throwable ex) {
        throw new MojoExecutionException("Error while baking", ex);
    } finally {
        getLog().info("Shutting down...");
        watcherService.shutdown();
    }
}

From source file:com.blogspot.progcookbook.mojo.MyMojo.java

License:Apache License

public void execute() throws MojoExecutionException {
    File f = outputDirectory;//from w  w w  .j a v a2 s . c  om
    getLog().info("\nTo dziala :-)");
    for (String s : options)
        getLog().info("\n " + s);

    if (!f.exists()) {
        f.mkdirs();
    }

    File touch = new File(f, "touch.txt");

    FileWriter w = null;
    try {
        w = new FileWriter(touch);

        w.write("touch.txt");
    } catch (IOException e) {
        throw new MojoExecutionException("Error creating file " + touch, e);
    } finally {
        if (w != null) {
            try {
                w.close();
            } catch (IOException e) {
                // ignore
            }
        }
    }
}