Example usage for org.apache.maven.model.inheritance DefaultInheritanceAssembler assembleModelInheritance

List of usage examples for org.apache.maven.model.inheritance DefaultInheritanceAssembler assembleModelInheritance

Introduction

In this page you can find the example usage for org.apache.maven.model.inheritance DefaultInheritanceAssembler assembleModelInheritance.

Prototype

@Override
    public void assembleModelInheritance(Model child, Model parent, ModelBuildingRequest request,
            ModelProblemCollector problems) 

Source Link

Usage

From source file:fr.fastconnect.factory.tibco.bw.maven.source.POMManager.java

License:Apache License

/**
 * Merge a Maven {@link Model} object from a POM file to an existing Maven
 * {@link Model} object.// w w  w  . j  av  a 2  s  .  c o m
 *
 * @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;
}