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


Java Xpp3DomBuilder.build方法代码示例

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


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

示例1: getEnforcerPlugin

import org.codehaus.plexus.util.xml.Xpp3DomBuilder; //导入方法依赖的package包/类
public Plugin getEnforcerPlugin(MavenProject project)
        throws MavenExecutionException {
    StringBuilder configString = new StringBuilder()
            .append("<configuration><rules>")
            .append("<requireReleaseDeps><message>No Snapshots Allowed!</message><excludes><exclude>"+project.getGroupId()+":*</exclude></excludes></requireReleaseDeps>")
            .append("</rules></configuration>");
    Xpp3Dom config = null;
    try {
        config = Xpp3DomBuilder.build(new StringReader(configString.toString()));
    } catch (XmlPullParserException | IOException ex) {
        throw new MavenExecutionException("Issue creating cofig for enforcer plugin", ex);
    }

    PluginExecution execution = new PluginExecution();
    execution.setId("no-snapshot-deps");
    execution.addGoal("enforce");
    execution.setConfiguration(config);

    Plugin result = new Plugin();
    result.setArtifactId("maven-enforcer-plugin");
    result.setVersion("1.4.1");
    result.addExecution(execution);

    return result;
}
 
开发者ID:IG-Group,项目名称:cdversion-maven-extension,代码行数:26,代码来源:Plugins.java

示例2: executePluginDef

import org.codehaus.plexus.util.xml.Xpp3DomBuilder; //导入方法依赖的package包/类
private void executePluginDef(InputStream is) throws Exception {
    Xpp3Dom pluginDef = Xpp3DomBuilder.build(is, "utf-8");
    Plugin plugin = loadPlugin(pluginDef);
    Xpp3Dom config = pluginDef.getChild("configuration");
    PluginDescriptor pluginDesc = pluginManager.loadPlugin(plugin, 
                                                           mavenProject.getRemotePluginRepositories(), 
                                                           mavenSession.getRepositorySession());
    Xpp3Dom executions = pluginDef.getChild("executions");
    
    for ( Xpp3Dom execution : executions.getChildren()) {
        Xpp3Dom goals = execution.getChild("goals");
        for (Xpp3Dom goal : goals.getChildren()) {
            MojoDescriptor desc = pluginDesc.getMojo(goal.getValue());
            pluginManager.executeMojo(mavenSession, new MojoExecution(desc, config));
        }
    }
}
 
开发者ID:apache,项目名称:karaf-boot,代码行数:18,代码来源:GenerateMojo.java

示例3: testClean

import org.codehaus.plexus.util.xml.Xpp3DomBuilder; //导入方法依赖的package包/类
@Test
public void testClean() throws Exception {

   final Xpp3Dom cleanConfig = Xpp3DomBuilder.build( SetUpMojoTest.class.getResourceAsStream( "setup-clean-mojo-config.xml" ), "UTF-8" );
   cleanConfig.getChild( "filesets" ).getChild( 0 ).getChild( "directory" ).setValue( helper.workingDir.getCanonicalPath() );

   doAnswer( new Answer<Void>() {
      @Override
      public Void answer( InvocationOnMock invocation ) throws Throwable {
         assertEquals( cleanConfig, ((MojoExecution) invocation.getArguments()[1]).getConfiguration() );
         return null;
      }
   } ).when( mojo.pluginManager ).executeMojo( eq( mojo.session ), any( MojoExecution.class ) );

   mojo.clean();
}
 
开发者ID:ZsZs,项目名称:FitNesseLauncher,代码行数:17,代码来源:SetUpMojoTest.java

示例4: testUnpack

import org.codehaus.plexus.util.xml.Xpp3DomBuilder; //导入方法依赖的package包/类
@Test
public void testUnpack() throws Exception {
   final Xpp3Dom unpackConfig = Xpp3DomBuilder.build( SetUpMojoTest.class.getResourceAsStream( "unpack-mojo-config.xml" ), "UTF-8" );
   unpackConfig.getChild( "artifactItems" ).getChild( 0 ).getChild( "outputDirectory" ).setValue( helper.workingDir.getCanonicalPath() );
   unpackConfig.getChild( "artifactItems" ).getChild( 1 ).getChild( "outputDirectory" ).setValue( helper.workingDir.getCanonicalPath() + "/FitNesseRoot/files" );

   doAnswer( new Answer<Void>() {
      @Override
      public Void answer( InvocationOnMock invocation ) throws Throwable {
         assertEquals( unpackConfig, ((MojoExecution) invocation.getArguments()[1]).getConfiguration() );
         return null;
      }
   } ).when( mojo.pluginManager ).executeMojo( eq( mojo.session ), any( MojoExecution.class ) );

   mojo.unpack();
}
 
