Java Code Examples for org.apache.maven.model.io.xpp3.MavenXpp3Reader

The following examples show how to use org.apache.maven.model.io.xpp3.MavenXpp3Reader. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: raptor   Source File: PomGeneratorTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testWriteTo() throws IOException, XmlPullParserException {
    String artifactId = "artifactId";
    String version = "version";
    String groupId = "groupId";

    PomModel pomModel = PomModel.builder().artifactId(artifactId).groupId(groupId).version(version).build();
    PomGenerator pomGenerator = new PomGenerator(pomModel);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    pomGenerator.writeTo(baos);
    String s = baos.toString();

    MavenXpp3Reader mavenXpp3Reader = new MavenXpp3Reader();
    InputStream is = new ByteArrayInputStream(s.getBytes());

    Model generated = mavenXpp3Reader.read(is);

    Assert.assertEquals(artifactId,generated.getArtifactId());
    Assert.assertEquals(version,generated.getVersion());
    Assert.assertEquals(groupId,generated.getGroupId());

}
 
Example 2
Source Project: netbeans   Source File: NBMNativeMWITest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testPathNoParent() throws IOException, XmlPullParserException {
    clearWorkDir();
    wd = FileUtil.toFileObject(getWorkDir());
    FileObject createData = wd.createFolder("test1");
    ProjectInfo pi = new ProjectInfo("my.groupid", "artefact1", "1.0", "my.packagename");
    NBMNativeMWI.instantiate(pi, FileUtil.toFile(createData), "RELEASE110", true, null);

    FileObject builtpom = createData.getFileObject("pom", "xml");
    MavenXpp3Reader reader = new MavenXpp3Reader();
    Model model = reader.read(new FileReader(FileUtil.toFile(builtpom)));

    assertEquals("nbm-maven-plugin", model.getBuild().getPlugins().get(0).getArtifactId());
    assertEquals(MavenNbModuleImpl.getLatestNbmPluginVersion(), model.getBuild().getPlugins().get(0).getVersion());
    assertEquals("maven-compiler-plugin", model.getBuild().getPlugins().get(1).getArtifactId());
    assertEquals("3.8.1", model.getBuild().getPlugins().get(1).getVersion());
    assertEquals(0, model.getRepositories().size());
}
 
Example 3
Source Project: netbeans   Source File: NBMNativeMWITest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testPathNoParentSnapshot() throws IOException, XmlPullParserException {
    clearWorkDir();
    wd = FileUtil.toFileObject(getWorkDir());
    FileObject createData = wd.createFolder("test1");
    ProjectInfo pi = new ProjectInfo("my.groupid", "artefact1", "1.0", "my.packagename");
    NBMNativeMWI.instantiate(pi, FileUtil.toFile(createData), "dev-SNAPSHOT", true, null);
    FileObject builtpom = createData.getFileObject("pom", "xml");

    MavenXpp3Reader reader = new MavenXpp3Reader();
    Model model = reader.read(new FileReader(FileUtil.toFile(builtpom)));
    assertEquals("nbm-maven-plugin", model.getBuild().getPlugins().get(0).getArtifactId());
    assertEquals(MavenNbModuleImpl.getLatestNbmPluginVersion(), model.getBuild().getPlugins().get(0).getVersion());
    assertEquals("maven-compiler-plugin", model.getBuild().getPlugins().get(1).getArtifactId());
    assertEquals("3.8.1", model.getBuild().getPlugins().get(1).getVersion());
    assertEquals(1, model.getRepositories().size());
}
 
Example 4
Source Project: NoraUi   Source File: Context.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * statisticsProcessor retrieves specific information from the robot to return it to users statistic feature.
 * 
 * @param loader
 *            is class loader.
 * @param packageName
 *            read for users statistic feature.
 * @return it to users statistic feature.
 */
