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:ch.ifocusit.livingdoc.plugin.CommonMojoDefinition.java

License:Apache License

void write(AsciiDocBuilder asciiDocBuilder) throws MojoExecutionException {
    outputDirectory.mkdirs();/* w  ww  . jav a2  s .  c  o m*/
    File output = getOutput(Format.adoc);
    try {
        // write adco file
        asciiDocBuilder.writeToFile(outputDirectory.getAbsolutePath(), getFilenameWithoutExtension(),
                StandardCharsets.UTF_8);
        if (Format.html.equals(format)) {
            Asciidoctor asciidoctor = Asciidoctor.Factory.create();
            asciidoctor.requireLibrary("asciidoctor-diagram");
            // write html from .adoc
            asciidoctor.convertFile(output,
                    OptionsBuilder.options().backend("html5").safe(SafeMode.UNSAFE).asMap());
        }
    } catch (IOException e) {
        throw new MojoExecutionException(
                String.format("Unable to convert asciidoc file '%s' to html !", output.getAbsolutePath()), e);
    }
}

From source file:ch.ifocusit.livingdoc.plugin.diagram.AbstractClassDiagramBuilder.java

License:Apache License

protected ClassPath initClassPath() throws MojoExecutionException {
    final ClassPath classPath;
    try {//from w w  w  . j av  a2s  .c om
        try {
            classPath = ClassPath.from(getRuntimeClassLoader());
        } catch (DependencyResolutionRequiredException e) {
            throw new MojoExecutionException("Unable to load project runtime !", e);
        }
    } catch (IOException e) {
        throw new MojoExecutionException("Unable to initialize classPath !", e);
    }
    return classPath;
}

From source file:ch.ifocusit.livingdoc.plugin.diagram.PlantumlClassDiagramBuilder.java

License:Apache License

public void mapNames(File mappings, Class<? extends Annotation> annotation, String linkTemplate)
        throws MojoExecutionException {
    try {/*from   w  w  w .  ja va  2s  . c  o  m*/
        namesMapper = new GlossaryNamesMapper(mappings, annotation, linkTemplate);
    } catch (IOException e) {
        throw new MojoExecutionException("error reading mappings file", e);
    }
}

From source file:ch.ifocusit.livingdoc.plugin.PublishMojo.java

License:Apache License

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    extractTemplatesFromJar();//from   w  w w .j  av a  2  s. c  o m
    try {
        PublishProvider provider;
        switch (publish.getProvider()) {
        default:
            provider = new ConfluenceProvider(publish.getEndpoint(), publish.getUsername(),
                    publish.getPassword());
        }

        List<Page> pages = readHtmlPages();
        publish(provider, pages);
    } catch (Exception e) {
        throw new MojoExecutionException("Unexpected error", e);
    }
}

From source file:ch.ifocusit.livingdoc.plugin.utils.ClassLoaderUtil.java

License:Apache License

public static ClassLoader getRuntimeClassLoader(MavenProject project) throws MojoExecutionException {
    try {/*from  ww w .j a  v  a 2 s .  c o  m*/
        List<String> runtimeClasspathElements = project.getRuntimeClasspathElements();
        List<String> compileClasspathElements = project.getCompileClasspathElements();
        URL[] runtimeUrls = new URL[runtimeClasspathElements.size() + compileClasspathElements.size()];
        for (int i = 0; i < runtimeClasspathElements.size(); i++) {
            String element = runtimeClasspathElements.get(i);
            runtimeUrls[i] = new File(element).toURI().toURL();
        }

        int j = runtimeClasspathElements.size();

        for (int i = 0; i < compileClasspathElements.size(); i++) {
            String element = compileClasspathElements.get(i);
            runtimeUrls[i + j] = new File(element).toURI().toURL();
        }

        return new URLClassLoader(runtimeUrls, Thread.currentThread().getContextClassLoader());

    } catch (Exception e) {
        throw new MojoExecutionException("Unable to load project runtime !", e);
    }
}

From source file:ch.ivyteam.ivy.maven.AbstractProjectCompileMojo.java

License:Apache License

@Override
public final void execute() throws MojoExecutionException, MojoFailureException {
    Slf4jSimpleEngineProperties.install();
    try {//from   w w w  . ja va 2  s.  c  om
        compile(getMavenProjectBuilder());
    } catch (Exception ex) {
        throw new MojoExecutionException("Failed to compile project '" + project.getBasedir() + "'.", ex);
    } finally {
        Slf4jSimpleEngineProperties.reset();
    }
}

From source file:ch.ivyteam.ivy.maven.engine.deploy.FileLogForwarder.java

License:Apache License

public synchronized void activate() throws MojoExecutionException {
    IOFileFilter logFilter = FileFilterUtils.and(FileFilterUtils.fileFileFilter(),
            FileFilterUtils.nameFileFilter(engineLog.getName()));
    FileAlterationObserver fileObserver = new FileAlterationObserver(engineLog.getParent(), logFilter);
    fileObserver.addListener(new LogModificationListener());
    monitor = new FileAlterationMonitor(100);
    monitor.addObserver(fileObserver);/*from   ww w .j a  v a 2  s  . c  o m*/
    try {
        monitor.start();
    } catch (Exception ex) {
        throw new MojoExecutionException("Failed to activate deploy log forwarder", ex);
    }
}

From source file:ch.ivyteam.ivy.maven.engine.deploy.FileLogForwarder.java

License:Apache License

public synchronized void deactivate() throws MojoExecutionException {
    try {/*from  w  ww  . ja v a  2 s  .co  m*/
        if (monitor != null) {
            monitor.stop(0);
        }
    } catch (Exception ex) {
        throw new MojoExecutionException("Failed to deactivate deploy log forwarder", ex);
    } finally {
        monitor = null;
    }
}

From source file:ch.ivyteam.ivy.maven.engine.deploy.MarkerFileDeployer.java

License:Apache License

private void initDeployment() throws MojoExecutionException {
    try {//from ww w. ja v a  2s  .  c  o m
        log.info("Deploying project " + markerFile.getDeployCandidate().getName());
        markerFile.doDeploy().createNewFile();
    } catch (IOException ex) {
        throw new MojoExecutionException("Failed to initialize engine deployment, could not create marker", ex);
    }
}

From source file:ch.ivyteam.ivy.maven.engine.deploy.MarkerFileDeployer.java

License:Apache License

private void determineDeployResult() throws MojoExecutionException {
    FileLogForwarder logForwarder = new FileLogForwarder(markerFile.log(), log, new EngineLogLineHandler(log));
    try {/*from   w  w  w  .ja  v  a2  s  .  com*/
        logForwarder.activate();
        wait(() -> !markerFile.doDeploy().exists(), timeoutInSeconds, TimeUnit.SECONDS);
    } catch (TimeoutException ex) {
        throw new MojoExecutionException("Deployment result does not exist", ex);
    } finally {
        logForwarder.deactivate();
    }

    failOnError();
    log.info("Deployment finished");
}