use of org.apache.maven.plugin.MojoExecutionException in project camel by apache.
the class PrepareUserGuideMojo method updateOthers.
private boolean updateOthers(File file, String changed) throws MojoExecutionException {
if (!file.exists()) {
return false;
}
try {
String text = loadText(new FileInputStream(file));
String existing = StringHelper.between(text, "<!-- others: START -->", "<!-- others: 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, "<!-- others: START -->");
String after = StringHelper.after(text, "<!-- others: END -->");
text = before + "<!-- others: START -->\n" + changed + "\n<!-- others: 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<!-- others: START -->");
getLog().warn("\t<!-- others: 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 updateDataFormats.
private boolean updateDataFormats(File file, String changed) throws MojoExecutionException {
if (!file.exists()) {
return false;
}
try {
String text = loadText(new FileInputStream(file));
String existing = StringHelper.between(text, "<!-- dataformats: START -->", "<!-- dataformats: 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, "<!-- dataformats: START -->");
String after = StringHelper.after(text, "<!-- dataformats: END -->");
text = before + "<!-- dataformats: START -->\n" + changed + "\n<!-- dataformats: 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<!-- dataformats: START -->");
getLog().warn("\t<!-- dataformats: 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 SpringBootStarterMojo method execute.
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
if (!isStarterAllowed()) {
getLog().info("Spring-Boot-Starter: starter not allowed for module " + project.getArtifactId() + ": skipping.");
return;
}
try {
// create the starter directory
File starterDir = starterDir();
getLog().info("Spring-Boot-Starter: starter dir for the component is: " + starterDir.getAbsolutePath());
if (!starterDir.exists()) {
starterDir.mkdirs();
}
// create the base pom.xml
Document pom = createBasePom();
// Apply changes to the starter pom
fixExcludedDependencies(pom);
fixAdditionalDependencies(pom);
fixAdditionalRepositories(pom);
// Write the starter pom
File pomFile = new File(starterDir, "pom.xml");
writeXmlFormatted(pom, pomFile);
// write LICENSE, USAGE and spring.provides files
writeStaticFiles();
writeSpringProvides();
// synchronized all starters with their parent pom 'modules' section
synchronizeParentPom();
} catch (Exception e) {
throw new MojoFailureException("Unable to create starter", e);
}
}
use of org.apache.maven.plugin.MojoExecutionException in project camel by apache.
the class UpdateReadmeMojo method updateLanguageOptions.
private boolean updateLanguageOptions(File file, String changed) throws MojoExecutionException {
if (!file.exists()) {
return false;
}
try {
String text = loadText(new FileInputStream(file));
String existing = StringHelper.between(text, "// language options: START", "// language options: 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, "// language options: START");
String after = StringHelper.after(text, "// language options: END");
text = before + "// language options: START\n" + changed + "\n// language options: 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// language options: START");
getLog().warn("\t// language options: END");
if (isFailFast()) {
throw new MojoExecutionException("Failed build due failFast=true");
}
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 UpdateReadmeMojo method updateComponentOptions.
private boolean updateComponentOptions(File file, String changed) throws MojoExecutionException {
if (!file.exists()) {
return false;
}
try {
String text = loadText(new FileInputStream(file));
String existing = StringHelper.between(text, "// component options: START", "// component options: 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, "// component options: START");
String after = StringHelper.after(text, "// component options: END");
text = before + "// component options: START\n" + changed + "\n// component options: 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// component options: START");
getLog().warn("\t// component options: END");
if (isFailFast()) {
throw new MojoExecutionException("Failed build due failFast=true");
}
return false;
}
} catch (Exception e) {
throw new MojoExecutionException("Error reading file " + file + " Reason: " + e, e);
}
}
Aggregations