protected Statistics statisticsProcessor(ClassLoader loader, String packageName) {
    Statistics stat = new Statistics();
    MavenXpp3Reader reader = new MavenXpp3Reader();
    org.apache.maven.model.Model model;
    try {
        model = reader.read(new FileReader("pom.xml"));
        stat.setNorauiVersion(model.getProperties().getProperty("noraui.version"));
        stat.setName(model.getName());
        stat.setGroupId(model.getGroupId());
        stat.setArtifactId(model.getArtifactId());
        stat.setVersion(model.getVersion());
    } catch (IOException | XmlPullParserException e) {
        log.trace("noraui.version not found.");
    }
    stat.setApplications(applications.entrySet().stream().filter(e -> e.getValue().getHomeUrl() != null).collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().getHomeUrl(), (a, b) -> b)));
    try {
        Map<String, String> code = ClassPath.from(loader).getTopLevelClassesRecursive(packageName).stream().collect(Collectors.toMap(ClassInfo::getName, c -> read(c.getName()), (a, b) -> b));
        stat.setCucumberMethods(code);
    } catch (IOException e1) {
        log.trace("Cucumber Methods not found.");
    }
    return stat;
}
 
Example 5
@Test
public void getSpringCloudReleaseVersionTest() throws Exception {
	String bomVersion = "vHoxton.BUILD-SNAPSHOT";
	RestTemplate rest = mock(RestTemplate.class);
	Github github = mock(Github.class);
	GithubPomReader githubPomReader = mock(GithubPomReader.class);
	when(githubPomReader.readPomFromUrl(eq(String
			.format(SpringCloudRelease.SPRING_CLOUD_STARTER_PARENT_RAW, bomVersion))))
					.thenReturn(new MavenXpp3Reader()
							.read(new FileReader(new ClassPathResource(
									"spring-cloud-starter-parent-pom.xml")
											.getFile())));
	when(githubPomReader.readPomFromUrl(eq(String.format(
			SpringCloudRelease.SPRING_CLOUD_RELEASE_DEPENDENCIES_RAW, bomVersion))))
					.thenReturn(new MavenXpp3Reader().read(new FileReader(
							new ClassPathResource("spring-cloud-dependencies-pom.xml")
									.getFile())));
	InitializrSpringCloudInfoService service = spy(
			new InitializrSpringCloudInfoService(rest, github, githubPomReader));
	doReturn(Arrays.asList(new String[] { bomVersion })).when(service)
			.getSpringCloudVersions();
	Map<String, String> releaseVersionsResult = service
			.getReleaseVersions(bomVersion);
	assertThat(releaseVersionsResult,
			Matchers.equalTo(SpringCloudInfoTestData.releaseVersions));
}
 
Example 6
@Test(expected = SpringCloudVersionNotFoundException.class)
public void getSpringCloudReleaseVersionNotFoundTest() throws Exception {
	String bomVersion = "vFooBar.BUILD-SNAPSHOT";
	RestTemplate rest = mock(RestTemplate.class);
	Github github = mock(Github.class);
	GithubPomReader githubPomReader = mock(GithubPomReader.class);
	when(githubPomReader.readPomFromUrl(eq(String
			.format(SpringCloudRelease.SPRING_CLOUD_STARTER_PARENT_RAW, bomVersion))))
					.thenReturn(new MavenXpp3Reader()
							.read(new FileReader(new ClassPathResource(
									"spring-cloud-starter-parent-pom.xml")
											.getFile())));
	when(githubPomReader.readPomFromUrl(eq(String.format(
			SpringCloudRelease.SPRING_CLOUD_RELEASE_DEPENDENCIES_RAW, bomVersion))))
					.thenReturn(new MavenXpp3Reader().read(new FileReader(
							new ClassPathResource("spring-cloud-dependencies-pom.xml")
									.getFile())));
	InitializrSpringCloudInfoService service = spy(
			new InitializrSpringCloudInfoService(rest, github, githubPomReader));
	doReturn(new ArrayList()).when(service).getSpringCloudVersions();
	service.getReleaseVersions(bomVersion);
}
 
