Author: khmarbaise
Date: Wed Dec 30 11:46:21 2015
New Revision: 1722317

URL: http://svn.apache.org/viewvc?rev=1722317&view=rev
Log:
Upgraded to Maven 3 and reformatted code.

Modified:
    maven/shared/trunk/maven-project-utils/pom.xml
    
maven/shared/trunk/maven-project-utils/src/main/java/org/apache/maven/shared/project/utils/ProjectUtils.java
    
maven/shared/trunk/maven-project-utils/src/main/java/org/apache/maven/shared/project/utils/ScmUtils.java
    
maven/shared/trunk/maven-project-utils/src/main/java/org/apache/maven/shared/project/utils/SiteUtils.java
    
maven/shared/trunk/maven-project-utils/src/test/java/org/apache/maven/shared/project/utils/ProjectUtilsTest.java
    
maven/shared/trunk/maven-project-utils/src/test/java/org/apache/maven/shared/project/utils/ScmUtilsTest.java

Modified: maven/shared/trunk/maven-project-utils/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/shared/trunk/maven-project-utils/pom.xml?rev=1722317&r1=1722316&r2=1722317&view=diff
==============================================================================
--- maven/shared/trunk/maven-project-utils/pom.xml (original)
+++ maven/shared/trunk/maven-project-utils/pom.xml Wed Dec 30 11:46:21 2015
@@ -26,7 +26,7 @@ under the License.
   <parent>
     <groupId>org.apache.maven.shared</groupId>
     <artifactId>maven-shared-components</artifactId>
-    <version>21</version>
+    <version>22</version>
     
<relativePath>../../pom/maven/maven-shared-components/pom.xml</relativePath>
   </parent>
 
@@ -55,7 +55,7 @@ under the License.
   </distributionManagement>
 
   <properties>
-    <mavenVersion>2.2.1</mavenVersion>
+    <mavenVersion>3.0</mavenVersion>
   </properties>
 
   <dependencies>
@@ -65,11 +65,6 @@ under the License.
       <version>${mavenVersion}</version>
     </dependency>
     <dependency>
-      <groupId>org.apache.maven</groupId>
-      <artifactId>maven-project</artifactId>
-      <version>${mavenVersion}</version>
-    </dependency>
-    <dependency>
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-model</artifactId>
       <version>${mavenVersion}</version>

Modified: 
maven/shared/trunk/maven-project-utils/src/main/java/org/apache/maven/shared/project/utils/ProjectUtils.java
URL: 
http://svn.apache.org/viewvc/maven/shared/trunk/maven-project-utils/src/main/java/org/apache/maven/shared/project/utils/ProjectUtils.java?rev=1722317&r1=1722316&r2=1722317&view=diff
==============================================================================
--- 
maven/shared/trunk/maven-project-utils/src/main/java/org/apache/maven/shared/project/utils/ProjectUtils.java
 (original)
+++ 
maven/shared/trunk/maven-project-utils/src/main/java/org/apache/maven/shared/project/utils/ProjectUtils.java
 Wed Dec 30 11:46:21 2015
