Search in sources :

Example 46 with MojoExecutionException

use of org.apache.maven.plugin.MojoExecutionException in project camel by apache.

the class PrepareReadmeMojo method templateOthers.

private String templateOthers(List<OtherModel> models, int artifacts, long deprecated) throws MojoExecutionException {
    try {
        String template = loadText(UpdateReadmeMojo.class.getClassLoader().getResourceAsStream("readme-others.mvel"));
        Map<String, Object> map = new HashMap<>();
        map.put("others", models);
        map.put("numberOfArtifacts", artifacts);
        map.put("numberOfDeprecated", deprecated);
        String out = (String) TemplateRuntime.eval(template, map);
        return out;
    } catch (Exception e) {
        throw new MojoExecutionException("Error processing mvel template. Reason: " + e, e);
    }
}
Also used : MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) HashMap(java.util.HashMap) IOException(java.io.IOException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) MojoFailureException(org.apache.maven.plugin.MojoFailureException)

Example 47 with MojoExecutionException

use of org.apache.maven.plugin.MojoExecutionException in project camel by apache.

the class PrepareReadmeMojo method templateLanguages.

private String templateLanguages(List<LanguageModel> models, int artifacts, long deprecated) throws MojoExecutionException {
    try {
        String template = loadText(UpdateReadmeMojo.class.getClassLoader().getResourceAsStream("readme-languages.mvel"));
        Map<String, Object> map = new HashMap<>();
        map.put("languages", models);
        map.put("numberOfArtifacts", artifacts);
        map.put("numberOfDeprecated", deprecated);
        String out = (String) TemplateRuntime.eval(template, map);
        return out;
    } catch (Exception e) {
        throw new MojoExecutionException("Error processing mvel template. Reason: " + e, e);
    }
}
Also used : MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) HashMap(java.util.HashMap) IOException(java.io.IOException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) MojoFailureException(org.apache.maven.plugin.MojoFailureException)

Example 48 with MojoExecutionException

use of org.apache.maven.plugin.MojoExecutionException in project camel by apache.

the class PrepareUserGuideMojo method updateComponents.

private boolean updateComponents(File file, String changed) throws MojoExecutionException {
    if (!file.exists()) {
        return false;
    }
    try {
        String text = loadText(new FileInputStream(file));
        String existing = StringHelper.between(text, "<!-- components: START -->", "<!-- components: END -->");
        if (existing != null) {
            // remove leading line breaks etc
            existing = existing.trim();
            changed = changed.trim();
            if (existing.equals(changed)) {
                return false;
            } else {
                String before = StringHelper.before(text, "<!-- components: START -->");
                String after = StringHelper.after(text, "<!-- components: END -->");
                text = before + "<!-- components: START -->\n" + changed + "\n<!-- components: END -->" + after;
                writeText(file, text);
                return true;
            }
        } else {
            getLog().warn("Cannot find markers in file " + file);
            getLog().warn("Add the following markers");
            getLog().warn("\t<!-- components: START -->");
            getLog().warn("\t<!-- components: END -->");
            return false;
        }
    } catch (Exception e) {
        throw new MojoExecutionException("Error reading file " + file + " Reason: " + e, e);
    }
}
Also used : MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) FileInputStream(java.io.FileInputStream) IOException(java.io.IOException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) MojoFailureException(org.apache.maven.plugin.MojoFailureException)

Example 49 with MojoExecutionException

use of org.apache.maven.plugin.MojoExecutionException in project camel by apache.

the class PrepareUserGuideMojo method updateLanguages.

private boolean updateLanguages(File file, String changed) throws MojoExecutionException {
    if (!file.exists()) {
        return false;
    }
    try {
        String text = loadText(new FileInputStream(file));
        String existing = StringHelper.between(text, "<!-- languages: START -->", "<!-- languages: END -->");
        if (existing != null) {
            // remove leading line breaks etc
            existing = existing.trim();
            changed = changed.trim();
            if (existing.equals(changed)) {
                return false;
            } else {
                String before = StringHelper.before(text, "<!-- languages: START -->");
                String after = StringHelper.after(text, "<!-- languages: END -->");
                text = before + "<!-- languages: START -->\n" + changed + "\n<!-- languages: END -->" + after;
                writeText(file, text);
                return true;
            }
        } else {
            getLog().warn("Cannot find markers in file " + file);
            getLog().warn("Add the following markers");
            getLog().warn("\t<!-- languages: START -->");
            getLog().warn("\t<!-- languages: END -->");
            return false;
        }
    } catch (Exception e) {
        throw new MojoExecutionException("Error reading file " + file + " Reason: " + e, e);
    }
}
Also used : MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) FileInputStream(java.io.FileInputStream) IOException(java.io.IOException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) MojoFailureException(org.apache.maven.plugin.MojoFailureException)

Example 50 with MojoExecutionException

use of org.apache.maven.plugin.MojoExecutionException in project camel by apache.

the class EipDocumentationEnricherMojo method execute.

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    if (pathToModelDir == null) {
        throw new MojoExecutionException("pathToModelDir parameter must not be null");
    }
    validateExists(inputCamelSchemaFile, "inputCamelSchemaFile");
    validateIsFile(inputCamelSchemaFile, "inputCamelSchemaFile");
    validateExists(camelCoreDir, "camelCoreDir");
    validateExists(camelCoreXmlDir, "camelCoreXmlDir");
    validateExists(camelSpringDir, "camelSpringDir");
    validateIsDirectory(camelCoreDir, "camelCoreDir");
    validateIsDirectory(camelCoreXmlDir, "camelCoreXmlDir");
    validateIsDirectory(camelSpringDir, "camelSpringDir");
    try {
        runPlugin();
    } catch (Exception e) {
        throw new MojoExecutionException("Error during plugin execution", e);
    }
}
Also used : MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) XPathExpressionException(javax.xml.xpath.XPathExpressionException) TransformerException(javax.xml.transform.TransformerException) IOException(java.io.IOException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) FileNotFoundException(java.io.FileNotFoundException) MojoFailureException(org.apache.maven.plugin.MojoFailureException)

Aggregations

MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)586 IOException (java.io.IOException)322 File (java.io.File)261 MojoFailureException (org.apache.maven.plugin.MojoFailureException)138 Artifact (org.apache.maven.artifact.Artifact)86 ArrayList (java.util.ArrayList)70 FileInputStream (java.io.FileInputStream)56 HashMap (java.util.HashMap)47 MavenProject (org.apache.maven.project.MavenProject)37 MalformedURLException (java.net.MalformedURLException)34 Map (java.util.Map)34 ArchiverException (org.codehaus.plexus.archiver.ArchiverException)32 Properties (java.util.Properties)30 FileOutputStream (java.io.FileOutputStream)28 FileWriter (java.io.FileWriter)28 List (java.util.List)25 URL (java.net.URL)22 InputStream (java.io.InputStream)21 LinkedHashSet (java.util.LinkedHashSet)21 FileNotFoundException (java.io.FileNotFoundException)20