Example 7
Source Project: carnotzet   Source File: CarnotzetModuleCoordinates.java    License: Apache License 2.0 6 votes vote down vote up
public static CarnotzetModuleCoordinates fromPom(@NonNull Path pom) {
	Model result;
	try {
		BufferedReader in = new BufferedReader(Files.newBufferedReader(pom, StandardCharsets.UTF_8));
		MavenXpp3Reader reader = new MavenXpp3Reader();
		result = reader.read(in);
	}
	catch (XmlPullParserException | IOException e) {
		throw new CarnotzetDefinitionException(e);
	}
	String groupId = result.getGroupId();
	String version = result.getVersion();
	if (groupId == null) {
		groupId = result.getParent().getGroupId();
	}
	if (version == null) {
		version = result.getParent().getVersion();
	}
	return new CarnotzetModuleCoordinates(groupId, result.getArtifactId(), version, null);
}
 
Example 8
Source Project: scava   Source File: LibrarySuggestionModel.java    License: Eclipse Public License 2.0 6 votes vote down vote up
private Collection<Library> readUsedLibrariesFromProject() {
	Collection<Library> usedLibraries;

	try {
		MavenXpp3Reader reader = new MavenXpp3Reader();
		org.apache.maven.model.Model model = reader.read(new FileReader(pomLocation));
		List<Dependency> dependencies = model.getDependencies();

		usedLibraries = dependencies.stream()
				.map(dependency -> new Library(Optional.ofNullable(dependency.getGroupId()).orElse(""),
						Optional.ofNullable(dependency.getArtifactId()).orElse(""),
						Optional.ofNullable(dependency.getVersion()).orElse(""), null))
				.collect(Collectors.toList());

	} catch (IOException | XmlPullParserException e1) {
		usedLibraries = new ArrayList<>();
	}

	return usedLibraries;
}
 
Example 9
Source Project: scava   Source File: LibrarySuggestionModel.java    License: Eclipse Public License 2.0 6 votes vote down vote up
public void installPickedLibraries() throws FileNotFoundException, IOException, XmlPullParserException {
	MavenXpp3Reader reader = new MavenXpp3Reader();
	org.apache.maven.model.Model model = reader.read(new FileReader(pomLocation));

	pickedLibraries.forEach(library -> {
		Dependency dependency = new Dependency();
		dependency.setGroupId(library.getGroupId());
		dependency.setArtifactId(library.getArtifactId());
		dependency.setVersion(library.getVersion());

		model.addDependency(dependency);
	});

	MavenXpp3Writer writer = new MavenXpp3Writer();
	writer.write(new FileWriter(pomLocation), model);
}
 
Example 10
Source Project: spring-cloud-release   Source File: PomReader.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Returns a parsed POM.
 * @param pom location to the pom
 * @return parsed model
 */
public static Model readPom(File pom) {
	if (!pom.exists()) {
		throw new IllegalStateException(
				"File [" + pom.getAbsolutePath() + "] not found");
	}
	String fileText = "";
	try (Reader reader = new FileReader(pom)) {
		if (pom.isFile()) {
			fileText = new String(Files.readAllBytes(pom.toPath()));
		}
		MavenXpp3Reader xpp3Reader = new MavenXpp3Reader();
		return xpp3Reader.read(reader);
	}
	catch (XmlPullParserException | IOException e) {
		if (pom.isFile() && fileText.length() == 0) {
			throw new IllegalStateException(
					"File [" + pom.getAbsolutePath() + "] is empty", e);
		}
		throw new IllegalStateException(
				"Failed to read file: " + pom.getAbsolutePath(), e);
	}
}
 
Example 11
Source Project: gradle-plugins   Source File: MavenProjectWrapper.java    License: MIT License 6 votes vote down vote up
public MavenProjectWrapper(Project project, File pomFile) throws IOException, XmlPullParserException {
    this.project = project;
    this.pomFile = pomFile;

    MavenXpp3Reader reader = new MavenXpp3Reader();
    Model model = reader.read(new FileReader(pomFile));

    setModel(model);

    getBuild().setDirectory(project.getBuildDir().getAbsolutePath());

    SourceSetContainer sourceSets = project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets();

    SourceSet main = sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME);
    getBuild().setSourceDirectory(main.getJava().getSrcDirs().iterator().next().getAbsolutePath());
    getBuild().setOutputDirectory(main.getJava().getOutputDir().getAbsolutePath());

    SourceSet test = sourceSets.getByName(SourceSet.TEST_SOURCE_SET_NAME);
    getBuild().setTestSourceDirectory(test.getJava().getSrcDirs().iterator().next().getAbsolutePath());
    getBuild().setTestOutputDirectory(test.getJava().getOutputDir().getAbsolutePath());

    setArtifact(new ProjectArtifact(this));
}
 
