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


Java MavenXpp3Writer类代码示例

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


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

示例1: pomFileWithDependencies

import org.apache.maven.model.io.xpp3.MavenXpp3Writer; //导入依赖的package包/类
@And("^POM file with dependencies:$")
public void pomFileWithDependencies(List<MavenDependencySpec> dependencies) throws Throwable {
  for (MavenDependencySpec dependency : dependencies) {
    dependency.setExcludes(dependency.excludes);
  }

  Model model = new Model();
  model.setModelVersion("4.0.0");
  model.setGroupId("com.example");
  model.setArtifactId("example-artifact");
  model.setVersion("1.0.0-SNAPSHOT");
  model.setPackaging("pom");
  dependencies.forEach(model::addDependency);

  Path pomFile = projectDir.resolve("pom.xml");
  new MavenXpp3Writer().write(Files.newBufferedWriter(pomFile), model);
}
 
开发者ID:bsideup,项目名称:gradle-maven-sync-plugin,代码行数:18,代码来源:GradleStepdefs.java

示例2: POMData

import org.apache.maven.model.io.xpp3.MavenXpp3Writer; //导入依赖的package包/类
public POMData(ParentData parentData, String groupId, String artifactId, String versionId,
               List<DependencyData>
        dependencies, List<RepositoryData> repositories) throws IOException {
    Model model = new Model();
    parentData.write(model);
    model.setGroupId(groupId);
    model.setArtifactId(artifactId);
    model.setVersion(versionId);
    model.setModelVersion("4.0.0");
    dependencies.forEach((dependencyData -> dependencyData.write(model)));
    repositories.forEach((repositoryData -> repositoryData.write(model)));
    this.dependencies = dependencies;
    this.repositories = repositories;
    this.groupId = groupId;
    this.artifactId = artifactId;
    this.version = versionId;
    StringWriter writer = new StringWriter();
    new MavenXpp3Writer().write(writer, model);
    this.xml = writer.toString();
}
 
开发者ID:PizzaCrust,项目名称:IodineToolkit,代码行数:21,代码来源:POMData.java

示例3: createPom

