當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。