@@ -42,7 +42,7 @@ public final class ProjectUtils
 {
     // This instance is often used, including in recursive methods, so 
initiate it for general usage
     private static final MavenXpp3Reader POM_READER = new MavenXpp3Reader();
-    
+
     private ProjectUtils()
     {
     }
@@ -91,7 +91,7 @@ public final class ProjectUtils
         {
             return null;
         }
-        
+
         MavenProject current = project;
 
         while ( !isRootProject( current ) )
@@ -104,15 +104,14 @@ public final class ProjectUtils
 
     /**
      * Return {@code true} if this project has modules, but is 
<strong>never</strong> the parent of one of them.<br/>
-     * 
      * Return {@code false} if this project has no modules, or if 1 or more 
modules have this project as its parent.
      * 
      * @param project
-     * @return {@code true} if project is an aggregator, {@code false} if 
project is standalone or hybrid 
+     * @return {@code true} if project is an aggregator, {@code false} if 
project is standalone or hybrid
      */
     public static boolean isAggregator( MavenProject project )
     {
-     // (not) being an aggregator must never depend on reactor projects or 
active profiles
+        // (not) being an aggregator must never depend on reactor projects or 
active profiles
         Set<String> modules = getAllModules( project ).keySet();
 
         if ( modules.isEmpty() )
@@ -149,23 +148,24 @@ public final class ProjectUtils
         return true;
     }
 
-    private static Model readModel( File moduleFile ) throws IOException, 
XmlPullParserException
+    private static Model readModel( File moduleFile )
+        throws IOException, XmlPullParserException
     {
         FileReader moduleReader = null;
-        
+
         Model model = null;
-        
+
         try
         {
             moduleReader = new FileReader( moduleFile );
-            
+
             model = POM_READER.read( moduleReader );
         }
         finally
         {
             IOUtil.close( moduleReader );
         }
-        
+
         return model;
     }
 
@@ -173,11 +173,11 @@ public final class ProjectUtils
     {
         return getModuleFile( project.getBasedir(), module );
     }
-    
+
     private static File getModuleFile( File basedir, String module )
     {
         File moduleFile = new File( basedir, module );
-        
+
         if ( moduleFile.isDirectory() )
         {
             moduleFile = new File( moduleFile, "pom.xml" );
@@ -185,7 +185,6 @@ public final class ProjectUtils
         return moduleFile;
     }
 
-    
     /**
      * Returns all modules of a project, including does specified in profiles, 
both active and inactive. The key of the
      * returned Map is the name of the module, the value refers to the source 
of the module (the project or a specific
@@ -197,14 +196,14 @@ public final class ProjectUtils
     public static Map<String, String> getAllModules( MavenProject project )
     {
         Model model = project.getModel();
-        
+
         return getAllModules( model );
     }
 
     private static Map<String, String> getAllModules( Model model )
     {
         Map<String, String> modules = new LinkedHashMap<String, String>();
-        
+
         for ( String module : model.getModules() )
         {
             modules.put( module, "project" ); // id?
@@ -217,10 +216,10 @@ public final class ProjectUtils
                 modules.put( module, "profile(id:" + profile.getId() + ")" );
             }
         }
-        
+
         return Collections.unmodifiableMap( modules );
     }
-    
+
     /**
      * Returns the upper most folder of this projects and all of its 
descendants (i.e. modules, their modules, etc.).
      * 
@@ -233,7 +232,7 @@ public final class ProjectUtils
         {
             return null;
         }
-        
+
         try
         {
             return getJoinedFolder( project.getBasedir(), project.getModel() );
@@ -248,29 +247,29 @@ public final class ProjectUtils
             // TODO Auto-generated catch block
             e.printStackTrace();
         }
-        
-        return null; //@todo fix exception handling
+
+        return null; // @todo fix exception handling
     }
-    
+
     private static File getJoinedFolder( File baseDirectory, Model model )
         throws IOException, XmlPullParserException
     {
         File joinedFolder = baseDirectory;
-        
+
         for ( String module : getAllModules( model ).keySet() )
         {
             File moduleFile = getModuleFile( baseDirectory, module );
-            
+
             Model submodel = readModel( moduleFile );
-            
+
             File modulesJoinedFolder = getJoinedFolder( 
moduleFile.getParentFile(), submodel );
-            
+
             joinedFolder = getJoinedFolder( joinedFolder, modulesJoinedFolder 
);
         }
-        
+
         return joinedFolder;
     }
-    
+
     // Don't make this method public, it has nothing to do with a MavenProject.
     // If required on more places, create a separate Utils-class
     protected static File getJoinedFolder( File lhs, File rhs )
@@ -278,33 +277,33 @@ public final class ProjectUtils
         File joinedFolder = null;
 
         Stack<File> lhsStack = new Stack<File>();
-        
+
         File lhsAncestor = lhs;
-        
+
         while ( lhsAncestor != null )
         {
             lhsAncestor = lhsStack.push( lhsAncestor ).getParentFile();
         }
 
         Stack<File> rhsStack = new Stack<File>();
-        
+
         File rhsAncestor = rhs;
-        
+
         while ( rhsAncestor != null )
         {
             rhsAncestor = rhsStack.push( rhsAncestor ).getParentFile();
         }
-        
+
         while ( !lhsStack.isEmpty() && !rhsStack.isEmpty() )
         {
             File nextFile = lhsStack.pop();
-            
+
             if ( nextFile.isDirectory() && nextFile.equals( rhsStack.pop() ) )
             {
                 joinedFolder = nextFile;
             }
         }
-        
+
         return joinedFolder;
     }
 }

Modified: 
maven/shared/trunk/maven-project-utils/src/main/java/org/apache/maven/shared/project/utils/ScmUtils.java
URL: 
http://svn.apache.org/viewvc/maven/shared/trunk/maven-project-utils/src/main/java/org/apache/maven/shared/project/utils/ScmUtils.java?rev=1722317&r1=1722316&r2=1722317&view=diff
==============================================================================
--- 
maven/shared/trunk/maven-project-utils/src/main/java/org/apache/maven/shared/project/utils/ScmUtils.java
 (original)
+++ 
maven/shared/trunk/maven-project-utils/src/main/java/org/apache/maven/shared/project/utils/ScmUtils.java
 Wed Dec 30 11:46:21 2015
@@ -35,8 +35,8 @@ public final class ScmUtils
     }
 
     /**
-     * Resolve the scm connection, based on the type of project and 
inheritance.
-     * This method assumes that the connection ends with the path and can be 
extended.
+     * Resolve the scm connection, based on the type of project and 
inheritance. This method assumes that the connection
+     * ends with the path and can be extended.
      * 
      * @param project the Maven project
      * @return the resolved SCM connection, otherwise an empty String
@@ -70,8 +70,8 @@ public final class ScmUtils
     }
 
     /**
-     * Resolve the scm developer connection, based on the type of project and 
inheritance.
-     * This method assumes that the developer connection ends with the path 
and can be extended.
+     * Resolve the scm developer connection, based on the type of project and 
inheritance. This method assumes that the
+     * developer connection ends with the path and can be extended.
      * 
      * @param project the Maven Project
      * @return the resolved SCM developer connection, otherwise an empty String

Modified: 
maven/shared/trunk/maven-project-utils/src/main/java/org/apache/maven/shared/project/utils/SiteUtils.java
URL: 
http://svn.apache.org/viewvc/maven/shared/trunk/maven-project-utils/src/main/java/org/apache/maven/shared/project/utils/SiteUtils.java?rev=1722317&r1=1722316&r2=1722317&view=diff
==============================================================================
--- 
maven/shared/trunk/maven-project-utils/src/main/java/org/apache/maven/shared/project/utils/SiteUtils.java
 (original)
+++ 
maven/shared/trunk/maven-project-utils/src/main/java/org/apache/maven/shared/project/utils/SiteUtils.java
 Wed Dec 30 11:46:21 2015
@@ -39,9 +39,8 @@ public final class SiteUtils
     {
         return resolveDistributionManagementSiteUrl( project, true );
     }
-    
+
     /**
-     * 
      * @param project
      * @param useModuleName use the moduleName instead of the artifactId
      * @return
@@ -59,7 +58,7 @@ public final class SiteUtils
                 if ( useModuleName )
                 {
                     Map<String, String> modules = ProjectUtils.getAllModules( 
project.getParent() );
-                    
+
                     for ( String module : modules.keySet() )
                     {
                         if ( new File( project.getParent().getBasedir(), 
module ).equals( project.getFile() ) )
@@ -78,11 +77,10 @@ public final class SiteUtils
         }
         return siteUrl;
     }
-    
+
     /**
-     * 
      * @param model
-     * @return return the url if available, otherwise {@code null} 
+     * @return return the url if available, otherwise {@code null}
      */
     protected static String getDistributionManagementSiteUrl( Model model )
     {

Modified: 
maven/shared/trunk/maven-project-utils/src/test/java/org/apache/maven/shared/project/utils/ProjectUtilsTest.java
URL: 
http://svn.apache.org/viewvc/maven/shared/trunk/maven-project-utils/src/test/java/org/apache/maven/shared/project/utils/ProjectUtilsTest.java?rev=1722317&r1=1722316&r2=1722317&view=diff
==============================================================================
--- 
maven/shared/trunk/maven-project-utils/src/test/java/org/apache/maven/shared/project/utils/ProjectUtilsTest.java
 (original)
+++ 
maven/shared/trunk/maven-project-utils/src/test/java/org/apache/maven/shared/project/utils/ProjectUtilsTest.java
 Wed Dec 30 11:46:21 2015
@@ -1,12 +1,5 @@
 package org.apache.maven.shared.project.utils;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-
-import java.io.File;
-
-import org.junit.Test;
-
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -26,6 +19,13 @@ import org.junit.Test;
  * under the License.
  */
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import java.io.File;
+
+import org.junit.Test;
+
 public class ProjectUtilsTest
 {
     private static final File ROOT_FOLDER = new File( "." );
@@ -57,7 +57,6 @@ public class ProjectUtilsTest
         assertNull( ProjectUtils.getJoinedFolder( ROOT_FOLDER, null ) );
     }
 
-    
     @Test
     public void getJoinedFolderSameDirectory()
         throws Exception

Modified: 
maven/shared/trunk/maven-project-utils/src/test/java/org/apache/maven/shared/project/utils/ScmUtilsTest.java
URL: 
http://svn.apache.org/viewvc/maven/shared/trunk/maven-project-utils/src/test/java/org/apache/maven/shared/project/utils/ScmUtilsTest.java?rev=1722317&r1=1722316&r2=1722317&view=diff
==============================================================================
--- 
maven/shared/trunk/maven-project-utils/src/test/java/org/apache/maven/shared/project/utils/ScmUtilsTest.java
 (original)
+++ 
maven/shared/trunk/maven-project-utils/src/test/java/org/apache/maven/shared/project/utils/ScmUtilsTest.java
 Wed Dec 30 11:46:21 2015
@@ -1,20 +1,5 @@
 package org.apache.maven.shared.project.utils;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import java.io.File;
-import java.io.IOException;
-
-import org.apache.maven.model.Model;
-import org.apache.maven.model.Scm;
-import org.apache.maven.project.MavenProject;
-import org.junit.Test;
-
-import edu.emory.mathcs.backport.java.util.Collections;
-
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -34,6 +19,21 @@ import edu.emory.mathcs.backport.java.ut
  * under the License.
  */
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Collections;
+
+import org.apache.maven.model.Model;
+import org.apache.maven.model.Scm;
+import org.apache.maven.project.MavenProject;
+import org.junit.Test;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
 public class ScmUtilsTest
 {
 
@@ -52,7 +52,8 @@ public class ScmUtilsTest
     }
 
     @Test
-    public void resolveScmConnectionByParent() throws IOException
+    public void resolveScmConnectionByParent()
+        throws IOException
     {
         MavenProject parent = mock( MavenProject.class );
         Model parentModel = mock( Model.class );
@@ -77,7 +78,8 @@ public class ScmUtilsTest
     }
 
     @Test
-    public void resolveScmDeveloperConnectionByParent() throws IOException
+    public void resolveScmDeveloperConnectionByParent()
+        throws IOException
     {
         MavenProject parent = mock( MavenProject.class );
         Model parentModel = mock( Model.class );


Reply via email to