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


Java EnforcerRuleHelper.evaluate方法代码示例

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


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

示例1: execute

import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper; //导入方法依赖的package包/类
public void execute(EnforcerRuleHelper helper) throws EnforcerRuleException {
    Log log = helper.getLog();

    List<Pattern> excludedPatterns = new ArrayList<Pattern>(excludes.size());
    for (String exclude : excludes) {
        excludedPatterns.add(Pattern.compile(exclude));
    }

    try {
        MavenProject project = (MavenProject) helper.evaluate("${project}");
        List<Artifact> artifactList = project.getAttachedArtifacts();
        for (Artifact artifact : artifactList) {
            String artifactFileName = artifact.getFile().getName();
            log.debug("evaluating artifact [" + artifactFileName + "]");
            for (Pattern pattern : excludedPatterns) {
                if (pattern.matcher(artifactFileName).matches()) {
                    throw new EnforcerRuleException("found banned attached artifact: artifact [" + artifactFileName + "] matched exclude pattern [" + pattern.toString() + "]");
                }
            }
        }

    } catch (ExpressionEvaluationException e) {
        throw new EnforcerRuleException("Unable to lookup expression", e);
    }

}
 
开发者ID:elastic,项目名称:attached-artifact-enforcer,代码行数:27,代码来源:BannedAttachedArtifacts.java

示例2: execute

import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper; //导入方法依赖的package包/类
public void execute(EnforcerRuleHelper helper) throws EnforcerRuleException {
    Log log = helper.getLog();

    try {
        // get the various expressions out of the helper.
        MavenProject project = (MavenProject) helper.evaluate("${project}");
        // MavenSession session = (MavenSession) helper.evaluate("${session}");
        // String target = (String) helper.evaluate("${project.build.directory}");
        // String artifactId = (String) helper.evaluate("${project.artifactId}");

        // ArtifactResolver resolver = (ArtifactResolver) helper.getComponent(ArtifactResolver.class);
        // RuntimeInfo rti = (RuntimeInfo) helper.getComponent(RuntimeInfo.class);
        List compileSourceRoots = project.getCompileSourceRoots();

        for (Object compileSourceRoot : compileSourceRoots) {
            String path = (String) compileSourceRoot;
            applyForJavaSourcesInRoot(path, log);
        }
    } catch (ExpressionEvaluationException e) {
        throw new EnforcerRuleException("Unable to lookup an expression " + e.getLocalizedMessage(), e);
    }
}
 
开发者ID:CloudSlang,项目名称:cloud-slang,代码行数:23,代码来源:SpringCleansingRule.java

示例3: getPropertyValue

import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper; //导入方法依赖的package包/类
/**
 * Extracted for easier testability.
 *
 * @param helper
 * @param propertyName name of the property to extract.
 * @return the value of the property.
 * @throws EnforcerRuleException
 */
Object getPropertyValue( EnforcerRuleHelper helper, final String propertyName ) throws EnforcerRuleException
{
    try
    {
        return helper.evaluate( "${" + propertyName + "}" );
    }
    catch ( ExpressionEvaluationException eee )
    {
        throw new EnforcerRuleException( "Unable to evaluate property: " + propertyName, eee );
    }
}
 
开发者ID:mojohaus,项目名称:extra-enforcer-rules,代码行数:20,代码来源:RequirePropertyDiverges.java

示例4: getMavenProject

import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper; //导入方法依赖的package包/类
/**
 * Extracted for easier testability.
 *
 * @param helper
 * @return the MavenProject enforcer is running on.
 *
 * @throws EnforcerRuleException
 */
MavenProject getMavenProject( EnforcerRuleHelper helper ) throws EnforcerRuleException
{
    try
    {
        return ( MavenProject ) helper.evaluate( "${project}" );
    }
    catch ( ExpressionEvaluationException eee )
    {
        throw new EnforcerRuleException( "Unable to get project.", eee );
    }
}
 
开发者ID:mojohaus,项目名称:extra-enforcer-rules,代码行数:20,代码来源:RequirePropertyDiverges.java

示例5: execute

