本文整理汇总了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);
}
}
示例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);
}
}
示例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 );
}
}
示例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 );
}
}
示例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);
}
示例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);
}
}
示例7: getProject
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper; //导入方法依赖的package包/类
public static MavenProject getProject(EnforcerRuleHelper helper) throws ExpressionEvaluationException {
return (MavenProject) helper.evaluate("${project}");
}
示例8: getSession
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper; //导入方法依赖的package包/类
public static MavenSession getSession(EnforcerRuleHelper helper) throws ExpressionEvaluationException {
return (MavenSession) helper.evaluate("${session}");
}
示例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 );
}
}