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


Java MavenXpp3Reader类代码示例

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


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

示例1: AbstractProjectStub

import org.apache.maven.model.io.xpp3.MavenXpp3Reader; //导入依赖的package包/类
AbstractProjectStub(String pomResourceName) throws IOException, XmlPullParserException {
    super(new MavenXpp3Reader().read(ITCompileBundleMojo.class.getResourceAsStream(pomResourceName)));

    Model model = getModel();
    setGroupId(model.getGroupId());
    setArtifactId(model.getArtifactId());
    setVersion(model.getVersion());
    setName(model.getName());
    setUrl(model.getUrl());
    setPackaging(model.getPackaging());

    SimpleArtifactStub artifact = new SimpleArtifactStub(
        model.getGroupId(), model.getArtifactId(), model.getVersion(), model.getPackaging());
    artifact.setArtifactHandler(new SimpleArtifactHandlerStub(model.getPackaging()));
    setArtifact(artifact);

    Build build = new Build();
    build.setFinalName(model.getArtifactId() + '-' + model.getVersion());
    setBuild(build);

    for (Dependency dependency: model.getDependencies()) {
        if (dependency.getScope() == null) {
            dependency.setScope(JavaScopes.COMPILE);
        }
    }
}
 
开发者ID:cloudkeeper-project,项目名称:cloudkeeper,代码行数:27,代码来源:AbstractProjectStub.java

示例2: 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

示例3: getAppAssemblerBooterVersion

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

示例4: 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

示例5: 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

示例6: 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

示例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: 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

示例10: 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

示例11: 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

示例12: 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

示例13: getCurrentProjectVersion

import org.apache.maven.model.io.xpp3.MavenXpp3Reader; //导入依赖的package包/类
/**
 * Gets current project version from pom.xml file.
 * 
 * @return Current project version.
 * @throws MojoFailureException
 */
protected String getCurrentProjectVersion() throws MojoFailureException {
    try {
        // read pom.xml
        final MavenXpp3Reader mavenReader = new MavenXpp3Reader();
        final FileReader fileReader = new FileReader(mavenSession
                .getCurrentProject().getFile().getAbsoluteFile());
        try {
            final Model model = mavenReader.read(fileReader);

            if (model.getVersion() == null) {
                throw new MojoFailureException(
                        "Cannot get current project version. This plugin should be executed from the parent project.");
            }

            return model.getVersion();
        } finally {
            if (fileReader != null) {
                fileReader.close();
            }
        }
    } catch (Exception e) {
        throw new MojoFailureException("", e);
    }
}
 
开发者ID:aleksandr-m,项目名称:gitflow-maven-plugin,代码行数:31,代码来源:AbstractGitFlowMojo.java

示例14: 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

示例15: 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


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