use of org.apache.maven.model.io.xpp3.MavenXpp3Reader in project build-info by JFrogDev.
the class ProjectReader method readModel.
/**
* @return Construct a Maven {@link Model} from the pom.
*/
private Model readModel(File pom) throws IOException {
MavenXpp3Reader reader = new MavenXpp3Reader();
StringReader stringReader = null;
try {
stringReader = new StringReader(Files.toString(pom, Charset.forName("UTF-8")));
return reader.read(stringReader);
} catch (XmlPullParserException e) {
throw new IOException(e);
} finally {
IOUtils.closeQuietly(stringReader);
}
}
use of org.apache.maven.model.io.xpp3.MavenXpp3Reader in project tycho by eclipse.
the class TychoVersionsPluginCompatibilityTest method invokeVersionsPluginOnTycho0120Project.
/**
* <p>
* This test verifies that current and future versions of the tycho-versions-plugin can be
* executed on a project that is built with Tycho 0.12.0. With this assertion it's possible to
* call the plugin without version on the commandline:
* </p>
* <p>
* <code>mvn org.eclipse.tycho:tycho-versions-plugin:set-version</code>
* </p>
* <p>
* Background: The tycho-versions-plugin 0.12.0 can't handle projects that are built with Tycho
* 0.11.0 or older, see <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=363791">Bug
* 363791</a>.
* </p>
*/
@Test
public void invokeVersionsPluginOnTycho0120Project() throws Exception {
String expectedNewVersion = "1.2.3";
Verifier verifier = getVerifier("TychoVersionsPluginTest", true);
verifier.getCliOptions().add("-DnewVersion=" + expectedNewVersion);
verifier.executeGoal("org.eclipse.tycho:tycho-versions-plugin:" + TychoVersion.getTychoVersion() + ":set-version");
verifier.verifyErrorFreeLog();
MavenXpp3Reader pomReader = new MavenXpp3Reader();
Model pomModel = pomReader.read(new FileReader(new File(verifier.getBasedir(), "pom.xml")));
assertEquals("<version> in pom.xml has not been changed!", expectedNewVersion, pomModel.getVersion());
}
use of org.apache.maven.model.io.xpp3.MavenXpp3Reader in project jib by google.
the class TestPlugin method before.
@Override
protected void before() throws IOException, XmlPullParserException, VerificationException {
// Installs the plugin for use in tests.
Verifier verifier = new Verifier(".", true);
verifier.setAutoclean(false);
verifier.addCliOption("-DskipTests");
verifier.executeGoal("install");
// Reads the project version.
MavenXpp3Reader reader = new MavenXpp3Reader();
Model model = reader.read(Files.newBufferedReader(Paths.get("pom.xml"), StandardCharsets.UTF_8));
pluginVersion = model.getVersion();
}
use of org.apache.maven.model.io.xpp3.MavenXpp3Reader in project mule by mulesoft.
the class MavenModelFactory method createMavenProject.
/**
* Creates a {@link Model} by reading the {@code pom.xml} file.
*
* @param pomFile to parse and read the model
* @return {@link Model} representing the Maven project from pom file.
*/
public static Model createMavenProject(File pomFile) {
MavenXpp3Reader mavenReader = new MavenXpp3Reader();
if (pomFile != null && pomFile.exists()) {
try (FileReader reader = new FileReader(pomFile)) {
Model model = mavenReader.read(reader);
model.setPomFile(pomFile);
return model;
} catch (Exception e) {
throw new RuntimeException("Couldn't get Maven Artifact from pom: " + pomFile);
}
}
throw new IllegalArgumentException("pom file doesn't exits for path: " + pomFile);
}
use of org.apache.maven.model.io.xpp3.MavenXpp3Reader in project ceylon by eclipse.
the class AetherResolverImpl method findExtension.
private String findExtension(File pomFile) {
if (pomFile != null && pomFile.exists()) {
MavenXpp3Reader reader = new MavenXpp3Reader();
Model model;
try (FileReader fileReader = new FileReader(pomFile)) {
model = reader.read(fileReader);
return model.getPackaging();
} catch (XmlPullParserException | IOException e) {
return null;
}
}
;
return null;
}
Aggregations