Search in sources :

Example 1 with RepositoryBase

use of org.apache.maven.model.RepositoryBase in project ignite by apache.

the class MavenUtils method mavenProjectRepositories.

/**
 * @return Collection of configured repositories for the Maven project.
 */
private static Collection<String> mavenProjectRepositories() throws Exception {
    String workDir = System.getProperty("user.dir");
    File prjPomFile = new File(workDir, "pom.xml");
    if (!prjPomFile.exists())
        return Collections.emptyList();
    Path outPath = Files.createTempFile("effective-pom", "");
    try {
        exec(buildMvnCommand() + " -f " + workDir + " help:effective-pom -Doutput=" + outPath.toAbsolutePath());
        Model model = new MavenXpp3Reader().read(new FileInputStream(outPath.toFile()));
        return F.transform(model.getRepositories(), RepositoryBase::getUrl);
    } finally {
        Files.deleteIfExists(outPath);
    }
}
Also used : Path(java.nio.file.Path) RepositoryBase(org.apache.maven.model.RepositoryBase) Model(org.apache.maven.model.Model) MavenXpp3Reader(org.apache.maven.model.io.xpp3.MavenXpp3Reader) File(java.io.File) FileInputStream(java.io.FileInputStream)

Aggregations

File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 Path (java.nio.file.Path)1 Model (org.apache.maven.model.Model)1 RepositoryBase (org.apache.maven.model.RepositoryBase)1 MavenXpp3Reader (org.apache.maven.model.io.xpp3.MavenXpp3Reader)1