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);
}
}
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);
}
}
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);
}
}
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);
}
}
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);
}
}
Aggregations