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


Java EnforcerRuleHelper.getLog方法代码示例

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


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

示例1: detectUnmanagedModules

import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper; //导入方法依赖的package包/类
private void detectUnmanagedModules(EnforcerRuleHelper helper, MavenProject project) throws ExpressionEvaluationException, EnforcerRuleException {
    Log log = helper.getLog();
    MavenSession session = RuleHelper.getSession(helper);
    List<MavenProject> projects = session.getProjects();
    ImmutableListMultimap managedDependencies = RuleHelper.getManagedDependenciesAsMap(project);

    for (MavenProject mavenProject : projects) {
        if (ruleIsDefinedInProjectOrNotModuleParent(mavenProject, log)) {
            continue;
        }
        String projectIdentifier = RuleHelper.getProjectIdentifier(mavenProject);
        if (!managedDependencies.containsKey(projectIdentifier)) {
            logHeader(log, "manage all modules");
            log.warn("unmanaged project found: " + projectIdentifier);
            failureDetected = true;
        }
    }

    if (failureDetected) {
        throw new EnforcerRuleException("Failing because of unmanaged projects");
    }
}
 
开发者ID:1and1,项目名称:ono-extra-enforcer-rules,代码行数:23,代码来源:ManageAllModulesRule.java

示例2: 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

示例3: 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

示例4: execute

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

    try {
        MavenProject currentProject = RuleHelper.getSession(helper).getCurrentProject();

        checkForSubmoduleDependencyManagement(currentProject, log);

        if (failureDetected) {
            throw new EnforcerRuleException("Failing because of forbidden dependency management in sub modules");
        }
    } catch (ExpressionEvaluationException e) {
        throw new EnforcerRuleException("Unable to lookup an expression " + e.getLocalizedMessage(), e);
    }
}
 
开发者ID:1and1,项目名称:ono-extra-enforcer-rules,代码行数:16,代码来源:ForbidDependencyManagementInSubModulesRule.java

示例5: execute

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

    try {
        MavenProject project = getProject(helper);

        checkPluginManagementDiffs(project, log);

        if (failureDetected) {
            throw new EnforcerRuleException("Failing because of overridden managed plugins");
        }
    } catch (ExpressionEvaluationException e) {
        throw new EnforcerRuleException("Unable to lookup an expression " + e.getLocalizedMessage(), e);
    }
}
 
开发者ID:1and1,项目名称:ono-extra-enforcer-rules,代码行数:16,代码来源:ForbidOverridingManagedPluginsRule.java

示例6: execute

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

    Object propValue = getPropertyValue( helper );
    checkPropValueNotBlank( propValue );

    final MavenProject project = getMavenProject( helper );
    log.debug( getRuleName() + ": checking property '" + property + "' for project " + project );

    final MavenProject parent = findDefiningParent( project );

    // fail fast if the defining parent could not be found due to a bug in the rule
    if ( parent == null )
    {
        throw new IllegalStateException( "Failed to find parent POM which defines the current rule" );
    }

    if ( project.equals( parent ) )
    {
        log.debug( getRuleName() + ": skip for property '" + property + "' as " + project + " defines rule." );
    }
    else
    {
        log.debug( "Check configuration defined in " + parent );
        if ( regex == null )
        {
            checkAgainstParentValue( project, parent, helper, propValue );
        }
        else
        {
            checkAgainstRegex( propValue );
        }
    }
}
 
开发者ID:mojohaus,项目名称:extra-enforcer-rules,代码行数:42,代码来源:RequirePropertyDiverges.java

示例7: 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

示例8: execute

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

  if (reportOnly) {
    logger.info("Flag 'reportOnly' is set. Exceptions from rule will only be reported!");
  }

  if (listMissingArtifacts) {
    logger.info("Flag 'listMissingArtifacts' is set. Transitively used artifacts are resolved.");
    initializeDependencyGraphBuilder(helper);
  }

  if (useClassesFromLastBuild) {
    logger.info("Flag 'useClassesFromLastBuild' is set. Try to use existing output folder.");
  }

  if (suppressTypesFromJavaRuntime) {
    logger.info(
      "Flag 'suppressTypesFromJavaRuntime' is set. Classes available in current Java-runtime will be ignored.");
  }

  initializeArtifactResolver(helper);

  initializeProject(helper);

  final Artifact artifact = resolveArtifact();

  // skip analyzes if the artifact has no associated file..
  if (artifact.getFile() == null) {
    logger.info("Nothing to analyze in '" + artifact.getId() + "'.");
    return;
  }

  // initialize the suppression filter
  filter = new ClassFilter(logger, suppressTypesFromJavaRuntime, regexIgnoredClasses);

  final Repository artifactClassesRepository = ArtifactRepositoryAnalyzer.analyzeArtifacts(logger,
    true,
    filter)
    .analyzeArtifacts(Collections.singleton(artifact));

  final Set<Artifact> dependencies = resolveDirectDependencies(artifact);

  final Repository dependenciesClassesRepository = ArtifactRepositoryAnalyzer.analyzeArtifacts(logger,
    false,
    filter)
    .analyzeArtifacts(dependencies);

  if (logger.isDebugEnabled()) {
    logger.debug("Artifact's type dependencies are: " + artifactClassesRepository.getDependencies());
    logger.debug("Classes defined in direct dependencies are: " + dependenciesClassesRepository.getTypes());
  }

  final Set<String> unresolvedTypes = new HashSet<String>(artifactClassesRepository.getDependencies());
  unresolvedTypes.removeAll(artifactClassesRepository.getTypes());
  unresolvedTypes.removeAll(dependenciesClassesRepository.getTypes());

  // traverse transitive dependencies to find the artifact a certain class is loaded from
  if (unresolvedTypes.isEmpty()) {
    logger.info("No illegal transitive dependencies found in '" + artifact.getId() + "'.");
  } else {
    final String message = buildOutput(artifact, unresolvedTypes);

    writeOutputFile(artifact, message);

    if (reportOnly) {
      logger.error(message);
    } else {
      throw new EnforcerRuleException(message);
    }
  }
}
 
开发者ID:ImmobilienScout24,项目名称:illegal-transitive-dependency-check,代码行数:74,代码来源:IllegalTransitiveDependencyCheck.java


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