import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper; //导入方法依赖的package包/类
@Override
public void execute(EnforcerRuleHelper helper) throws EnforcerRuleException {
    MavenProject project = null;
    try {
        project = (MavenProject) helper.evaluate("${project}");
    } catch (ExpressionEvaluationException eee) {
        throw new EnforcerRuleException("Unable to retrieve the MavenProject: ", eee);
    }
    root = project.getArtifact();
    super.execute(helper);
}
 
开发者ID:peiliping,项目名称:excalibur,代码行数:12,代码来源:BannedDependenciesEX.java

示例6: getMavenProject

import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper; //导入方法依赖的package包/类
private MavenProject getMavenProject(final EnforcerRuleHelper helper)
	throws EnforcerRuleException
{
	try {
		return (MavenProject) helper.evaluate("${project}");
	}
	catch (final ExpressionEvaluationException exc) {
		throw new EnforcerRuleException("Unable to get project.", exc);
	}
}
 
开发者ID:scijava,项目名称:scijava-maven-plugin,代码行数:11,代码来源:RequireElements.java

示例7: getProject

import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper; //导入方法依赖的package包/类
public static MavenProject getProject(EnforcerRuleHelper helper) throws ExpressionEvaluationException {
    return (MavenProject) helper.evaluate("${project}");
}
 
开发者ID:1and1,项目名称:ono-extra-enforcer-rules,代码行数:4,代码来源:RuleHelper.java

示例8: getSession

import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper; //导入方法依赖的package包/类
public static MavenSession getSession(EnforcerRuleHelper helper) throws ExpressionEvaluationException {
    return (MavenSession) helper.evaluate("${session}");
}
 
开发者ID:1and1,项目名称:ono-extra-enforcer-rules,代码行数:4,代码来源:RuleHelper.java

示例9: execute

import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper; //导入方法依赖的package包/类
public void execute( EnforcerRuleHelper helper )
    throws EnforcerRuleException
{
    try
    {
        if ( StringUtils.isBlank( encoding ) )
        {
            encoding = (String) helper.evaluate( "${project.build.sourceEncoding}" );
        }
        Log log = helper.getLog();
        if ( encoding.equals( StandardCharsets.US_ASCII.name() ) )
        {
            log.warn( "Encoding US-ASCII is hard to detect. Use UTF-8 or ISO-8859-1" );
        }
        String basedir = (String) helper.evaluate( "${basedir}" );
        DirectoryScanner ds = new DirectoryScanner();
        ds.setBasedir( basedir );
        if ( StringUtils.isNotBlank( includes ) )
        {
            ds.setIncludes( includes.split( "[,\\|]" ) );
        }
        if ( StringUtils.isNotBlank( excludes ) )
        {
            ds.setExcludes( excludes.split( "[,\\|]" ) );
        }
        if ( useDefaultExcludes )
        {
            ds.addDefaultExcludes();
        }
        ds.scan();
        StringBuilder filesInMsg = new StringBuilder();
        for ( String file : ds.getIncludedFiles() )
        {
            String fileEncoding = getEncoding( encoding, new File( basedir, file ), log );
            if ( log.isDebugEnabled() )
            {
                log.debug( file + "==>" + fileEncoding );
            }
            if ( fileEncoding != null && !fileEncoding.equals( encoding ) )
            {
                filesInMsg.append( file );
                filesInMsg.append( "==>" );
                filesInMsg.append( fileEncoding );
                filesInMsg.append( "\n" );
                if ( failFast )
                {
                    throw new EnforcerRuleException( filesInMsg.toString() );
                }
            }
        }
        if ( filesInMsg.length() > 0 )
        {
            throw new EnforcerRuleException( "Files not encoded in " + encoding + ":\n" + filesInMsg );
        }
    }
    catch ( IOException ex )
    {
        throw new EnforcerRuleException( "Reading Files", ex );
    }
    catch ( ExpressionEvaluationException e )
    {
        throw new EnforcerRuleException( "Unable to lookup an expression " + e.getLocalizedMessage(), e );
    }
}
 
开发者ID:mojohaus,项目名称:extra-enforcer-rules,代码行数:65,代码来源:RequireEncoding.java


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