You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mf...@apache.org on 2015/05/02 22:10:08 UTC

svn commit: r1677346 - in /maven/enforcer/trunk/maven-enforcer-plugin/src: it/projects/never-fail-on-recommendations/ main/java/org/apache/maven/plugins/enforcer/ main/resources/META-INF/m2e/

Author: mfriedenhagen
Date: Sat May  2 20:10:08 2015
New Revision: 1677346

URL: http://svn.apache.org/r1677346
Log:
Start to revert MENFORCER-159 as it is superceded by MENFORCER-160.

Unfortunately the patches for both issues were merged, but using levels
is the recommended way, so remove the goal recommend.

Removed:
    maven/enforcer/trunk/maven-enforcer-plugin/src/it/projects/never-fail-on-recommendations/
    maven/enforcer/trunk/maven-enforcer-plugin/src/main/java/org/apache/maven/plugins/enforcer/RecommendMojo.java
Modified:
    maven/enforcer/trunk/maven-enforcer-plugin/src/main/java/org/apache/maven/plugins/enforcer/AbstractEnforceMojo.java
    maven/enforcer/trunk/maven-enforcer-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml

Modified: maven/enforcer/trunk/maven-enforcer-plugin/src/main/java/org/apache/maven/plugins/enforcer/AbstractEnforceMojo.java
URL: http://svn.apache.org/viewvc/maven/enforcer/trunk/maven-enforcer-plugin/src/main/java/org/apache/maven/plugins/enforcer/AbstractEnforceMojo.java?rev=1677346&r1=1677345&r2=1677346&view=diff
==============================================================================
--- maven/enforcer/trunk/maven-enforcer-plugin/src/main/java/org/apache/maven/plugins/enforcer/AbstractEnforceMojo.java (original)
+++ maven/enforcer/trunk/maven-enforcer-plugin/src/main/java/org/apache/maven/plugins/enforcer/AbstractEnforceMojo.java Sat May  2 20:10:08 2015
@@ -101,133 +101,6 @@ public abstract class AbstractEnforceMoj
     }
 
     /**
-     * Entry point to the mojo
-     * 
-     * @throws MojoExecutionException
-     */
-    public void execute()
-        throws MojoExecutionException
-    {
-        Log log = this.getLog();
-        EnforcerExpressionEvaluator evaluator = new EnforcerExpressionEvaluator( session, translator, project,
-                                                                                 mojoExecution );
-        // the entire execution can be easily skipped
-        if ( !skip )
-        {
-            // list to store exceptions
-            List<String> list = new ArrayList<String>();
-            // make sure the rules exist
-            if ( getRules() != null && getRules().length > 0 )
-            {
-                String currentRule = "Unknown";
-                // create my helper
-                EnforcerRuleHelper helper = new DefaultEnforcementRuleHelper( session, evaluator, log, container );
-                // if we are only warning, then disable
-                // failFast
-                if ( !isFail() )
-                {
-                    setFailFast( false );
-                }
-                // go through each rule
-                for ( int i = 0; i < getRules().length; i++ )
-                {
-                    // prevent against empty rules
-                    EnforcerRule rule = getRules()[i];
-                    if ( rule != null )
-                    {
-                        // store the current rule for
-                        // logging purposes
-                        currentRule = rule.getClass().getName();
-                        log.debug( "Executing rule: " + currentRule );
-                        try
-                        {
-                            if ( ignoreCache || shouldExecute( rule ) )
-                            {
-                                // execute the rule
-                                // noinspection SynchronizationOnLocalVariableOrMethodParameter
-                                synchronized ( rule )
-                                {
-                                    rule.execute( helper );
-                                }
-                            }
-                        }
-                        catch ( EnforcerRuleException e )
-                        {
-                            // i can throw an exception
-                            // because failfast will be
-                            // false if fail is false.
-                            if ( isFailFast() )
-                            {
-                                throw new MojoExecutionException( currentRule + " failed with message:\n"
-                                    + e.getMessage(), e );
-                            }
-                            else
-                            {
-                                list.add( createRuleMessage( i, currentRule, e ) );
-                                log.debug( "Adding failure due to exception", e );
-                            }
-                        }
-                    }
-                }
-                // if we found anything
-                if ( !list.isEmpty() )
-                {
-                    for ( String failure : list )
-                    {
-                        log.warn( failure );
-                    }
-                    if ( isFail() )
-                    {
-                        // CHECKSTYLE_OFF: LineLength
-                        throw new MojoExecutionException(
-                                                          "Some Enforcer rules have failed. Look above for specific messages explaining why the rule failed." );
-                        // CHECKSTYLE_ON: LineLength
-                    }
-                }
-            }
-            else
-            {
-                // CHECKSTYLE_OFF: LineLength
-                throw new MojoExecutionException(
-                                                  "No rules are configured. Use the skip flag if you want to disable execution." );
-                // CHECKSTYLE_ON: LineLength
-            }
-        }
-        else
-        {
-            log.info( "Skipping Rule Enforcement." );
-        }
-    }
-
-    /**
-     * This method determines if a rule should execute based on the cache
-     *
-     * @param rule the rule to verify
-     * @return {@code true} if rule should be executed, otherwise {@code false}
-     */
-    protected boolean shouldExecute( EnforcerRule rule )
-    {
-        if ( rule.isCacheable() )
-        {
-            Log log = this.getLog();
-            log.debug( "Rule " + rule.getClass().getName() + " is cacheable." );
-            String key = rule.getClass().getName() + " " + rule.getCacheId();
-            if ( EnforceMojo.cache.containsKey( key ) )
-            {
-                log.debug( "Key " + key + " was found in the cache" );
-                if ( rule.isResultValid( (EnforcerRule) cache.get( key ) ) )
-                {
-                    log.debug( "The cached results are still valid. Skipping the rule: " + rule.getClass().getName() );
-                    return false;
-                }
-            }
-            // add it to the cache of executed rules
-            EnforceMojo.cache.put( key, rule );
-        }
-        return true;
-    }
-
-    /**
      * @return the fail
      */
     public abstract boolean isFail();

Modified: maven/enforcer/trunk/maven-enforcer-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml
URL: http://svn.apache.org/viewvc/maven/enforcer/trunk/maven-enforcer-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml?rev=1677346&r1=1677345&r2=1677346&view=diff
==============================================================================
--- maven/enforcer/trunk/maven-enforcer-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml (original)
+++ maven/enforcer/trunk/maven-enforcer-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml Sat May  2 20:10:08 2015
@@ -25,7 +25,6 @@
       <pluginExecutionFilter>
         <goals>
           <goal>enforce</goal>
-          <goal>recommend</goal>
         </goals>
       </pluginExecutionFilter>
       <action>