use of org.eclipse.ceylon.aether.apache.maven.model.io.xpp3.MavenXpp3Reader in project morphia by mongodb.
the class MorphiaVersionTest method testVersion.
@Test
public void testVersion() throws Exception {
MavenXpp3Reader reader = new MavenXpp3Reader();
Model model = reader.read(new FileReader("../pom.xml"));
Version version = Version.valueOf(model.getVersion());
String minorVersion = format("%s%s", version.getMajorVersion(), version.getMinorVersion());
// noinspection MisorderedAssertEqualsArguments
assertEquals(MorphiaVersion23.class.getSimpleName().replaceAll("\\D", ""), minorVersion);
}
use of org.eclipse.ceylon.aether.apache.maven.model.io.xpp3.MavenXpp3Reader in project maven-plugins by apache.
the class AnalyzeDuplicateMojo method execute.
/**
* {@inheritDoc}
*/
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
if (skip) {
getLog().info("Skipping plugin execution");
return;
}
MavenXpp3Reader pomReader = new MavenXpp3Reader();
Model model = null;
Reader reader = null;
try {
reader = ReaderFactory.newXmlReader(project.getFile());
model = pomReader.read(reader);
reader.close();
reader = null;
} catch (Exception e) {
throw new MojoExecutionException("IOException: " + e.getMessage(), e);
} finally {
IOUtil.close(reader);
}
Set<String> duplicateDependencies = Collections.emptySet();
if (model.getDependencies() != null) {
duplicateDependencies = findDuplicateDependencies(model.getDependencies());
}
Set<String> duplicateDependenciesManagement = Collections.emptySet();
if (model.getDependencyManagement() != null && model.getDependencyManagement().getDependencies() != null) {
duplicateDependenciesManagement = findDuplicateDependencies(model.getDependencyManagement().getDependencies());
}
if (getLog().isInfoEnabled()) {
StringBuilder sb = new StringBuilder();
if (!duplicateDependencies.isEmpty()) {
sb.append("List of duplicate dependencies defined in <dependencies/> in your pom.xml:\n");
for (Iterator<String> it = duplicateDependencies.iterator(); it.hasNext(); ) {
String dup = it.next();
sb.append("\to ").append(dup);
if (it.hasNext()) {
sb.append("\n");
}
}
}
if (!duplicateDependenciesManagement.isEmpty()) {
if (sb.length() > 0) {
sb.append("\n");
}
sb.append("List of duplicate dependencies defined in <dependencyManagement/> in your pom.xml:\n");
for (Iterator<String> it = duplicateDependenciesManagement.iterator(); it.hasNext(); ) {
String dup = it.next();
sb.append("\to ").append(dup);
if (it.hasNext()) {
sb.append("\n");
}
}
}
if (sb.length() > 0) {
getLog().info(sb.toString());
} else {
getLog().info("No duplicate dependencies found in <dependencies/> or in <dependencyManagement/>");
}
}
}
use of org.eclipse.ceylon.aether.apache.maven.model.io.xpp3.MavenXpp3Reader in project maven-plugins by apache.
the class PomUtils method loadPom.
/**
* Loads the (raw) model from the specified POM file.
*
* @param pomFile The path to the POM file to load, must not be <code>null</code>.
* @return The raw model, never <code>null</code>.
* @throws MojoExecutionException If the POM file could not be loaded.
*/
public static Model loadPom(File pomFile) throws MojoExecutionException {
Reader reader = null;
try {
reader = ReaderFactory.newXmlReader(pomFile);
final Model model = new MavenXpp3Reader().read(reader, false);
reader.close();
reader = null;
return model;
} catch (XmlPullParserException e) {
throw new MojoExecutionException("Failed to parse POM: " + pomFile, e);
} catch (IOException e) {
throw new MojoExecutionException("Failed to read POM: " + pomFile, e);
} finally {
IOUtil.close(reader);
}
}
use of org.eclipse.ceylon.aether.apache.maven.model.io.xpp3.MavenXpp3Reader in project maven-plugins by apache.
the class Project001Stub method readModelFromFile.
static Model readModelFromFile(File file) throws IOException, XmlPullParserException {
MavenXpp3Reader pomReader = new MavenXpp3Reader();
XmlStreamReader reader = null;
try {
reader = ReaderFactory.newXmlReader(file);
final Model model = pomReader.read(reader);
reader.close();
reader = null;
return model;
} finally {
IOUtil.close(reader);
}
}
use of org.eclipse.ceylon.aether.apache.maven.model.io.xpp3.MavenXpp3Reader 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);
}
}
Aggregations