开发者ID:ZsZs,项目名称:FitNesseLauncher,代码行数:17,代码来源:SetUpMojoTest.java

示例5: testMove

import org.codehaus.plexus.util.xml.Xpp3DomBuilder; //导入方法依赖的package包/类
@Test
public void testMove() throws Exception {

   final Xpp3Dom antrunConfig = Xpp3DomBuilder.build( SetUpMojoTest.class.getResourceAsStream( "antrun-mojo-config.xml" ), "UTF-8" );
   // Because the tmp directory differs by OS
   antrunConfig.getChild( "target" ).getChild( 0 ).setAttribute( "todir", helper.workingDir.getCanonicalPath() );
   antrunConfig.getChild( "target" ).getChild( 0 ).setAttribute( "file", helper.workingDir.getCanonicalPath() + "/" + SetUpMojo.FIT_ROOT );
   antrunConfig.getChild( "target" ).getChild( 1 ).setAttribute( "todir", helper.workingDir.getCanonicalPath() + "/" + FitNesseHelper.DEFAULT_ROOT + "/files" );
   antrunConfig.getChild( "target" ).getChild( 1 ).getChild( "fileset" ).setAttribute( "dir",
         helper.workingDir.getCanonicalPath() + "/" + FitNesseHelper.DEFAULT_ROOT + "/files/" + SetUpMojo.FIT_FILES );

   doAnswer( new Answer<Void>() {
      @Override
      public Void answer( InvocationOnMock invocation ) throws Throwable {
         assertEquals( antrunConfig, ((MojoExecution) invocation.getArguments()[1]).getConfiguration() );
         return null;
      }
   } ).when( mojo.pluginManager ).executeMojo( eq( mojo.session ), any( MojoExecution.class ) );

   mojo.move();
}
 
开发者ID:ZsZs,项目名称:FitNesseLauncher,代码行数:22,代码来源:SetUpMojoTest.java

示例6: testExecute

import org.codehaus.plexus.util.xml.Xpp3DomBuilder; //导入方法依赖的package包/类
@Test
public void testExecute() throws Exception {
   final Xpp3Dom cleanConfig = Xpp3DomBuilder.build( TearDownMojoTest.class.getResourceAsStream( "teardown-clean-mojo-config.xml" ), "UTF-8" );

   doAnswer( new Answer<Void>() {
      @Override
      public Void answer( InvocationOnMock invocation ) throws Throwable {
         assertEquals( cleanConfig, ((MojoExecution) invocation.getArguments()[1]).getConfiguration() );
         return null;
      }
   } ).when( helper.mojo.pluginManager ).executeMojo( eq( helper.mojo.session ), any( MojoExecution.class ) );

   helper.mojo.execute();

   verify( helper.mojo.pluginManager, times( 1 ) ).executeMojo( eq( helper.mojo.session ), any( MojoExecution.class ) );
}
 
开发者ID:ZsZs,项目名称:FitNesseLauncher,代码行数:17,代码来源:TearDownMojoTest.java

示例7: patchGwtModule

import org.codehaus.plexus.util.xml.Xpp3DomBuilder; //导入方法依赖的package包/类
/**
 * Patches the IDE GWT module by replacing inheritance of Full.gwt.xml by
 * Full-with-excludes.gwt.xml.
 */