Example 12
Source Project: appassembler   Source File: AbstractDaemonGeneratorTest.java    License: MIT License 6 votes vote down vote up
private static String getAppAssemblerBooterVersion()
    throws IOException, XmlPullParserException
{
    if ( appassemblerVersion == null )
    {
        MavenXpp3Reader reader = new MavenXpp3Reader();
        FileReader fileReader = new FileReader( getTestFile( "pom.xml" ) );
        try
        {
            appassemblerVersion = reader.read( fileReader ).getParent().getVersion();
        }
        finally
        {
            IOUtil.close( fileReader );
        }
    }
    return appassemblerVersion;
}
 
Example 13
public static String getMavenPropertyVersionFor(String key) {
  // Maven compile uses a jar, and is in target
  String basePath = Paths.get("").toAbsolutePath().toString();
  if (basePath.endsWith("target")) {
    basePath = basePath.replace("target/", "");
  }

  String pomfile = basePath + "/../../pom.xml";
  Model model = null;
  MavenXpp3Reader mavenreader = new MavenXpp3Reader();
  try {
    FileReader reader = new FileReader(pomfile);
    model = mavenreader.read(reader);
    model.setPomFile(new File(pomfile));
  } catch (Exception ex) {
    throw new IllegalStateException("Can't find the pom.xml file. basePath=" + basePath + " pomFile=" + pomfile);
  }

  MavenProject project = new MavenProject(model);
  Properties properties = project.getProperties();
  String value = (String) properties.get(key);
  return value;
}
 
Example 14
Source Project: sundrio   Source File: AbstractSundrioMojo.java    License: Apache License 2.0 6 votes vote down vote up
MavenProject readProject(File pomFile) throws IOException {
    MavenXpp3Reader mavenReader = new MavenXpp3Reader();
    FileReader fileReader = null;
    try {
        fileReader = new FileReader(pomFile);
        Model model = mavenReader.read(fileReader);
        model.setPomFile(pomFile);
        MavenProject project = new MavenProject(model);
        project.setFile(pomFile);
        project.setArtifact(createArtifact(pomFile, model.getGroupId(), model.getArtifactId(), model.getVersion(), "compile", model.getPackaging(), ""));
        return project;
    } catch (Exception e) {
        throw new RuntimeException(e);
    } finally {
        if (fileReader != null) {
            fileReader.close();
        }
    }
}
 
Example 15
Source Project: jkube   Source File: MavenUtilTest.java    License: Eclipse Public License 2.0 5 votes vote down vote up
private MavenProject loadMavenProjectFromPom() throws IOException, XmlPullParserException {
    MavenXpp3Reader mavenreader = new MavenXpp3Reader();
    File pomfile = new File(getClass().getResource("/util/test-pom.xml").getFile());
    final FileReader reader = new FileReader(pomfile);
    final Model model  = mavenreader.read(reader);
    model.setPomFile(pomfile);
    model.getBuild().setOutputDirectory(temporaryFolder.newFolder("outputDirectory").getAbsolutePath());
    model.getBuild().setDirectory(temporaryFolder.newFolder("build").getAbsolutePath());
    return new MavenProject(model);
}
 
Example 16
Source Project: camel-spring-boot   Source File: BomGeneratorMojo.java    License: Apache License 2.0 5 votes vote down vote up
private MavenProject loadExternalProjectPom(File pomFile) throws Exception {
    try (FileReader reader = new FileReader(pomFile)) {
        MavenXpp3Reader mavenReader = new MavenXpp3Reader();
        Model model = mavenReader.read(reader);

        MavenProject project = new MavenProject(model);
        project.setFile(pomFile);
        return project;
    }
}
 
