• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java EnforcerRuleException类的典型用法和代码示例

java 10次浏览

本文整理汇总了Java中org.apache.maven.enforcer.rule.api.EnforcerRuleException的典型用法代码示例。如果您正苦于以下问题:Java EnforcerRuleException类的具体用法?Java EnforcerRuleException怎么用?Java EnforcerRuleException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

EnforcerRuleException类属于org.apache.maven.enforcer.rule.api包,在下文中一共展示了EnforcerRuleException类的38个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testFiles

点赞 3

import org.apache.maven.enforcer.rule.api.EnforcerRuleException; //导入依赖的package包/类
private void testFiles(
        boolean expected,
        int expectedFaultyFilesAmount,
        @Nonnull String encoding,
        @Nonnull String dir,
        @Nonnull String includeRegex,
        @Nonnull String excludeRegex
) {
    boolean isValid;
    CharacterSetEncodingRule rule = new CharacterSetEncodingRule();
    rule.setRequireEncoding(encoding);
    rule.setDirectory(dir);
    rule.setIncludeRegex(includeRegex);
    rule.setExcludeRegex(excludeRegex);
    try {
        EnforcerRuleHelper helper = EnforcerTestUtils.getHelper();
        rule.execute(helper);
        isValid = true;
    } catch (EnforcerRuleException e) {
        // e.printStackTrace();
        isValid = false;
    }
    assertTrue(isValid == expected && rule.getFaultyFiles().size() == expectedFaultyFilesAmount);
}
 

开发者ID:mikkoi,
项目名称:maven-enforcer-char-set-encoding,
代码行数:25,
代码来源:TestCharacterSetEncodingRule.java

示例2: detectUnmanagedModules

点赞 3

import org.apache.maven.enforcer.rule.api.EnforcerRuleException; //导入依赖的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

示例3: handleArtifacts

点赞 3

import org.apache.maven.enforcer.rule.api.EnforcerRuleException; //导入依赖的package包/类
@Override
protected void handleArtifacts( Set<Artifact> artifacts )
    throws EnforcerRuleException
{
    computeParameters();

    // look for banned dependencies
    Set<Artifact> foundExcludes = checkDependencies( filterArtifacts( artifacts ), getLog() );

    // if any are found, fail the check but list all of them
    if ( foundExcludes != null && !foundExcludes.isEmpty() )
    {
        StringBuilder buf = new StringBuilder();
        if ( message != null )
        {
            buf.append( message + "\n" );
        }
        for ( Artifact artifact : foundExcludes )
        {
            buf.append( getErrorMessage( artifact ) );
        }
        message = buf.toString() + "Use 'mvn dependency:tree' to locate the source of the banned dependencies.";

        throw new EnforcerRuleException( message );
    }
}
 

开发者ID:mojohaus,
项目名称:extra-enforcer-rules,
代码行数:27,
代码来源:EnforceBytecodeVersion.java

示例4: checkDependencies

点赞 3

import org.apache.maven.enforcer.rule.api.EnforcerRuleException; //导入依赖的package包/类
protected Set<Artifact> checkDependencies( Set<Artifact> dependencies, Log log )
    throws EnforcerRuleException
{
    long beforeCheck = System.currentTimeMillis();
    Set<Artifact> problematic = new LinkedHashSet<Artifact>();
    for ( Iterator<Artifact> it = dependencies.iterator(); it.hasNext(); )
    {
        Artifact artifact = it.next();
        getLog().debug( "Analyzing artifact " + artifact );
        String problem = isBadArtifact( artifact );
        if ( problem != null )
        {
            getLog().info( problem );
            problematic.add( artifact );
        }
    }
    getLog().debug( "Bytecode version analysis took " + ( System.currentTimeMillis() - beforeCheck ) + " ms" );
    return problematic;
}
 

开发者ID:mojohaus,
项目名称:extra-enforcer-rules,
代码行数:20,
代码来源:EnforceBytecodeVersion.java

示例5: checkAgainstParentValue

点赞 3

import org.apache.maven.enforcer.rule.api.EnforcerRuleException; //导入依赖的package包/类
/**
 * Checks the value of the project against the one given in the defining ancestor project.
 *
 * @param project
 * @param parent
 * @param helper
 * @param propValue
 * @throws EnforcerRuleException
 */
void checkAgainstParentValue( final MavenProject project, final MavenProject parent, EnforcerRuleHelper helper,
        Object propValue ) throws EnforcerRuleException
{
    final StringBuilder parentHierarchy = new StringBuilder( "project." );
    MavenProject needle = project;
    while ( !needle.equals( parent ) )
    {
        parentHierarchy.append( "parent." );
        needle = needle.getParent();
    }
    final String propertyNameInParent = property.replace( "project.", parentHierarchy.toString() );
    Object parentValue = getPropertyValue( helper, propertyNameInParent );
    if ( propValue.equals( parentValue ) )
    {
        final String errorMessage = createResultingErrorMessage( String.format(
                "Property '%s' evaluates to '%s'. This does match '%s' from parent %s",
                property, propValue, parentValue, parent ) );
        throw new EnforcerRuleException( errorMessage );
    }
}
 

开发者ID:mojohaus,
项目名称:extra-enforcer-rules,
代码行数:30,
代码来源:RequirePropertyDiverges.java

示例6: checkValidRoles

点赞 3

import org.apache.maven.enforcer.rule.api.EnforcerRuleException; //导入依赖的package包/类
private void checkValidRoles( final Set<String> requiredRolesSet, final Set<String> rolesFromProject )
    throws EnforcerRuleException
{
    final Set<String> copyOfRolesFromProject = new LinkedHashSet<String>(rolesFromProject); 
    final Set<String> allowedRoles = getRolesFromString( validRoles );
    if ( !allowedRoles.contains( "*" ) )
    {
        allowedRoles.addAll( requiredRolesSet );

        // results in invalid roles
        copyOfRolesFromProject.removeAll( allowedRoles );
        if ( copyOfRolesFromProject.size() > 0 )
        {
            final String message = String.format( "Found invalid %s role(s) '%s'", getRoleName(), copyOfRolesFromProject );
            throw new EnforcerRuleException( message );
        }
    }
}
 

开发者ID:mojohaus,
项目名称:extra-enforcer-rules,
代码行数:19,
代码来源:AbstractRequireRoles.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)