use of org.apache.maven.plugin.MojoFailureException in project maven-plugins by apache.
the class AbstractCheckDocumentationMojo method execute.
public void execute() throws MojoExecutionException, MojoFailureException {
setupProxy();
if (output != null) {
getLog().info("Writing documentation check results to: " + output);
}
Map<MavenProject, DocumentationReporter> reporters = new LinkedHashMap<MavenProject, DocumentationReporter>();
boolean hasErrors = false;
for (MavenProject project : reactorProjects) {
if (approveProjectPackaging(project.getPackaging())) {
getLog().info("Checking project: " + project.getName());
DocumentationReporter reporter = new DocumentationReporter();
checkProject(project, reporter);
if (!hasErrors && reporter.hasErrors()) {
hasErrors = true;
}
reporters.put(project, reporter);
} else {
getLog().info("Skipping unsupported project: " + project.getName());
}
}
String messages;
messages = buildErrorMessages(reporters);
if (!hasErrors) {
messages += "No documentation errors were found.";
}
try {
writeMessages(messages, hasErrors);
} catch (IOException e) {
throw new MojoExecutionException("Error writing results to output file: " + output);
}
if (hasErrors) {
String logLocation;
if (output == null) {
logLocation = "Please see the console output above for more information.";
} else {
logLocation = "Please see \'" + output + "\' for more information.";
}
throw new MojoFailureException("Documentation problems were found. " + logLocation);
}
}
use of org.apache.maven.plugin.MojoFailureException in project maven-plugins by apache.
the class AbstractEarModule method resolveArtifact.
/** {@inheritDoc} */
public void resolveArtifact(Set<Artifact> artifacts) throws EarPluginException, MojoFailureException {
// If the artifact is already set no need to resolve it
if (artifact == null) {
// Make sure that at least the groupId and the artifactId are specified
if (groupId == null || artifactId == null) {
throw new MojoFailureException("Could not resolve artifact[" + groupId + ":" + artifactId + ":" + getType() + "]");
}
final ArtifactRepository ar = earExecutionContext.getArtifactRepository();
artifact = ar.getUniqueArtifact(groupId, artifactId, getType(), classifier);
// Artifact has not been found
if (artifact == null) {
Set<Artifact> candidates = ar.getArtifacts(groupId, artifactId, getType());
if (candidates.size() > 1) {
throw new MojoFailureException("Artifact[" + this + "] has " + candidates.size() + " candidates, please provide a classifier.");
} else {
throw new MojoFailureException("Artifact[" + this + "] is not a dependency of the project.");
}
}
}
}
use of org.apache.maven.plugin.MojoFailureException in project maven-plugins by apache.
the class ApplyMojo method findPatchesToApply.
private Map findPatchesToApply(List foundPatchFiles, File patchSourceDir) throws MojoFailureException {
Map patchesApplied = new LinkedHashMap();
if (naturalOrderProcessing) {
patches = new ArrayList(foundPatchFiles);
Collections.sort(patches);
}
String alreadyAppliedPatches = "";
try {
if (optimizations && patchTrackingFile.exists()) {
alreadyAppliedPatches = FileUtils.fileRead(patchTrackingFile);
}
} catch (IOException ioe) {
throw new MojoFailureException("unable to read patch tracking file: " + ioe.getMessage());
}
for (Object patche : patches) {
String patch = (String) patche;
if (!alreadyAppliedPatches.contains(patch)) {
File patchFile = new File(patchSourceDir, patch);
getLog().debug("Looking for patch: " + patch + " in: " + patchFile);
if (!patchFile.exists()) {
if (strictPatching) {
throw new MojoFailureException(this, "Patch operation cannot proceed.", "Cannot find specified patch: \'" + patch + "\' in patch-source directory: \'" + patchSourceDir + "\'.\n\nEither fix this error, " + "or relax strictPatching.");
} else {
getLog().info("Skipping patch: " + patch + " listed in the parameter \"patches\"; " + "it is missing.");
}
} else {
foundPatchFiles.remove(patch);
patchesApplied.put(patch, createPatchCommand(patchFile));
}
}
}
return patchesApplied;
}
use of org.apache.maven.plugin.MojoFailureException in project maven-plugins by apache.
the class JModCreateMojo method execute.
public void execute() throws MojoExecutionException, MojoFailureException {
failIfParametersAreNotInTheirValidValueRanges();
String jModExecutable;
try {
jModExecutable = getJModExecutable();
} catch (IOException e) {
throw new MojoFailureException("Unable to find jmod command: " + e.getMessage(), e);
}
getLog().info("Toolchain in maven-jmod-plugin: jmod [ " + jModExecutable + " ]");
// We need to put the resulting x.jmod files into jmods folder.
// Check why?
File modsFolder = new File(outputDirectory, "jmods");
File resultingJModFile = new File(modsFolder, moduleName + ".jmod");
deleteOutputIfAlreadyExists(resultingJModFile);
// create the jmods folder...
modsFolder.mkdirs();
Commandline cmd = createJModCreateCommandLine(resultingJModFile);
cmd.setExecutable(jModExecutable);
executeCommand(cmd, outputDirectory);
}
use of org.apache.maven.plugin.MojoFailureException in project maven-plugins by apache.
the class JModHashMojo method execute.
public void execute() throws MojoExecutionException, MojoFailureException {
String jModExecutable;
try {
jModExecutable = getJModExecutable();
} catch (IOException e) {
throw new MojoFailureException("Unable to find jmod command: " + e.getMessage(), e);
}
Commandline cmd = createJModHashCommandLine();
cmd.setExecutable(jModExecutable);
// executeCommand( cmd, outputDirectory );
}
Aggregations