当前位置: 首页>>代码示例>>Java>>正文


Java MavenXpp3Reader.read方法代码示例

本文整理汇总了Java中org.apache.maven.model.io.xpp3.MavenXpp3Reader.read方法的典型用法代码示例。如果您正苦于以下问题:Java MavenXpp3Reader.read方法的具体用法?Java MavenXpp3Reader.read怎么用?Java MavenXpp3Reader.read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.maven.model.io.xpp3.MavenXpp3Reader的用法示例。


在下文中一共展示了MavenXpp3Reader.read方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: fromPom

import org.apache.maven.model.io.xpp3.MavenXpp3Reader; //导入方法依赖的package包/类
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);
}
 
开发者ID:swissquote,项目名称:carnotzet,代码行数:21,代码来源:CarnotzetModuleCoordinates.java

示例2: getModelFromPOM

import org.apache.maven.model.io.xpp3.MavenXpp3Reader; //导入方法依赖的package包/类
/**
 * Load a Maven {@link Model} object from a POM file.
 * 
 * @param pom
 * @param logger
 * @return the model parsed from the POM file
 * @throws XmlPullParserException 
 * @throws IOException 
 */
public static Model getModelFromPOM(File pom, Log logger) throws IOException, XmlPullParserException {
	Model model = null;
	FileInputStream fis = null;
	InputStreamReader isr = null;
	try {
		fis = new FileInputStream(pom);
		isr = new InputStreamReader(fis, "utf-8"); // FIXME
		MavenXpp3Reader reader = new MavenXpp3Reader();
		model = reader.read(isr);
	} finally {
		try {
			isr.close();
			fis.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	return model;
}
 
开发者ID:fastconnect,项目名称:tibco-bwmaven,代码行数:30,代码来源:POMManager.java

示例3: mergeModelFromPOM

import org.apache.maven.model.io.xpp3.MavenXpp3Reader; //导入方法依赖的package包/类
/**
 * Merge a Maven {@link Model} object from a POM file to an existing Maven
 * {@link Model} object.
 *
 * @param pom
 * @param existingModel
 * @param logger
 * @return the existing model merged with the parsed model from the POM file
 * @throws XmlPullParserException
 * @throws IOException
 */
public static Model mergeModelFromPOM(File pom, Model existingModel, Log logger) throws IOException, XmlPullParserException {
	if (pom == null || !pom.exists() || existingModel == null || logger == null) return null;

	Model model = null;
	FileInputStream fis = null;
	InputStreamReader isr = null;
	try {
		fis = new FileInputStream(pom);
		isr = new InputStreamReader(fis, "utf-8"); // FIXME
		MavenXpp3Reader reader = new MavenXpp3Reader();
		model = reader.read(isr);
		DefaultInheritanceAssembler assembler = new DefaultInheritanceAssembler();
		assembler.assembleModelInheritance(model, existingModel, null, null);
	} finally {
		try {
			isr.close();
			fis.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	return model;
}
 
开发者ID:fastconnect,项目名称:tibco-bwmaven,代码行数:36,代码来源:POMManager.java

示例4: parseParentPom

import org.apache.maven.model.io.xpp3.MavenXpp3Reader; //导入方法依赖的package包/类
public void parseParentPom(InputStream inputStream) {
    try {
        MavenXpp3Reader reader = new MavenXpp3Reader();

        Model model = reader.read(inputStream);

        PomInformation parentPom = new PomInformation();

        setPropertiesFromModel(parentPom, model);
        parentPom.setParent(model.getParent());

        this.parentPomInformation = parentPom;
    } catch (Exception ex) {
        LOGGER.error("Error while reading parent POM file", ex);
    } 
}
 
开发者ID:motech,项目名称:motech,代码行数:17,代码来源:PomInformation.java

示例5: mavenProjectFor

import org.apache.maven.model.io.xpp3.MavenXpp3Reader; //导入方法依赖的package包/类
public MavenProject mavenProjectFor(File pom, List<Property> properties) throws Exception {
    MavenXpp3Reader reader = new MavenXpp3Reader();
    Model model = reader.read(new FileReader(pom));

    for (Property p : properties) {
        model.addProperty(p.name, p.value);
    }

    model.setRepositories(new ArrayList<Repository>());

    MavenProject project = new MavenProject(model);

    project.setPluginArtifactRepositories(new ArrayList<ArtifactRepository>());
    project.setFile(pom);

    return project;
}
 
开发者ID:smartcodeltd,项目名称:release-candidate-maven-plugin,代码行数:18,代码来源:Mojos.java

示例6: getRawModel

import org.apache.maven.model.io.xpp3.MavenXpp3Reader; //导入方法依赖的package包/类
/**
 * Gets the current raw model before any interpolation what-so-ever.
 *
 * @param modifiedPomXMLEventReader The {@link ModifiedPomXMLEventReader} to get the raw model for.
 * @return The raw model.
 * @throws IOException if the file is not found or if the file does not parse.
 */
public static Model getRawModel( ModifiedPomXMLEventReader modifiedPomXMLEventReader )
    throws IOException
{
    StringReader stringReader = null;
    try
    {
        stringReader = new StringReader( modifiedPomXMLEventReader.asStringBuilder().toString() );
        MavenXpp3Reader reader = new MavenXpp3Reader();
        return reader.read( stringReader );
    }
    catch ( XmlPullParserException e )
    {
        IOException ioe = new IOException( e.getMessage() );
        ioe.initCause( e );
        throw ioe;
    }
    finally
    {
        if ( stringReader != null )
        {
            stringReader.close();
        }
    }
}
 
开发者ID:petr-ujezdsky,项目名称:versions-maven-plugin-svn-clone,代码行数:32,代码来源:PomHelper.java

示例7: getMavenPropertyVersionFor

import org.apache.maven.model.io.xpp3.MavenXpp3Reader; //导入方法依赖的package包/类
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;
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:24,代码来源:TestEnvironmentUtil.java

示例8: readProject

import org.apache.maven.model.io.xpp3.MavenXpp3Reader; //导入方法依赖的package包/类
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();
        }
    }
}
 
开发者ID:sundrio,项目名称:sundrio,代码行数:20,代码来源:AbstractSundrioMojo.java

示例9: loadProject

import org.apache.maven.model.io.xpp3.MavenXpp3Reader; //导入方法依赖的package包/类
protected MavenProject loadProject(File pomFile) throws IOException, XmlPullParserException {
    MavenProject ret;
    MavenXpp3Reader mavenReader = new MavenXpp3Reader();

    //Removed null and file exists protections that mask errors
    FileReader reader = null;
    reader = new FileReader(pomFile);
    Model model = mavenReader.read(reader);
    model.setPomFile(pomFile);
    ret = new MavenProject(model);
    if(model.getParent() != null) {
        MavenProject parent = new MavenProject();
        parent.setGroupId(model.getParent().getGroupId());
        parent.setArtifactId(model.getParent().getArtifactId());
        parent.setVersion(model.getParent().getVersion());
        ret.setParent(parent);
    }

    reader.close();

    return ret;
}
 
开发者ID:DIVERSIFY-project,项目名称:sosiefier,代码行数:23,代码来源:MavenDependencyResolver.java

示例10: getProjectVersion

import org.apache.maven.model.io.xpp3.MavenXpp3Reader; //导入方法依赖的package包/类
/**
 *
 * @return
 */
private static String getProjectVersion() {
    File corePomfile = new File(
            ITHelper.class.getClassLoader().getResource("").getPath()
                    + "/../../pom.xml");
    Model model = null;
    FileReader reader;
    MavenXpp3Reader mavenReader = new MavenXpp3Reader();
    try {
        reader = new FileReader(corePomfile);
        model = mavenReader.read(reader);
        model.setPomFile(corePomfile);
    } catch(Exception ex){}
    MavenProject project = new MavenProject(model);
    return project.getVersion();
}
 
开发者ID:holodeck-b2b,项目名称:Holodeck-B2B,代码行数:20,代码来源:ITHelper.java

示例11: readMavenModel

import org.apache.maven.model.io.xpp3.MavenXpp3Reader; //导入方法依赖的package包/类
private Model readMavenModel(String baseDir) throws FileNotFoundException, IOException {
    Reader reader = null;
    try {
        Path pomPath = fs.getPath(baseDir, "pom.xml");
        if (Files.notExists(pomPath)) {
            return null;
        }
        reader = new FileReader(pomPath.toFile());
        MavenXpp3Reader xpp3Reader = new MavenXpp3Reader();
        return xpp3Reader.read(reader);
    } catch (XmlPullParserException e) {
        throw new IllegalStateException("Cannot read maven model");
    } finally {
        if (reader != null) {
            reader.close();
        }
    }
}
 
开发者ID:Glamdring,项目名称:aardWARk,代码行数:19,代码来源:StartupListener.java

示例12: getBuildStringFromPomXml

import org.apache.maven.model.io.xpp3.MavenXpp3Reader; //导入方法依赖的package包/类
public String getBuildStringFromPomXml() {
	Model model = null;
	FileReader reader = null;
	MavenXpp3Reader mavenreader = new MavenXpp3Reader();

	try {
		File pomfile = new File("pom.xml");
		reader = new FileReader(pomfile);
		model = mavenreader.read(reader);
		model.setPomFile(pomfile);
	} catch (Exception ex) {
		ex.printStackTrace();
	}

	MavenProject project = new MavenProject(model);

	logger.trace("version " + project.getVersion());
	return project.getVersion();
}
 
开发者ID:Neonunux,项目名称:calao,代码行数:20,代码来源:Version.java

示例13: resolveDependenciesFromMultimodulePrj

import org.apache.maven.model.io.xpp3.MavenXpp3Reader; //导入方法依赖的package包/类
public static List<Artifact> resolveDependenciesFromMultimodulePrj(List<String> pomsPaths) {
    MavenXpp3Reader reader = new MavenXpp3Reader();
    List<Artifact> deps = new ArrayList<>();
    try {
        for (String pomx : pomsPaths) {
            Path pom = Paths.get(pomx);
            Model model = reader.read(new ByteArrayInputStream(Files.readAllBytes(pom)));
            if (model.getDependencyManagement() != null && model.getDependencyManagement().getDependencies() != null) {
                createArtifacts(model.getDependencyManagement().getDependencies(),
                                deps);
            }
            if (model.getDependencies() != null) {
                createArtifacts(model.getDependencies(),
                                deps);
            }
        }
    } catch (Exception ex) {
        logger.error(ex.getMessage());
        return Collections.emptyList();
    }
    return deps;
}
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:23,代码来源:MavenUtils.java

示例14: getParent

import org.apache.maven.model.io.xpp3.MavenXpp3Reader; //导入方法依赖的package包/类
private Parent getParent(IDocument doc) {
    Model model = null;
    MavenXpp3Reader mavenreader = new MavenXpp3Reader();
    InputStream in = null;
    try {
        in = IOUtils.toInputStream(doc.get(), "UTF-8");
        model = mavenreader.read(in);
        return model.getParent();
    } catch (Exception ex) {

    } finally {
        if (in != null) {
            try {
                in.close();
            } catch (IOException e) {

            }
        }
    }
    return null;
}
 
开发者ID:mulesoft,项目名称:mule-tooling-incubator,代码行数:22,代码来源:ParentPomLinkDetector.java

示例15: getModel

import org.apache.maven.model.io.xpp3.MavenXpp3Reader; //导入方法依赖的package包/类
public Model getModel(File artifactFile) throws IOException {
    Model model = null;
    FileReader reader = null;
    MavenXpp3Reader mavenreader = new MavenXpp3Reader();
    try {
        reader = new FileReader(artifactFile);
        model = mavenreader.read(reader);
    } catch (Exception ex) {

    } finally {
        if (reader != null) {
            reader.close();
        }
    }
    return model;
}
 
开发者ID:mulesoft,项目名称:mule-tooling-incubator,代码行数:17,代码来源:MavenArtifactResolver.java


注:本文中的org.apache.maven.model.io.xpp3.MavenXpp3Reader.read方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。