import org.apache.maven.model.io.xpp3.MavenXpp3Writer; //导入依赖的package包/类
private File createPom( File targetPath, String filename, FileMetadata fileMetadata, String groupId,
                        String artifactId, String version, String packaging )
    throws IOException
{
    Model projectModel = new Model();
    projectModel.setModelVersion( "4.0.0" );
    projectModel.setGroupId( groupId );
    projectModel.setArtifactId( artifactId );
    projectModel.setVersion( version );
    projectModel.setPackaging( packaging );

    File pomFile = new File( targetPath, filename );
    MavenXpp3Writer writer = new MavenXpp3Writer();

    try (FileWriter w = new FileWriter( pomFile ))
    {
        writer.write( w, projectModel );
    }

    return pomFile;
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:22,代码来源:DefaultFileUploadService.java

示例4: write

import org.apache.maven.model.io.xpp3.MavenXpp3Writer; //导入依赖的package包/类
public String write(Manifest manifest, ArtifactDescriptor artifact) {
    MavenXpp3Writer writer = new MavenXpp3Writer();
    Model model = new Model();

    addProjectInformation(manifest, artifact, model);
    addRequiresDependency(manifest, model);
    addArchiveDependencies(manifest, model);
    addBinaryDependencies(manifest, model);
    addRepositories(manifest, model);

    StringWriter sw = new StringWriter();
    try {
        writer.write(sw, model);
    }
    catch (IOException e) {
    }
    return sw.toString();
}
 
开发者ID:atomist-attic,项目名称:rug-resolver,代码行数:19,代码来源:ManifestPomWriter.java

示例5: generatePOM

import org.apache.maven.model.io.xpp3.MavenXpp3Writer; //导入依赖的package包/类
private static void generatePOM(Path pomFile, String groupId, String artifactId, List<String> dependencies)
        throws IOException {
    Model pom = new Model();
    pom.setModelVersion(MODEL_VERSION);

    pom.setGroupId(groupId);
    pom.setArtifactId(artifactId);
    pom.setVersion(VERSION.toString());
    pom.setPackaging("jar");
    pom.setName(artifactId + ": fabricated POM for testing");

    for (String dependency: dependencies) {
        pom.addDependency(createMavenDependency(dependency, TYPE));
        pom.addDependency(createMavenDependency(dependency, "jar"));
    }

    MavenXpp3Writer writer = new MavenXpp3Writer();
    try (OutputStream outputStream = Files.newOutputStream(pomFile)) {
        writer.write(outputStream, pom);
    }
}
 
开发者ID:cloudkeeper-project,项目名称:cloudkeeper,代码行数:22,代码来源:DummyAetherRepository.java

示例6: addDependency

import org.apache.maven.model.io.xpp3.MavenXpp3Writer; //导入依赖的package包/类
/**
 * Add the Maven dependency to the new created project
 */
private void addDependency(Model model, IMavenProjectFacade facade) {
	String latestVersion = getLatestVersion();

	Dependency dependency = new Dependency();
	dependency.setGroupId(groupId);
	dependency.setArtifactId(artifactId);
	dependency.setVersion(latestVersion);

	model.addDependency(dependency);

	try {
		FileOutputStream fos = new FileOutputStream(facade.getPomFile());
		new MavenXpp3Writer().write(fos, model);
	} catch (IOException e) {
	}
}
 
开发者ID:dice-project,项目名称:DICE-Platform,代码行数:20,代码来源:QualityTestingNewProjectWizard.java

示例7: writeEffectivePom

import org.apache.maven.model.io.xpp3.MavenXpp3Writer; //导入依赖的package包/类
/**
 * org.apache.maven.plugins.help.EffectivePomMojo#writeEffectivePom
 */
private static void writeEffectivePom(MavenProject project, XMLWriter writer)
  throws MojoExecutionException {
  Model pom = project.getModel();
  cleanModel(pom);

  String effectivePom;

  StringWriter sWriter = new StringWriter();
  MavenXpp3Writer pomWriter = new MavenXpp3Writer();
  try {
    pomWriter.write(sWriter, pom);
  }
  catch (IOException e) {
    throw new MojoExecutionException("Cannot serialize POM to XML.", e);
  }

  effectivePom = addMavenNamespace(sWriter.toString(), true);

  writeComment(writer, "Effective POM for project \'" + project.getId() + "\'");

  writer.writeMarkup(effectivePom);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:MavenEffectivePomDumper.java

示例8: testReadModel

import org.apache.maven.model.io.xpp3.MavenXpp3Writer; //导入依赖的package包/类
@Test
public void testReadModel() throws IOException {

    // PREPARE
    final String expected = IOUtils.toString(getClass()
            .getResourceAsStream("/objects4j.xml"), Charset.forName("ISO-8859-1"));

    // TEST
    final Model model = MavenPomReader
            .readModel("org.fuin:objects4j:0.6.1");

    // VERIFY
    final MavenXpp3Writer writer = new MavenXpp3Writer();
    final StringWriter sw = new StringWriter();
    writer.write(sw, model);
    assertThat(sw.toString()).isEqualTo(expected);
    assertThat(model.getName()).isEqualTo("Objects4J");
    assertThat(model.getScm()).isNotNull();
    assertThat(model.getScm().getUrl()).isEqualTo("https://github.com/fuinorg/objects4j/");
    
    

}
 
开发者ID:fuinorg,项目名称:utils4maven,代码行数:24,代码来源:MavenPomReaderTest.java

示例9: writeEffectivePom

import org.apache.maven.model.io.xpp3.MavenXpp3Writer; //导入依赖的package包/类
/**
 * method from org.apache.maven.plugins.help.EffectivePomMojo Method for writing the effective pom
 * informations of the current build.
 *
 * @param project the project of the current build, not null.
 * @param writer the XML writer , not null, not null.
 * @throws MojoExecutionException if any
 */
private static void writeEffectivePom(MavenProject project, XMLWriter writer)
    throws MojoExecutionException {
  Model pom = project.getModel();
  cleanModel(pom);

  String effectivePom;

  StringWriter sWriter = new StringWriter();
  MavenXpp3Writer pomWriter = new MavenXpp3Writer();
  try {
    pomWriter.write(sWriter, pom);
  } catch (IOException e) {
    throw new MojoExecutionException("Cannot serialize POM to XML.", e);
  }

  effectivePom = addMavenNamespace(sWriter.toString(), true);

  writeComment(writer, "Effective POM for project \'" + project.getId() + "\'");

  writer.writeMarkup(effectivePom);
}
 
开发者ID:eclipse,项目名称:che,代码行数:30,代码来源:EffectivePomWriter.java

示例10: generatePOM

import org.apache.maven.model.io.xpp3.MavenXpp3Writer; //导入依赖的package包/类
public String generatePOM(final GAV gav) {
    Model model = new Model();
    model.setGroupId(gav.getGroupId());
    model.setArtifactId(gav.getArtifactId());
    model.setVersion(gav.getVersion());
    model.setModelVersion("4.0.0");

    StringWriter stringWriter = new StringWriter();
    try {
        new MavenXpp3Writer().write(stringWriter,
                                    model);
    } catch (IOException e) {
        log.error(e.getMessage());
    }

    return stringWriter.toString();
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:18,代码来源:GuvnorM2Repository.java

示例11: generateParentPOM

import org.apache.maven.model.io.xpp3.MavenXpp3Writer; //导入依赖的package包/类
public String generateParentPOM(final GAV gav) {
    Model model = new Model();
    model.setGroupId(gav.getGroupId());
    model.setArtifactId(gav.getArtifactId());
    model.setVersion(gav.getVersion());
    model.setPackaging("pom");
    model.setModelVersion("4.0.0");

    StringWriter stringWriter = new StringWriter();
    try {
        new MavenXpp3Writer().write(stringWriter,
                                    model);
    } catch (IOException e) {
        log.error(e.getMessage());
    }

    return stringWriter.toString();
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:19,代码来源:GuvnorM2Repository.java

示例12: toString

import org.apache.maven.model.io.xpp3.MavenXpp3Writer; //导入依赖的package包/类
private String toString(final POM pom,
                        final Model model) throws IOException {
    model.setName(pom.getName());
    model.setDescription(pom.getDescription());
    model.setArtifactId(pom.getGav().getArtifactId());
    model.setModelVersion(pom.getModelVersion());

    model.setGroupId(pom.getGav().getGroupId());
    model.setVersion(pom.getGav().getVersion());

    model.setPackaging(pom.getPackaging());

    model.setParent(getParent(pom));
    model.setBuild(getBuild(pom,
                            model));
    model.setModules(getModules(pom));
    model.setRepositories(getRepositories(pom));
    new DependencyUpdater(model.getDependencies()).updateDependencies(pom.getDependencies());

    StringWriter stringWriter = new StringWriter();
    new MavenXpp3Writer().write(stringWriter,
                                model);
    return stringWriter.toString();
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:25,代码来源:POMContentHandler.java

示例13: createPom

import org.apache.maven.model.io.xpp3.MavenXpp3Writer; //导入依赖的package包/类
private Path createPom( Path targetPath, String filename, FileMetadata fileMetadata, String groupId,
                        String artifactId, String version, String packaging )
    throws IOException
{
    Model projectModel = new Model();
    projectModel.setModelVersion( "4.0.0" );
    projectModel.setGroupId( groupId );
    projectModel.setArtifactId( artifactId );
    projectModel.setVersion( version );
    projectModel.setPackaging( packaging );

    Path pomFile = targetPath.resolve( filename );
    MavenXpp3Writer writer = new MavenXpp3Writer();

    try (FileWriter w = new FileWriter( pomFile.toFile() ))
    {
        writer.write( w, projectModel );
    }

    return pomFile;
}
 
开发者ID:apache,项目名称:archiva,代码行数:22,代码来源:DefaultFileUploadService.java

示例14: generate

import org.apache.maven.model.io.xpp3.MavenXpp3Writer; //导入依赖的package包/类
@Override
public void generate() {
    logger.info("Creating the pom file {}", POM_FILE);
    File pom = new File(baseDir, POM_FILE);
    OutputStreamWriter fileWriter = null;
    try {
        fileWriter = new OutputStreamWriter(new FileOutputStream(pom), Charsets.UTF_8);
        logger.debug("Writing the generated pom file {}", POM_FILE);
        MavenXpp3Writer writer = new MavenXpp3Writer();
        writer.write(fileWriter, model);
    } catch (Exception e) {
        throw new MinnalGeneratorException("Failed while writing the pom - " + pom.getName(), e);
    } finally {
        closeStream(fileWriter);
    }
}
 
开发者ID:minnal,项目名称:minnal,代码行数:17,代码来源:PomGenerator.java

示例15: write

import org.apache.maven.model.io.xpp3.MavenXpp3Writer; //导入依赖的package包/类
public void write( Writer output, Map<String, Object> options, Model model )
    throws IOException
{
    if ( output == null )
    {
        throw new IllegalArgumentException( "output writer missing" );
    }

    if ( model == null )
    {
        throw new IllegalArgumentException( "model missing" );
    }

    try
    {
        MavenXpp3Writer w = new MavenXpp3Writer();
        w.write( output, model );
    }
    finally
    {
        IOUtil.close( output );
    }
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:24,代码来源:DefaultModelWriter.java


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