本文整理汇总了Java中org.codehaus.plexus.configuration.PlexusConfiguration类的典型用法代码示例。如果您正苦于以下问题:Java PlexusConfiguration类的具体用法?Java PlexusConfiguration怎么用?Java PlexusConfiguration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PlexusConfiguration类属于org.codehaus.plexus.configuration包,在下文中一共展示了PlexusConfiguration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configureComponent
import org.codehaus.plexus.configuration.PlexusConfiguration; //导入依赖的package包/类
@Override
public void configureComponent(final Object component,
final PlexusConfiguration configuration,
final ExpressionEvaluator expressionEvaluator,
final ClassRealm containerRealm,
final ConfigurationListener listener)
throws ComponentConfigurationException {
addProjectDependenciesToClassRealm(expressionEvaluator, containerRealm);
this.converterLookup.registerConverter(new ClassRealmConverter(containerRealm));
final ObjectWithFieldsConverter converter = new ObjectWithFieldsConverter();
converter.processConfiguration(this.converterLookup, component,
containerRealm, configuration,
expressionEvaluator, listener);
}
开发者ID:Substeps,项目名称:substeps-framework,代码行数:20,代码来源:IncludeProjectDependenciesComponentConfigurator.java
示例2: write
import org.codehaus.plexus.configuration.PlexusConfiguration; //导入依赖的package包/类
private void write(PlexusConfiguration c, XMLWriter w, int depth) throws IOException {
int count = c.getChildCount();
if (count == 0) {
writeTag(c, w, depth);
} else {
w.startElement(c.getName());
writeAttributes(c, w);
for (int i = 0; i < count; i++) {
PlexusConfiguration child = c.getChild(i);
write(child, w, depth + 1);
}
w.endElement();
}
}
示例3: getConfiguration
import org.codehaus.plexus.configuration.PlexusConfiguration; //导入依赖的package包/类
/**
* @see HibernateMojo#getConfiguration()
*/
public PlexusConfiguration getConfiguration()
throws MojoExecutionException
{
try
{
// if it isn't the run goal, let's check that the goal exists
if ( !"run".equals( getGoalName() ) )
{
hibernatetool.getChild( getGoalName() );
}
return PlexusConfigurationUtils.parseHibernateTool( hibernatetool, getGoalName(), getAntClassLoader(),
session );
}
catch ( PlexusConfigurationException e )
{
throw new MojoExecutionException( "There was an error parsing the configuration", e );
}
}
示例4: convertArray
import org.codehaus.plexus.configuration.PlexusConfiguration; //导入依赖的package包/类
private static PlexusConfiguration convertArray(ModelNode configuration, ConversionContext ctx) {
ModelNode itemsSchema = ctx.currentSchema.get("items");
if (!itemsSchema.isDefined()) {
throw new IllegalArgumentException(
"No schema found for items of a list. Cannot continue with XML-to-JSON conversion.");
}
PlexusConfiguration list = new XmlPlexusConfiguration(ctx.tagName);
if (ctx.id != null) {
list.setAttribute("id", ctx.id);
}
for (ModelNode childConfig : configuration.asList()) {
ctx.tagName = "item";
ctx.currentSchema = itemsSchema;
ctx.id = null;
ctx.currentPath.push("[]");
PlexusConfiguration child = convert(childConfig, ctx);
ctx.currentPath.pop();
list.addChild(child);
}
return list;
}
示例5: testNestedSchemasConverted
import org.codehaus.plexus.configuration.PlexusConfiguration; //导入依赖的package包/类
@Test
public void testNestedSchemasConverted() throws Exception {
ModelNode topSchema = json("{\"type\": \"object\", \"properties\": {\"a\": {\"type\": \"string\"}}}");
ModelNode nestedSchema = json("{\"type\": \"boolean\"}");
Map<String, ModelNode> extensionSchemas = new HashMap<>();
extensionSchemas.put("top", topSchema);
extensionSchemas.put("top.nested", nestedSchema);
ModelNode config = json("{\"top\": {\"a\": \"kachny\", \"nested\": true}}");
PlexusConfiguration xml = SchemaDrivenJSONToXmlConverter.convertToXml(extensionSchemas, config);
assertEquals(2, xml.getChildCount());
PlexusConfiguration topXml = xml.getChild("top");
assertNotNull(topXml);
assertEquals("top", topXml.getName());
assertEquals(1, topXml.getChildCount());
assertEquals("a", topXml.getChild(0).getName());
assertEquals("kachny", topXml.getChild("a").getValue());
PlexusConfiguration nested = xml.getChild("top.nested");
assertNotNull(nested);
assertEquals(0, nested.getChildCount());
assertEquals("true", nested.getValue());
}
示例6: testOneOf
import org.codehaus.plexus.configuration.PlexusConfiguration; //导入依赖的package包/类
@Test
public void testOneOf() throws Exception {
ModelNode schema = json("{\"oneOf\": [{\"type\": \"integer\"}, {\"type\": \"number\"}, {\"type\": \"boolean\"}]}");
ModelNode json1 = json("1");
ModelNode json2 = json("1.1");
try {
SchemaDrivenJSONToXmlConverter.convert(json1, schema, "ext", null);
fail("Should not have been possible to convert using ambiguous oneOf.");
} catch (IllegalArgumentException __) {
//good
}
PlexusConfiguration xml = SchemaDrivenJSONToXmlConverter.convert(json2, schema, "ext", null);
assertNotNull(xml);
assertEquals("ext", xml.getName());
assertEquals(0, xml.getChildCount());
assertEquals("1.1", xml.getValue());
}
示例7: configurePitMojo
import org.codehaus.plexus.configuration.PlexusConfiguration; //导入依赖的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);
}
示例8: extractionOfMojoSpecificConfigurationAndMergingwithDefaultMojoConfiguration
import org.codehaus.plexus.configuration.PlexusConfiguration; //导入依赖的package包/类
@Test
public void extractionOfMojoSpecificConfigurationAndMergingwithDefaultMojoConfiguration() throws Exception {
InputStream is = getClass().getResourceAsStream("/META-INF/maven/plugin.xml");
assertNotNull(is);
PluginDescriptor pluginDescriptor = pluginDescriptorBuilder.build(new InputStreamReader(is, "UTF-8"));
String goal = merger.determineGoal("io.takari.maven.plugins.jar.Jar", pluginDescriptor);
assertEquals("We expect the goal name to be 'jar'", "jar", goal);
MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo(goal);
PlexusConfiguration defaultMojoConfiguration = mojoDescriptor.getMojoConfiguration();
System.out.println(defaultMojoConfiguration);
PlexusConfiguration configurationFromMaven = builder("configuration") //
.es("jar") //
.es("sourceJar").v("true").ee() //
.ee() //
.buildPlexusConfiguration();
PlexusConfiguration mojoConfiguration = merger.extractAndMerge(goal, configurationFromMaven, defaultMojoConfiguration);
String xml = mojoConfiguration.toString();
assertXpathEvaluatesTo("java.io.File", "/configuration/classesDirectory/@implementation", xml);
assertXpathEvaluatesTo("${project.build.outputDirectory}", "/configuration/classesDirectory/@default-value", xml);
assertXpathEvaluatesTo("java.util.List", "/configuration/reactorProjects/@implementation", xml);
assertXpathEvaluatesTo("${reactorProjects}", "/configuration/reactorProjects/@default-value", xml);
assertXpathEvaluatesTo("true", "/configuration/sourceJar", xml);
}
示例9: plexusConfigurationMerging
import org.codehaus.plexus.configuration.PlexusConfiguration; //导入依赖的package包/类
@Test
public void plexusConfigurationMerging() throws Exception {
PlexusConfiguration mojoConfigurationFromPom = builder("configuration") //
.es("sourceJar").v("true").ee() //
.buildPlexusConfiguration();
PlexusConfiguration defaultMojoConfiguration = builder("configuration") //
.entry("classesDirectory", "java.io.File", "${project.build.outputDirectory}") //
.entry("reactorProjects", "java.util.List", "${reactorProjects}") //
.entry("souceJar", "boolean", "${sourceJar") //
.buildPlexusConfiguration();
PlexusConfiguration mojoConfiguration = merger.mergePlexusConfiguration(mojoConfigurationFromPom, defaultMojoConfiguration);
String xml = mojoConfiguration.toString();
assertXpathEvaluatesTo("java.io.File", "/configuration/classesDirectory/@implementation", xml);
assertXpathEvaluatesTo("${project.build.outputDirectory}", "/configuration/classesDirectory/@default-value", xml);
assertXpathEvaluatesTo("java.util.List", "/configuration/reactorProjects/@implementation", xml);
assertXpathEvaluatesTo("${reactorProjects}", "/configuration/reactorProjects/@default-value", xml);
assertXpathEvaluatesTo("true", "/configuration/sourceJar", xml);
}
示例10: toXppDom
import org.codehaus.plexus.configuration.PlexusConfiguration; //导入依赖的package包/类
/**
* Recursively convert PLEXUS config to Xpp3Dom.
* @param config The config to convert
* @return The Xpp3Dom document
* @see #execute(String,String,Properties)
*/
private Xpp3Dom toXppDom(final PlexusConfiguration config) {
final Xpp3Dom result = new Xpp3Dom(config.getName());
result.setValue(config.getValue(null));
for (final String name : config.getAttributeNames()) {
try {
result.setAttribute(name, config.getAttribute(name));
} catch (final PlexusConfigurationException ex) {
throw new IllegalArgumentException(ex);
}
}
for (final PlexusConfiguration child : config.getChildren()) {
result.addChild(this.toXppDom(child));
}
return result;
}
示例11: fromConfiguration
import org.codehaus.plexus.configuration.PlexusConfiguration; //导入依赖的package包/类
private JdkToolchain fromConfiguration( PlexusConfiguration configuration, ExpressionEvaluator expressionEvaluator )
throws ComponentConfigurationException
{
PlexusConfiguration[] params = configuration.getChildren();
Map parameters = new HashMap();
for ( int j = 0; j < params.length; j++ )
{
try
{
String name = params[j].getName();
String val = params[j].getValue();
parameters.put( name, val );
}
catch ( PlexusConfigurationException ex )
{
throw new ComponentConfigurationException( ex );
}
}
final JdkToolchain result = new JdkToolchain();
result.setParameters( Collections.unmodifiableMap( parameters ) );
return result;
}
示例12: fromConfiguration
import org.codehaus.plexus.configuration.PlexusConfiguration; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
public Object fromConfiguration(ConverterLookup converterLookup,
PlexusConfiguration configuration, Class type, Class baseType,
ClassLoader classLoader, ExpressionEvaluator expressionEvaluator,
ConfigurationListener listener)
throws ComponentConfigurationException {
if (isPropertyEditorSupportConversion(configuration, type, baseType,
classLoader, expressionEvaluator, listener)) {
return null;
} else {
ConfigurationConverter lookupConverterForType = converterLookup
.lookupConverterForType(type);
return lookupConverterForType.fromConfiguration(converterLookup,
configuration, type, baseType, classLoader,
expressionEvaluator);
}
}
示例13: getString
import org.codehaus.plexus.configuration.PlexusConfiguration; //导入依赖的package包/类
@CheckForNull
private String getString(MavenProject pom, String parameter) {
MavenProject oldProject = session.getCurrentProject();
try {
// Switch to the project for which we try to resolve the property.
session.setCurrentProject(pom);
for (MojoExecution exec : mojoExecutions) {
Xpp3Dom configuration = exec.getConfiguration();
PlexusConfiguration pomConfiguration = new XmlPlexusConfiguration(configuration);
PlexusConfiguration config = pomConfiguration.getChild(parameter);
ExpressionEvaluator expressionEvaluator = new PluginParameterExpressionEvaluator(session, exec);
BasicStringConverter converter = new BasicStringConverter();
String value = converter.fromExpression(config, expressionEvaluator);
if (value != null) {
return value;
}
}
} catch (Exception e) {
log.warn(String.format("Failed to get parameter '%s' for goal '%s': %s", parameter, COMPILE_GOAL, e.getMessage()));
} finally {
session.setCurrentProject(oldProject);
}
return null;
}
示例14: configureComponent
import org.codehaus.plexus.configuration.PlexusConfiguration; //导入依赖的package包/类
@Override
public void configureComponent(Object component, PlexusConfiguration configuration,
ExpressionEvaluator evaluator, ClassRealm realm, ConfigurationListener listener) throws ComponentConfigurationException {
addProjectDependenciesToClassRealm(evaluator, realm);
converterLookup.registerConverter(new ClassRealmConverter(realm));
ObjectWithFieldsConverter converter = new ObjectWithFieldsConverter();
converter.processConfiguration(converterLookup, component, realm.getParentClassLoader(), configuration,
evaluator, listener);
}
开发者ID:protostuff,项目名称:protostuff-compiler,代码行数:10,代码来源:IncludeProjectDependenciesComponentConfigurator.java
示例15: configureComponent
import org.codehaus.plexus.configuration.PlexusConfiguration; //导入依赖的package包/类
public void configureComponent(Object component, PlexusConfiguration configuration,
ExpressionEvaluator expressionEvaluator, ClassRealm containerRealm, ConfigurationListener listener)
throws ComponentConfigurationException
{
addProjectDependenciesToClassRealm(expressionEvaluator, containerRealm);
converterLookup.registerConverter(new ClassRealmConverter(containerRealm));
ObjectWithFieldsConverter converter = new ObjectWithFieldsConverter();
converter.processConfiguration(converterLookup, component, containerRealm, configuration, expressionEvaluator,
listener);
}