maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From khmarba...@apache.org
Subject svn commit: r1579380 - in /maven/enforcer/trunk/enforcer-rules/src: main/java/org/apache/maven/plugins/enforcer/ReactorModuleConvergence.java site/apt/reactorModuleConvergence.apt.vm
Date Wed, 19 Mar 2014 20:15:41 GMT
Author: khmarbaise
Date: Wed Mar 19 20:15:40 2014
New Revision: 1579380

URL: http://svn.apache.org/r1579380
Log:
[MENFORCER-188]
 - Fixed missing message output.

Modified:
    maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/ReactorModuleConvergence.java
    maven/enforcer/trunk/enforcer-rules/src/site/apt/reactorModuleConvergence.apt.vm

Modified: maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/ReactorModuleConvergence.java
URL: http://svn.apache.org/viewvc/maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/ReactorModuleConvergence.java?rev=1579380&r1=1579379&r2=1579380&view=diff
==============================================================================
--- maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/ReactorModuleConvergence.java
(original)
+++ maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/ReactorModuleConvergence.java
Wed Mar 19 20:15:40 2014
@@ -33,6 +33,7 @@ import org.apache.maven.model.Dependency
 import org.apache.maven.plugin.logging.Log;
 import org.apache.maven.project.MavenProject;
 import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
+import org.codehaus.plexus.util.StringUtils;
 
 /**
  * This rule will check if a multi module build will follow the best practices.
@@ -86,6 +87,7 @@ public class ReactorModuleConvergence
         if ( !parentsWhichAreNotPartOfTheReactor.isEmpty() )
         {
             StringBuilder sb = new StringBuilder().append( SystemUtils.LINE_SEPARATOR );
+            addMessageIfExist( sb );
             for ( MavenProject mavenProject : parentsWhichAreNotPartOfTheReactor )
             {
                 sb.append( " module: " );
@@ -110,6 +112,7 @@ public class ReactorModuleConvergence
         if ( !modulesWithoutParentsInReactory.isEmpty() )
         {
             StringBuilder sb = new StringBuilder().append( SystemUtils.LINE_SEPARATOR );
+            addMessageIfExist( sb );
             for ( MavenProject mavenProject : modulesWithoutParentsInReactory )
             {
                 sb.append( " module: " );
@@ -123,7 +126,7 @@ public class ReactorModuleConvergence
     private void checkDependenciesWithinReactor( List<MavenProject> sortedProjects
)
         throws EnforcerRuleException
     {
-        //TODO: After we are sure having consistent version we can simply use the first one?
+        // After we are sure having consistent version we can simply use the first one?
         String reactorVersion = sortedProjects.get( 0 ).getVersion();
 
         Map<MavenProject, List<Dependency>> areThereDependenciesWhichAreNotPartOfTheReactor
=
@@ -131,6 +134,7 @@ public class ReactorModuleConvergence
         if ( !areThereDependenciesWhichAreNotPartOfTheReactor.isEmpty() )
         {
             StringBuilder sb = new StringBuilder().append( SystemUtils.LINE_SEPARATOR );
+            addMessageIfExist( sb );
             for ( Entry<MavenProject, List<Dependency>> item : areThereDependenciesWhichAreNotPartOfTheReactor.entrySet()
)
             {
                 sb.append( " module: " );
@@ -160,13 +164,14 @@ public class ReactorModuleConvergence
     private void checkParentsInReactor( List<MavenProject> sortedProjects )
         throws EnforcerRuleException
     {
-        //TODO: After we are sure having consistent version we can simply use the first one?
+        //After we are sure having consistent version we can simply use the first one?
         String reactorVersion = sortedProjects.get( 0 ).getVersion();
 
         List<MavenProject> areParentsFromTheReactor = areParentsFromTheReactor( reactorVersion,
sortedProjects );
         if ( !areParentsFromTheReactor.isEmpty() )
         {
             StringBuilder sb = new StringBuilder().append( SystemUtils.LINE_SEPARATOR );
+            addMessageIfExist( sb );
             for ( MavenProject mavenProject : areParentsFromTheReactor )
             {
                 sb.append( " --> " );
@@ -191,6 +196,7 @@ public class ReactorModuleConvergence
         if ( !consistenceCheckResult.isEmpty() )
         {
             StringBuilder sb = new StringBuilder().append( SystemUtils.LINE_SEPARATOR );
+            addMessageIfExist( sb );
             for ( MavenProject mavenProject : consistenceCheckResult )
             {
                 sb.append( " --> " );
@@ -287,8 +293,8 @@ public class ReactorModuleConvergence
     }
 
     /**
-     * Assume we have a module which is which is a child of a multi module build but this
child does not have a parent.
-     * This method will exactly search for such cases.
+     * Assume we have a module which is a child of a multi module build but this child does
not have a parent. This
+     * method will exactly search for such cases.
      * 
      * @param projectList The sorted list of the reactor modules.
      * @return The resulting list will contain the modules in the reactor which do not have
a parent. The list will
@@ -338,6 +344,15 @@ public class ReactorModuleConvergence
         }
     }
 
+    /**
+     * Go through the list of modules in the builds and check if we have dependencies. If
yes we will check every
+     * dependency based on groupId/artifactId if it belong to the multi module build. In
such a case it will be checked
+     * if the version does fit the version in the rest of build.
+     * 
+     * @param reactorVersion The version of the reactor.
+     * @param sortedProjects The list of existing projects within this build.
+     * @return List of violations. Never null. If the list is empty than no violation has
happened.
+     */
     private Map<MavenProject, List<Dependency>> areThereDependenciesWhichAreNotPartOfTheReactor(
String reactorVersion,
                                                                                         
        List<MavenProject> sortedProjects )
     {
@@ -389,7 +404,6 @@ public class ReactorModuleConvergence
 
         if ( projectList != null && !projectList.isEmpty() )
         {
-            //TODO: Check if this the right choice ?
             String version = projectList.get( 0 ).getVersion();
             logger.debug( "First version:" + version );
             for ( MavenProject mavenProject : projectList )
@@ -424,4 +438,18 @@ public class ReactorModuleConvergence
         this.ignoreModuleDependencies = ignoreModuleDependencies;
     }
 
+    /**
+     * This will add the given user message to the output.
+     * 
+     * @param sb The already initialized exception message part.
+     */
+    private void addMessageIfExist( StringBuilder sb )
+    {
+        if ( !StringUtils.isEmpty( getMessage() ) )
+        {
+            sb.append( getMessage() );
+            sb.append( SystemUtils.LINE_SEPARATOR );
+        }
+    }
+
 }
\ No newline at end of file

Modified: maven/enforcer/trunk/enforcer-rules/src/site/apt/reactorModuleConvergence.apt.vm
URL: http://svn.apache.org/viewvc/maven/enforcer/trunk/enforcer-rules/src/site/apt/reactorModuleConvergence.apt.vm?rev=1579380&r1=1579379&r2=1579380&view=diff
==============================================================================
--- maven/enforcer/trunk/enforcer-rules/src/site/apt/reactorModuleConvergence.apt.vm (original)
+++ maven/enforcer/trunk/enforcer-rules/src/site/apt/reactorModuleConvergence.apt.vm Wed Mar
19 20:15:40 2014
@@ -32,7 +32,7 @@ Reactor Module Convergence
 
   The following parameters are supported by this rule:
    
-  * message - an optional message to the user if the rule fails.
+  * message - an optional supplemental message to the user if the rule fails.
   
   * ignoreModuleDependencies - Ignore module dependencies which references modules within
the 
     the reactor (default: false). 



Mime
View raw message