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


Java PlexusConfiguration.getAttribute方法代码示例

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


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

示例1: checkTargetName

import org.codehaus.plexus.configuration.PlexusConfiguration; //导入方法依赖的package包/类
public String checkTargetName(PlexusConfiguration antTargetConfig)
        throws PlexusConfigurationException {
    String target_name = antTargetConfig.getAttribute("name");
    if (target_name == null) {
        target_name = DEFAULT_ANT_TARGET_NAME;
    }
    return target_name;
}
 
开发者ID:0xC70FF3,项目名称:java-gems,代码行数:9,代码来源:DebianMojo.java

示例2: setDestinationDirectory

import org.codehaus.plexus.configuration.PlexusConfiguration; //导入方法依赖的package包/类
private static void setDestinationDirectory( PlexusConfiguration task, PlexusConfiguration goal,
                                             PlexusConfiguration target, MavenSession session,
                                             HibernateExpressionEvaluator evaluator )
    throws PlexusConfigurationException
{
    // first let's find out where is the destination directory
    String destdir = goal.getAttribute( "destdir" );
    if ( destdir == null )
    {
        destdir = task.getAttribute( "destdir" );
    }
    if ( destdir == null )
    {
        destdir = PropertyUtils.getProperty( goal.getName() + ".destdir" );
    }
    destdir = evaluator.evaluateString( destdir );

    // let's see it the destination directory needs to be added to sources
    if ( "true".equals( PropertyUtils.getProperty( goal.getName() + ".addtosource" ) ) )
    {
        session.getCurrentProject().addCompileSourceRoot( destdir );
    }

    // create the directory
    XmlPlexusConfiguration mkdir = new XmlPlexusConfiguration( "mkdir" );
    mkdir.setAttribute( "dir", destdir );
    target.addChild( mkdir );

    // and add it to the task
    ( (XmlPlexusConfiguration) task ).setAttribute( "destdir", destdir );
}
 
开发者ID:frincon,项目名称:openeos,代码行数:32,代码来源:PlexusConfigurationUtils.java

示例3: convert

import org.codehaus.plexus.configuration.PlexusConfiguration; //导入方法依赖的package包/类
public static Xpp3Dom convert( MojoDescriptor mojoDescriptor )
{
    Xpp3Dom dom = new Xpp3Dom( "configuration" );

    PlexusConfiguration c = mojoDescriptor.getMojoConfiguration();

    PlexusConfiguration[] ces = c.getChildren();

    if ( ces != null )
    {
        for ( PlexusConfiguration ce : ces )
        {
            String value = ce.getValue( null );
            String defaultValue = ce.getAttribute( "default-value", null );
            if ( value != null || defaultValue != null )
            {
                Xpp3Dom e = new Xpp3Dom( ce.getName() );
                e.setValue( value );
                if ( defaultValue != null )
                {
                    e.setAttribute( "default-value", defaultValue );
                }
                dom.addChild( e );
            }
        }
    }

    return dom;
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:30,代码来源:MojoDescriptorCreator.java

示例4: execute

import org.codehaus.plexus.configuration.PlexusConfiguration; //导入方法依赖的package包/类
public static void execute(WebSphereModel model, PlexusConfiguration target, MavenProject project,
                           MavenProjectHelper projectHelper, List<Artifact> pluginArtifact, Log logger)
    throws IOException, MojoExecutionException {
  // The fileName should probably use the plugin executionId instead of the targetName
  boolean useDefaultTargetName = false;
  String antTargetName = target.getAttribute("name");
  if (null == antTargetName) {
    antTargetName = DEFAULT_ANT_TARGET_NAME;
    useDefaultTargetName = true;
  }
  StringBuilder fileName = new StringBuilder(50);
  fileName.append("build");
  if (StringUtils.isNotBlank(model.getHost())) {
    fileName.append("-").append(model.getHost());
  }
  if (StringUtils.isNotBlank(model.getApplicationName())) {
    fileName.append("-").append(model.getApplicationName());
  }
  fileName.append("-").append(antTargetName).append("-").append(CommandUtils.getTimestampString()).append(".xml");
  File buildFile = getBuildFile(project, fileName.toString());

  if (model.isVerbose()) {
    logger.info("ant fileName: " + fileName);
  }

  if (buildFile.exists()) {
    logger.info("[SKIPPED] already executed");
    return;
  }

  StringWriter writer = new StringWriter();
  AntXmlPlexusConfigurationWriter xmlWriter = new AntXmlPlexusConfigurationWriter();
  xmlWriter.write(target, writer);

  StringBuffer antXML = writer.getBuffer();

  if (useDefaultTargetName) {
    stringReplace(antXML, "<target", "<target name=\"" + antTargetName + "\"");
  }

  final String xmlHeader = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n";
  antXML.insert(0, xmlHeader);
  final String projectOpen = "<project name=\"" + Constants.PLUGIN_ID + "\" default=\"" + antTargetName + "\">\n";
  int index = antXML.indexOf("<target");
  antXML.insert(index, projectOpen);

  final String projectClose = "\n</project>";
  antXML.append(projectClose);

  buildFile.getParentFile().mkdirs();
  FileUtils.fileWrite(buildFile.getAbsolutePath(), "UTF-8", antXML.toString());

  Project antProject = generateAntProject(model, buildFile, project, projectHelper, pluginArtifact, logger);
  antProject.executeTarget(antTargetName);
}
 
开发者ID:orctom,项目名称:was-maven-plugin,代码行数:56,代码来源:AntTaskUtils.java

示例5: validateParameters

import org.codehaus.plexus.configuration.PlexusConfiguration; //导入方法依赖的package包/类
private void validateParameters( MojoDescriptor mojoDescriptor, PlexusConfiguration configuration,
                                 ExpressionEvaluator expressionEvaluator )
    throws ComponentConfigurationException, PluginParameterException
{
    if ( mojoDescriptor.getParameters() == null )
    {
        return;
    }

    List<Parameter> invalidParameters = new ArrayList<Parameter>();

    for ( Parameter parameter : mojoDescriptor.getParameters() )
    {
        if ( !parameter.isRequired() )
        {
            continue;
        }

        Object value = null;

        PlexusConfiguration config = configuration.getChild( parameter.getName(), false );
        if ( config != null )
        {
            String expression = config.getValue( null );

            try
            {
                value = expressionEvaluator.evaluate( expression );

                if ( value == null )
                {
                    value = config.getAttribute( "default-value", null );
                }
            }
            catch ( ExpressionEvaluationException e )
            {
                String msg =
                    "Error evaluating the expression '" + expression + "' for configuration value '"
                        + configuration.getName() + "'";
                throw new ComponentConfigurationException( configuration, msg, e );
            }
        }

        if ( value == null && ( config == null || config.getChildCount() <= 0 ) )
        {
            invalidParameters.add( parameter );
        }
    }

    if ( !invalidParameters.isEmpty() )
    {
        throw new PluginParameterException( mojoDescriptor, invalidParameters );
    }
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:55,代码来源:DefaultMavenPluginManager.java


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