private void patchGwtModule() throws XmlPullParserException, IOException {
  String gwtModuleFileRelPath = getGwtModule().replace('.', '/') + ".gwt.xml";
  Path gwtModuleFilePath = Paths.get(outputDirectory.getPath(), gwtModuleFileRelPath);

  Xpp3Dom module = Xpp3DomBuilder.build(Files.newInputStream(gwtModuleFilePath), UTF_8.name());

  for (int i = module.getChildCount() - 1; i >= 0; i--) {
    Xpp3Dom child = module.getChild(i);

    if ("inherits".equals(child.getName())) {
      String moduleName = child.getAttribute("name");

      if (moduleName.equals(fullIdeGwtModule)) {
        child.setAttribute("name", fullIdeGwtModule + FULL_IDE_GWT_MODULE_SUFFIX);
        break;
      }
    }
  }

  try (Writer writer = new StringWriter()) {
    XMLWriter xmlWriter = new PrettyPrintXMLWriter(writer);
    Xpp3DomWriter.write(xmlWriter, module);
    Files.write(gwtModuleFilePath, writer.toString().getBytes());
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:30,代码来源:ProcessExcludesMojo.java

示例8: configurePitMojo

import org.codehaus.plexus.util.xml.Xpp3DomBuilder; //导入方法依赖的package包/类
protected void configurePitMojo(final AbstractPitMojo pitMojo, final String config)
    throws Exception {
  final Xpp3Dom xpp3dom = Xpp3DomBuilder.build(new StringReader(config));
  final PlexusConfiguration pluginConfiguration = extractPluginConfiguration(
      "pitest-maven", xpp3dom);

  // default the report dir to something
  setVariableValueToObject(pitMojo, "reportsDirectory", new File("."));

  configureMojo(pitMojo, pluginConfiguration);

  final Map<String, Artifact> pluginArtifacts = new HashMap<>();
  setVariableValueToObject(pitMojo, "pluginArtifactMap", pluginArtifacts);

  setVariableValueToObject(pitMojo, "project", this.project);

  ArrayList<String> elements = new ArrayList<>();
  setVariableValueToObject(pitMojo, "additionalClasspathElements", elements);

}
 
开发者ID:hcoles,项目名称:pitest,代码行数:21,代码来源:BasePitMojoTest.java

示例9: getConfigXml

import org.codehaus.plexus.util.xml.Xpp3DomBuilder; //导入方法依赖的package包/类
private Xpp3Dom getConfigXml( final Node node )
    throws ManipulationException
{
    final String config = galleyWrapper.toXML( node.getOwnerDocument(), false )
                                       .trim();

    try
    {
        return Xpp3DomBuilder.build( new StringReader( config ) );
    }
    catch ( final XmlPullParserException | IOException e )
    {
        throw new ManipulationException(
                                         "Failed to re-parse plugin configuration into Xpp3Dom: %s\nConfig was:\n%s",
                                         e, e.getMessage(), config );
    }
}
 
开发者ID:release-engineering,项目名称:pom-manipulation-ext,代码行数:18,代码来源:DistributionEnforcingManipulator.java

示例10: testShouldOverwritePluginConfigurationSubItemsByDefault

import org.codehaus.plexus.util.xml.Xpp3DomBuilder; //导入方法依赖的package包/类
public void testShouldOverwritePluginConfigurationSubItemsByDefault()
    throws XmlPullParserException, IOException
{
    String parentConfigStr = "<configuration><items><item>one</item><item>two</item></items></configuration>";
    Xpp3Dom parentConfig = Xpp3DomBuilder.build( new StringReader( parentConfigStr ) );

    Plugin parentPlugin = createPlugin( "group", "artifact", "1", null );
    parentPlugin.setConfiguration( parentConfig );

    String childConfigStr = "<configuration><items><item>three</item></items></configuration>";
    Xpp3Dom childConfig = Xpp3DomBuilder.build( new StringReader( childConfigStr ) );

    Plugin childPlugin = createPlugin( "group", "artifact", "1", null );
    childPlugin.setConfiguration( childConfig );

    ModelUtils.mergePluginDefinitions( childPlugin, parentPlugin, true );

    Xpp3Dom result = (Xpp3Dom) childPlugin.getConfiguration();
    Xpp3Dom items = result.getChild( "items" );

    assertEquals( 1, items.getChildCount() );

    Xpp3Dom item = items.getChild( 0 );
    assertEquals( "three", item.getValue() );
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:26,代码来源:ModelUtilsTest.java

示例11: initialValue

import org.codehaus.plexus.util.xml.Xpp3DomBuilder; //导入方法依赖的package包/类
protected Map<String,String> initialValue() {
  Map<String, String> map = new HashMap<String, String>();
  ClasspathResourceMap resources = scanner.matchResource(".*[.]gwt[.]*xml")
      .scan(Thread.currentThread().getContextClassLoader());
  for (StringDataResource resource : resources.findResources("", GWT_XML_PATTERN)) {
    try {
      Xpp3Dom dom = Xpp3DomBuilder.build(resource.open(), "UTF-8");
      String rename = dom.getAttribute("rename-to");
      if (rename != null) {
        String resName = resource.getResourceName().replace('/', '.');
        resName = resName.substring(0, resName.lastIndexOf("gwt")-1);
        map.put(rename, resName);
        X_Log.trace("Found gwt module rename; ", rename," -> ",resName);
      }
    } catch (Exception e) {
      X_Log.error("Error reading xml from ",resource.getResourceName(),e
          ,"\nSet xapi.log.level=TRACE to see the faulty xml");
      X_Log.trace("Faulty xml: ",resource.readAll());
    }
  };
  return map;
}
 
开发者ID:WeTheInternet,项目名称:xapi,代码行数:23,代码来源:RemoteClasspathServiceImpl.java

示例12: findModules

import org.codehaus.plexus.util.xml.Xpp3DomBuilder; //导入方法依赖的package包/类
private void findModules(File rootFile, File f, Collection<String> into) throws FileNotFoundException,
      XmlPullParserException, IOException {
      if (f.isDirectory()) {
        for (File child : f.listFiles(gwt_xml_filter)) {
          findModules(rootFile, child, into);
        }
      } else if (f.getName().endsWith(".gwt.xml")) {
        getLog().debug("Checking for entry points in " + f);
        // try to get entry points
        Xpp3Dom dom = Xpp3DomBuilder.build(new FileReader(f));
        getLog().debug(dom.toString());
        for (Xpp3Dom entry : dom.getChildren("entry-point")) {
          String attr = entry.getAttribute("class");
          if (null != attr && attr.length() > 0) {
//            into.add(attr.substring(0,
//                attr.lastIndexOf('.', attr.lastIndexOf('.') - 1))
//                + "." + f.getName().replace(".gwt.xml", ""));
            String mod = f.getAbsolutePath().substring(rootFile.getAbsolutePath().length()+1);
            into.add(mod.replace('/', '.').replace(".gwt.xml", ""));
          }
        }
      }
    }
 
开发者ID:WeTheInternet,项目名称:xapi,代码行数:24,代码来源:CodeServerMojo.java

示例13: findModule

import org.codehaus.plexus.util.xml.Xpp3DomBuilder; //导入方法依赖的package包/类
private String findModule(File f) throws FileNotFoundException,
    XmlPullParserException, IOException {
  if (f.isDirectory()) {
    String module;
    for (File child : f.listFiles(gwt_xml_filter)) {
      module = findModule(child);
      if (module != null) {
        return module;
      }
    }
  } else if (f.getName().endsWith(".gwt.xml")) {
    getLog().debug("Checking for entry points in " + f);
    // try to get entry points
    Xpp3Dom dom = Xpp3DomBuilder.build(new FileReader(f));
    getLog().debug(dom.toString());
    for (Xpp3Dom entry : dom.getChildren("entry-point")) {
      String attr = entry.getAttribute("class");
      if (null != attr && attr.length() > 0) {
        return attr.substring(0,
            attr.lastIndexOf('.', attr.lastIndexOf('.') - 1))
            + "." + f.getName().replace(".gwt.xml", "");
      }
    }
  }
  return null;
}
 
开发者ID:WeTheInternet,项目名称:xapi,代码行数:27,代码来源:CodeServerMojo.java

示例14: readDOM

import org.codehaus.plexus.util.xml.Xpp3DomBuilder; //导入方法依赖的package包/类
/**
 * Reads a source file into DOM, defaulting to a packaged resource if the
 * source file does not already exist.
 * 
 * @param sourceFile
 *            the source file to be parsed
 * @param resourcePath
 *            the default packaged resource
 * 
 * @return the parsed DOM
 */
private Xpp3Dom readDOM(File sourceFile, String resourcePath)
		throws IOException, XmlPullParserException {
	Reader reader = null;
	try {
		if (!force && sourceFile.exists()) {
			// parse the existing source file
			reader = new FileReader(sourceFile);
		} else {
			// parse the default resource file
			URL resource = getClass().getResource(resourcePath);

			// ensure that the resourcePath can be found
			if (resource == null)
				throw new IOException("Unable to read resource: "
						+ resourcePath);

			reader = new InputStreamReader(resource.openStream());
		}
		return Xpp3DomBuilder.build(reader);
	} finally {
		IOUtil.close(reader);
	}
}
 
开发者ID:alessandroleite,项目名称:maven-jdev-plugin,代码行数:35,代码来源:JDeveloperMojo.java

示例15: asXpp3Dom

import org.codehaus.plexus.util.xml.Xpp3DomBuilder; //导入方法依赖的package包/类
public Xpp3Dom asXpp3Dom(String config) throws MavenExecutionException {
	try {
		return Xpp3DomBuilder.build(new StringReader(config));
	} catch (Exception e) {
		throw new MavenExecutionException("Error parsing config", e);
	}
}
 
开发者ID:commsen,项目名称:EM,代码行数:8,代码来源:MavenConfig.java


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