use of org.codehaus.plexus.util.xml.pull.XmlPullParserException in project maven-plugins by apache.
the class ComponentsXmlArchiverFileFilter method isSelected.
@Override
public boolean isSelected(@Nonnull final FileInfo fileInfo) throws IOException {
if (fileInfo.isFile()) {
if (excludeOverride) {
return true;
}
String entry = fileInfo.getName().replace('\\', '/');
if (entry.startsWith("/")) {
entry = entry.substring(1);
}
if (ComponentsXmlArchiverFileFilter.COMPONENTS_XML_PATH.equals(entry)) {
Reader reader = null;
try {
reader = new BufferedReader(ReaderFactory.newXmlReader(fileInfo.getContents()));
addComponentsXml(reader);
reader.close();
reader = null;
} catch (final XmlPullParserException e) {
final IOException error = new IOException("Error finalizing component-set for archive. Reason: " + e.getMessage());
error.initCause(e);
throw error;
} finally {
IOUtil.close(reader);
}
return false;
} else {
return true;
}
} else {
return true;
}
}
use of org.codehaus.plexus.util.xml.pull.XmlPullParserException in project maven-plugins by apache.
the class SignAndDeployFileMojo method readModel.
/**
* Extract the model from the specified POM file.
*
* @param pomFile The path of the POM file to parse, must not be <code>null</code>.
* @return The model from the POM file, never <code>null</code>.
* @throws MojoExecutionException If the file doesn't exist of cannot be read.
*/
private Model readModel(File pomFile) throws MojoExecutionException {
Reader reader = null;
try {
reader = ReaderFactory.newXmlReader(pomFile);
final Model model = new MavenXpp3Reader().read(reader);
reader.close();
reader = null;
return model;
} catch (FileNotFoundException e) {
throw new MojoExecutionException("POM not found " + pomFile, e);
} catch (IOException e) {
throw new MojoExecutionException("Error reading POM " + pomFile, e);
} catch (XmlPullParserException e) {
throw new MojoExecutionException("Error parsing POM " + pomFile, e);
} finally {
IOUtil.close(reader);
}
}
use of org.codehaus.plexus.util.xml.pull.XmlPullParserException in project maven-plugins by apache.
the class InstallFileMojo method readModel.
/**
* Parses a POM.
*
* @param pomFile The path of the POM file to parse, must not be <code>null</code>.
* @return The model from the POM file, never <code>null</code>.
* @throws MojoExecutionException If the POM could not be parsed.
*/
private Model readModel(File pomFile) throws MojoExecutionException {
Reader reader = null;
try {
reader = ReaderFactory.newXmlReader(pomFile);
final Model model = new MavenXpp3Reader().read(reader);
reader.close();
reader = null;
return model;
} catch (FileNotFoundException e) {
throw new MojoExecutionException("File not found " + pomFile, e);
} catch (IOException e) {
throw new MojoExecutionException("Error reading POM " + pomFile, e);
} catch (XmlPullParserException e) {
throw new MojoExecutionException("Error parsing POM " + pomFile, e);
} finally {
IOUtil.close(reader);
}
}
use of org.codehaus.plexus.util.xml.pull.XmlPullParserException in project maven-plugins by apache.
the class ResourceResolver method resolveBundleFromProject.
private static List<JavadocBundle> resolveBundleFromProject(SourceResolverConfig config, MavenProject project, Artifact artifact) throws IOException {
List<JavadocBundle> bundles = new ArrayList<>();
List<String> classifiers = new ArrayList<>();
if (config.includeCompileSources()) {
classifiers.add(AbstractJavadocMojo.JAVADOC_RESOURCES_ATTACHMENT_CLASSIFIER);
}
if (config.includeTestSources()) {
classifiers.add(AbstractJavadocMojo.TEST_JAVADOC_RESOURCES_ATTACHMENT_CLASSIFIER);
}
for (String classifier : classifiers) {
File optionsFile = new File(project.getBuild().getDirectory(), "javadoc-bundle-options/javadoc-options-" + classifier + ".xml");
if (!optionsFile.exists()) {
continue;
}
FileInputStream stream = null;
try {
stream = new FileInputStream(optionsFile);
JavadocOptions options = new JavadocOptionsXpp3Reader().read(stream);
stream.close();
stream = null;
bundles.add(new JavadocBundle(options, new File(project.getBasedir(), options.getJavadocResourcesDirectory())));
} catch (XmlPullParserException e) {
IOException error = new IOException("Failed to read javadoc options from: " + optionsFile + "\nReason: " + e.getMessage());
error.initCause(e);
throw error;
} finally {
close(stream);
}
}
return bundles;
}
use of org.codehaus.plexus.util.xml.pull.XmlPullParserException in project maven-plugins by apache.
the class AbstractPmdViolationCheckMojo method executeCheck.
protected void executeCheck(final String filename, final String tagName, final String key, final int failurePriority) throws MojoFailureException, MojoExecutionException {
if (aggregate && !project.isExecutionRoot()) {
return;
}
if ("pom".equals(project.getPackaging()) && !aggregate) {
return;
}
excludeFromFile.loadExcludeFromFailuresData(excludeFromFailureFile);
final File outputFile = new File(targetDirectory, filename);
if (outputFile.exists()) {
try {
final ViolationDetails<D> violations = getViolations(outputFile, failurePriority);
final List<D> failures = violations.getFailureDetails();
final List<D> warnings = violations.getWarningDetails();
if (verbose) {
printErrors(failures, warnings);
}
final int failureCount = failures.size();
final int warningCount = warnings.size();
final String message = getMessage(failureCount, warningCount, key, outputFile);
getLog().debug("PMD failureCount: " + failureCount + ", warningCount: " + warningCount);
if (failureCount > 0 && isFailOnViolation()) {
throw new MojoFailureException(message);
}
this.getLog().info(message);
} catch (final IOException e) {
throw new MojoExecutionException("Unable to read PMD results xml: " + outputFile.getAbsolutePath(), e);
} catch (final XmlPullParserException e) {
throw new MojoExecutionException("Unable to read PMD results xml: " + outputFile.getAbsolutePath(), e);
}
} else {
throw new MojoFailureException("Unable to perform check, " + "unable to find " + outputFile);
}
}
Aggregations