Example 17
Source Project: kylin-on-parquet-v2   Source File: DeployUtil.java    License: Apache License 2.0 5 votes vote down vote up
private static String getPomVersion() {
    try {
        MavenXpp3Reader pomReader = new MavenXpp3Reader();
        Model model = pomReader
                .read(new InputStreamReader(new FileInputStream("../pom.xml"), StandardCharsets.UTF_8));
        return model.getVersion();
    } catch (Exception e) {
        throw new RuntimeException(e.getMessage(), e);
    }
}
 
Example 18
Source Project: helidon-build-tools   Source File: PomUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Reads the pom model.
 *
 * @param pomFile The pom file.
 * @return The model.
 * @throws RuntimeException on error.
 */
public static Model readPomModel(File pomFile) {
    try {
        try (FileReader fr = new FileReader(pomFile)) {
            MavenXpp3Reader mvnReader = new MavenXpp3Reader();
            return mvnReader.read(fr);
        }
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
Example 19
Source Project: vertx-maven-plugin   Source File: MojoUtilsTest.java    License: Apache License 2.0 5 votes vote down vote up
private Model buildModel(File pomFile) {
    try {
        return new MavenXpp3Reader().read(ReaderFactory.newXmlReader(pomFile));
    } catch (IOException var3) {
        throw new RuntimeException("Failed to read POM file: " + pomFile, var3);
    } catch (XmlPullParserException var4) {
        throw new RuntimeException("Failed to parse POM file: " + pomFile, var4);
    }
}
 
Example 20
Source Project: vertx-maven-plugin   Source File: Verify.java    License: Apache License 2.0 5 votes vote down vote up
public static void verifySetupWithVersion(File pomFile) throws Exception {
    MavenXpp3Reader xpp3Reader = new MavenXpp3Reader();
    Model model = xpp3Reader.read(new FileInputStream(pomFile));

    MavenProject project = new MavenProject(model);
    Properties projectProps = project.getProperties();
    assertNotNull(projectProps);
    assertFalse(projectProps.isEmpty());
    assertEquals(projectProps.getProperty("vertx.version"), "3.4.0");
}
 
Example 21
Source Project: vertx-maven-plugin   Source File: ExtraManifestInfoTest.java    License: Apache License 2.0 5 votes vote down vote up
private Model buildModel(File pomFile) {
    try {
        return new MavenXpp3Reader().read(ReaderFactory.newXmlReader(pomFile));
    } catch (IOException var3) {
        throw new RuntimeException("Failed to read POM file: " + pomFile, var3);
    } catch (XmlPullParserException var4) {
        throw new RuntimeException("Failed to parse POM file: " + pomFile, var4);
    }
}
 
Example 22
Source Project: java-specialagent   Source File: VerifyMojo.java    License: Apache License 2.0 5 votes vote down vote up
private Map<String,String> scanRenames() throws IOException, XmlPullParserException {
  final BufferedReader in = new BufferedReader(new FileReader(project.getParent().getFile()));
  final MavenXpp3Reader reader = new MavenXpp3Reader();
  final Model model = reader.read(in);
  final Properties properties = model.getProperties();
  final Map<String,String> renames = new HashMap<>();
  for (final Dependency dependency : model.getDependencies()) {
    final String rename = properties.getProperty(dependency.getArtifactId());
    if (rename != null)
      renames.put(dependency.getArtifactId() + "-" + dependency.getVersion() + ".jar", rename + ".jar");
  }

  return renames;
}
 
Example 23
Source Project: docker-maven-plugin   Source File: ProjectStub.java    License: Apache License 2.0 5 votes vote down vote up
public ProjectStub(File pom) {
  final MavenXpp3Reader pomReader = new MavenXpp3Reader();
  Model model;
  try {
    model = pomReader.read(ReaderFactory.newXmlReader(pom));
    setModel(model);
  } catch (Exception e) {
    throw new RuntimeException(e);
  }

  setGroupId(model.getGroupId());
  setArtifactId(model.getArtifactId());
  setVersion(model.getVersion());
  setName(model.getName());
  setUrl(model.getUrl());
  setPackaging(model.getPackaging());
  setBuild(model.getBuild());

  final List<String> compileSourceRoots = new ArrayList<>();
  compileSourceRoots.add(getBasedir() + "/src/main/java");
  setCompileSourceRoots(compileSourceRoots);

  final List<String> testCompileSourceRoots = new ArrayList<>();
  testCompileSourceRoots.add(getBasedir() + "/src/test/java");
  setTestCompileSourceRoots(testCompileSourceRoots);

  // normalize some expressions
  getBuild().setDirectory("${project.basedir}/target");
  getBuild().setTestOutputDirectory(new File(getBasedir(), "target/classes").getAbsolutePath());
}
 
Example 24
Source Project: quarkus   Source File: MojoUtils.java    License: Apache License 2.0 5 votes vote down vote up
public static Model readPom(final InputStream resourceAsStream) throws IOException {
    try (InputStream stream = resourceAsStream) {
        return new MavenXpp3Reader().read(stream);
    } catch (XmlPullParserException e) {
        throw new IOException(e.getMessage(), e);
    }
}
 
Example 25
Source Project: quarkus   Source File: ModelUtils.java    License: Apache License 2.0 5 votes vote down vote up
public static Model readModel(InputStream stream) throws IOException {
    try (InputStream is = stream) {
        return new MavenXpp3Reader().read(stream);
    } catch (XmlPullParserException e) {
        throw new IOException("Failed to parse POM", e);
    }
}
 
Example 26
Source Project: quarkus   Source File: MojoTestBase.java    License: Apache License 2.0 5 votes vote down vote up
public static Model loadPom(File directory) {
    File pom = new File(directory, "pom.xml");
    assertThat(pom).isFile();
    try (InputStreamReader isr = new InputStreamReader(new FileInputStream(pom), StandardCharsets.UTF_8);) {
        return new MavenXpp3Reader().read(isr);
    } catch (IOException | XmlPullParserException e) {
        throw new IllegalArgumentException("Cannot read the pom.xml file", e);
    }
}
 
Example 27
Source Project: quarkus   Source File: SetupVerifier.java    License: Apache License 2.0 5 votes vote down vote up
public static void verifySetupWithVersion(File pomFile) throws Exception {
    MavenXpp3Reader xpp3Reader = new MavenXpp3Reader();
    Model model = xpp3Reader.read(new FileInputStream(pomFile));

    MavenProject project = new MavenProject(model);
    Properties projectProps = project.getProperties();
    assertNotNull(projectProps);
    assertFalse(projectProps.isEmpty());
    final String quarkusVersion = getPlatformDescriptor().getQuarkusVersion();
    assertEquals(quarkusVersion, projectProps.getProperty(MojoUtils.TEMPLATE_PROPERTY_QUARKUS_PLUGIN_VERSION_NAME));
}
 
Example 28
Source Project: cyclonedx-gradle-plugin   Source File: MavenHelper.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Reads a POM and creates a MavenProject from it.
 * @param in the inputstream to read from
 * @return a MavenProject
 */
MavenProject readPom(InputStream in) {
    try {
        final MavenXpp3Reader mavenreader = new MavenXpp3Reader();
        try (final InputStreamReader reader = new InputStreamReader(in)) {
            final Model model = mavenreader.read(reader);
            return new MavenProject(model);
        }
    } catch (XmlPullParserException | IOException e) {
        logger.error("An error occurred attempting to read POM", e);
    }
    return null;
}
 
Example 29
Source Project: butterfly   Source File: AbstractStaxPomOperation.java    License: MIT License 5 votes vote down vote up
protected Model getModel(File pomFile) throws IOException, XmlPullParserException {
    MavenXpp3Reader reader = new MavenXpp3Reader();
    FileInputStream fileInputStream = new FileInputStream(pomFile);
    Model model = reader.read(fileInputStream);
    fileInputStream.close();

    return model;
}
 
Example 30
Source Project: butterfly   Source File: TransformationUtilityTestHelper.java    License: MIT License 5 votes vote down vote up
private Model getPomModel(File pomFile) throws IOException, XmlPullParserException {
    FileInputStream inputStream = null;
    try {
        MavenXpp3Reader reader = new MavenXpp3Reader();
        inputStream = new FileInputStream(pomFile);
        return reader.read(inputStream);
    } finally {
        if (inputStream != null) inputStream.close();
    }
}