public void execute( EnforcerRuleHelper theHelper )
        throws EnforcerRuleException
    {
        List<String> missingProfiles = new ArrayList<String>();
        try
        {
            MavenProject project = (MavenProject) theHelper.evaluate( "${project}" );
            if ( StringUtils.isNotEmpty( profiles ) )
            {
                String[] profs = profiles.split( "," );
                for ( String profile : profs )
                {
                    if ( !isProfileActive( project, profile ) )
                    {
                        missingProfiles.add( profile );
                    }
                }

                boolean fail = false;
                if ( !missingProfiles.isEmpty() )
                {
                    fail = true;
                    // if (all && missingProfiles.size() != profs.length)
                    // {
                    // fail = true;
                    // }
                    // else
                    // {
                    // if (!all && missingProfiles.size() >= (profs.length -1))
                    // {
                    // fail = true;
                    // }
                    // }
                }

                if ( fail )
                {
                    String message = getMessage();
                    StringBuilder buf = new StringBuilder();
                    if ( message != null )
                    {
                        buf.append( message + "\n" );
                    }

                    for ( String profile : missingProfiles )
                    {
                        buf.append( "Profile \"" + profile + "\" is not activated.\n" );
                    }

                    throw new EnforcerRuleException( buf.toString() );
                }

            }

        }
        catch ( ExpressionEvaluationException e )
        {
            throw new EnforcerRuleException( "Unable to retrieve the project.", e );
        }

    }
public void execute ( EnforcerRuleHelper theHelper ) throws EnforcerRuleException { List < String > missingProfiles = new ArrayList < String > ( ) ; try { MavenProject project = ( MavenProject ) theHelper . evaluate ( "${project}" ) ; if ( StringUtils . isNotEmpty ( profiles ) ) { String [ ] profs = profiles . split ( "," ) ; for ( String profile : profs ) { if ( ! isProfileActive ( project , profile ) ) { missingProfiles . add ( profile ) ; } } boolean fail = false ; if ( ! missingProfiles . isEmpty ( ) ) { fail = true ; } if ( fail ) { String message = getMessage ( ) ; StringBuilder buf = new StringBuilder ( ) ; if ( message != null ) { buf . append ( message + "\n" ) ; } for ( String profile : missingProfiles ) { buf . append ( "Profile \"" + profile + "\" is not activated.\n" ) ; } throw new EnforcerRuleException ( buf . toString ( ) ) ; } } } catch ( ExpressionEvaluationException e ) { throw new EnforcerRuleException ( "Unable to retrieve the project." , e ) ; } }
/*
(non-Javadoc)

@see org.apache.maven.enforcer.rule.api.EnforcerRule#execute(org.apache.maven.enforcer.rule.api.EnforcerRuleHelper)