continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r554646 - in /maven/continuum/trunk: continuum-api/src/main/java/org/apache/maven/continuum/ continuum-api/src/main/java/org/apache/maven/continuum/project/builder/ continuum-api/src/test/java/org/apache/maven/continuum/project/builder/ con...
Date Mon, 09 Jul 2007 13:42:36 GMT
Author: evenisse
Date: Mon Jul  9 06:42:35 2007
New Revision: 554646

URL: http://svn.apache.org/viewvc?view=rev&rev=554646
Log:
[CONTINUUM-774] Allow to add multi-module projects as one continuum project with recursive
mode
Submitted by: Olivier Lamy

Modified:
    maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java
    maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/project/builder/ContinuumProjectBuilder.java
    maven/continuum/trunk/continuum-api/src/test/java/org/apache/maven/continuum/project/builder/AbstractContinuumProjectBuilderTest.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadataAction.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenOneContinuumProjectBuilder.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilder.java
    maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadataTest.java
    maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenTwoProjectAction.java
    maven/continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties
    maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/addMavenTwoProject.jsp

Modified: maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java?view=diff&rev=554646&r1=554645&r2=554646
==============================================================================
--- maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java
(original)
+++ maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java
Mon Jul  9 06:42:35 2007
@@ -285,6 +285,23 @@
                                                        boolean useCredentialsCache )
         throws ContinuumException;
 
+
+    /**
+     * Add a Maven 2 project to the list of projects.
+     *
+     * @param metadataUrl           url of the pom.xml
+     * @param projectGroupId        id of the project group to use
+     * @param checkProtocol         check if the protocol is allowed, use false if the pom
is uploaded
+     * @param useCredentialsCache   whether to use cached scm account credentials or not
+     * @param loadRecursiveProjects if multi modules project record all projects (if false
only root project added)
+     * @return a holder with the projects, project groups and errors occurred during the
project adding
+     * @throws ContinuumException
+     */
+    public ContinuumProjectBuildingResult addMavenTwoProject( String metadataUrl, int projectGroupId,
+                                                              boolean checkProtocol, boolean
useCredentialsCache,
+                                                              boolean loadRecursiveProjects
)
+        throws ContinuumException;
+
     /**
      * Add a Maven 1 project to the list of projects.
      *

Modified: maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/project/builder/ContinuumProjectBuilder.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/project/builder/ContinuumProjectBuilder.java?view=diff&rev=554646&r1=554645&r2=554646
==============================================================================
--- maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/project/builder/ContinuumProjectBuilder.java
(original)
+++ maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/project/builder/ContinuumProjectBuilder.java
Mon Jul  9 06:42:35 2007
@@ -31,4 +31,8 @@
 
     ContinuumProjectBuildingResult buildProjectsFromMetadata( URL url, String username, String
password )
         throws ContinuumProjectBuilderException;
+
+    ContinuumProjectBuildingResult buildProjectsFromMetadata( URL url, String username, String
password,
+                                                              boolean recursiveProjects )
+        throws ContinuumProjectBuilderException;
 }

Modified: maven/continuum/trunk/continuum-api/src/test/java/org/apache/maven/continuum/project/builder/AbstractContinuumProjectBuilderTest.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-api/src/test/java/org/apache/maven/continuum/project/builder/AbstractContinuumProjectBuilderTest.java?view=diff&rev=554646&r1=554645&r2=554646
==============================================================================
--- maven/continuum/trunk/continuum-api/src/test/java/org/apache/maven/continuum/project/builder/AbstractContinuumProjectBuilderTest.java
(original)
+++ maven/continuum/trunk/continuum-api/src/test/java/org/apache/maven/continuum/project/builder/AbstractContinuumProjectBuilderTest.java
Mon Jul  9 06:42:35 2007
@@ -69,6 +69,13 @@
             return null;
         }
 
+        public ContinuumProjectBuildingResult buildProjectsFromMetadata( URL url, String
username, String password,
+                                                                         boolean recursiveProjects
)
+            throws ContinuumProjectBuilderException
+        {
+            return null;
+        }
+
     }
 
-}
\ No newline at end of file
+}

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java?view=diff&rev=554646&r1=554645&r2=554646
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
Mon Jul  9 06:42:35 2007
@@ -1158,7 +1158,7 @@
         throws ContinuumException
     {
         return executeAddProjectsFromMetadataActivity( metadataUrl, MavenOneContinuumProjectBuilder.ID,
projectGroupId,
-                                                       checkProtocol, useCredentialsCache
);
+                                                       checkProtocol, useCredentialsCache,
true );
     }
 
     // ----------------------------------------------------------------------
@@ -1195,7 +1195,16 @@
         throws ContinuumException
     {
         return executeAddProjectsFromMetadataActivity( metadataUrl, MavenTwoContinuumProjectBuilder.ID,
projectGroupId,
-                                                       checkProtocol, useCredentialsCache
);
+                                                       checkProtocol, useCredentialsCache,
true );
+    }
+
+    public ContinuumProjectBuildingResult addMavenTwoProject( String metadataUrl, int projectGroupId,
+                                                              boolean checkProtocol, boolean
useCredentialsCache,
+                                                              boolean recursiveProjects )
+        throws ContinuumException
+    {
+        return executeAddProjectsFromMetadataActivity( metadataUrl, MavenTwoContinuumProjectBuilder.ID,
projectGroupId,
+                                                       checkProtocol, useCredentialsCache,
recursiveProjects );
     }
 
     // ----------------------------------------------------------------------
@@ -1295,14 +1304,15 @@
                                                                                    boolean
checkProtocol )
         throws ContinuumException
     {
-        return executeAddProjectsFromMetadataActivity( metadataUrl, projectBuilderId, -1,
checkProtocol, false );
+        return executeAddProjectsFromMetadataActivity( metadataUrl, projectBuilderId, -1,
checkProtocol, false, false );
     }
 
     private ContinuumProjectBuildingResult executeAddProjectsFromMetadataActivity( String
metadataUrl,
                                                                                    String
projectBuilderId,
                                                                                    int projectGroupId,
                                                                                    boolean
checkProtocol,
-                                                                                   boolean
useCredentialsCache )
+                                                                                   boolean
useCredentialsCache,
+                                                                                   boolean
loadRecursiveProjects )
         throws ContinuumException
     {
         if ( checkProtocol )
@@ -1328,6 +1338,9 @@
 
         context.put( CreateProjectsFromMetadataAction.KEY_URL, metadataUrl );
 
+        context.put( CreateProjectsFromMetadataAction.KEY_LOAD_RECURSIVE_PROJECTS,
+                     Boolean.valueOf( loadRecursiveProjects ) );
+
         context.put( AbstractContinuumAction.KEY_WORKING_DIRECTORY, getWorkingDirectory()
);
 
         // ----------------------------------------------------------------------
@@ -1424,7 +1437,7 @@
         }
 
         // ----------------------------------------------------------------------
-        // Save all the projects
+        // Save all the projects if recursive mode asked
         // TODO: Validate all the projects before saving them
         // ----------------------------------------------------------------------
 
@@ -1464,6 +1477,7 @@
         {
             throw new ContinuumException( "Error adding projects from modules", e );
         }
+
         context.put( AbstractContinuumAction.KEY_PROJECT_GROUP_ID, new Integer( projectGroup.getId()
) );
         // add the relevent security administration roles for this project
         executeAction( "add-assignable-roles", context );

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadataAction.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadataAction.java?view=diff&rev=554646&r1=554645&r2=554646
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadataAction.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadataAction.java
Mon Jul  9 06:42:35 2007
@@ -73,11 +73,15 @@
 
     public static final String KEY_PROJECT_BUILDING_RESULT = "projectBuildingResult";
 
+    public static final String KEY_LOAD_RECURSIVE_PROJECTS = "loadRecursiveProjects";
+
     public void execute( Map context )
         throws ContinuumException, ContinuumProjectBuilderManagerException, ContinuumProjectBuilderException
     {
         String projectBuilderId = getString( context, KEY_PROJECT_BUILDER_ID );
 
+        boolean loadRecursiveProjects = getBoolean( context, KEY_LOAD_RECURSIVE_PROJECTS
);
+
         String curl = getString( context, KEY_URL );
 
         URL url;
@@ -138,7 +142,9 @@
                 {
                     url = mungedURL.getURL();
 
-                    result = projectBuilder.buildProjectsFromMetadata( url, username, password
);
+                    result = projectBuilder
+                        .buildProjectsFromMetadata( url, username, password, loadRecursiveProjects
);
+
                 }
                 else
                 {

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenOneContinuumProjectBuilder.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenOneContinuumProjectBuilder.java?view=diff&rev=554646&r1=554645&r2=554646
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenOneContinuumProjectBuilder.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenOneContinuumProjectBuilder.java
Mon Jul  9 06:42:35 2007
@@ -29,6 +29,7 @@
 import org.apache.maven.continuum.model.project.Schedule;
 import org.apache.maven.continuum.project.builder.AbstractContinuumProjectBuilder;
 import org.apache.maven.continuum.project.builder.ContinuumProjectBuilder;
+import org.apache.maven.continuum.project.builder.ContinuumProjectBuilderException;
 import org.apache.maven.continuum.project.builder.ContinuumProjectBuildingResult;
 import org.apache.maven.continuum.store.ContinuumStore;
 import org.apache.maven.continuum.store.ContinuumStoreException;
@@ -64,6 +65,13 @@
     // ----------------------------------------------------------------------
 
     public ContinuumProjectBuildingResult buildProjectsFromMetadata( URL url, String username,
String password )
+        throws ContinuumProjectBuilderException
+    {
+        return buildProjectsFromMetadata( url, username, password, true );
+    }
+
+    public ContinuumProjectBuildingResult buildProjectsFromMetadata( URL url, String username,
String password,
+                                                                     boolean recursiveProjects
)
     {
         ContinuumProjectBuildingResult result = new ContinuumProjectBuildingResult();
 

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilder.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilder.java?view=diff&rev=554646&r1=554645&r2=554646
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilder.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenTwoContinuumProjectBuilder.java
Mon Jul  9 06:42:35 2007
@@ -75,17 +75,24 @@
     // ----------------------------------------------------------------------
     // AbstractContinuumProjectBuilder Implementation
     // ----------------------------------------------------------------------
-
     public ContinuumProjectBuildingResult buildProjectsFromMetadata( URL url, String username,
String password )
         throws ContinuumProjectBuilderException
     {
+        return buildProjectsFromMetadata( url, username, password, true );
+    }
+
+
+    public ContinuumProjectBuildingResult buildProjectsFromMetadata( URL url, String username,
String password,
+                                                                     boolean loadRecursiveProjects
)
+        throws ContinuumProjectBuilderException
+    {
         // ----------------------------------------------------------------------
         // We need to roll the project data into a file so that we can use it
         // ----------------------------------------------------------------------
 
         ContinuumProjectBuildingResult result = new ContinuumProjectBuildingResult();
 
-        readModules( url, result, true, username, password, null );
+        readModules( url, result, true, username, password, null, loadRecursiveProjects );
 
         return result;
     }
@@ -95,8 +102,9 @@
     // ----------------------------------------------------------------------
 
     private void readModules( URL url, ContinuumProjectBuildingResult result, boolean groupPom,
String username,
-                              String password, String scmUrl )
+                              String password, String scmUrl, boolean loadRecursiveProjects
)
     {
+
         MavenProject mavenProject;
 
         try
@@ -154,8 +162,14 @@
 
                 bd.setDefaultForProject( true );
 
-                bd.setArguments( "--batch-mode --non-recursive" );
-
+                if ( loadRecursiveProjects )
+                {
+                    bd.setArguments( "--batch-mode --non-recursive" );
+                }
+                else
+                {
+                    bd.setArguments( "--batch-mode" );
+                }
                 bd.setGoals( "clean install" );
 
                 bd.setBuildFile( "pom.xml" );
@@ -250,29 +264,31 @@
         }
 
         prefix = prefix.substring( 0, lastSlash );
-
-        for ( Iterator it = modules.iterator(); it.hasNext(); )
+        if ( loadRecursiveProjects )
         {
-            String module = (String) it.next();
-
-            if ( StringUtils.isNotEmpty( module ) )
+            for ( Iterator it = modules.iterator(); it.hasNext(); )
             {
-                String urlString = prefix + "/" + module + POM_PART + suffix;
-
-                URL moduleUrl;
+                String module = (String) it.next();
 
-                try
-                {
-                    moduleUrl = new URL( urlString );
-                }
-                catch ( MalformedURLException e )
+                if ( StringUtils.isNotEmpty( module ) )
                 {
-                    getLogger().debug( "Error adding project module: Malformed URL " + urlString,
e );
-                    result.addError( ContinuumProjectBuildingResult.ERROR_MALFORMED_URL,
urlString );
-                    continue;
+                    String urlString = prefix + "/" + module + POM_PART + suffix;
+
+                    URL moduleUrl;
+
+                    try
+                    {
+                        moduleUrl = new URL( urlString );
+                    }
+                    catch ( MalformedURLException e )
+                    {
+                        getLogger().debug( "Error adding project module: Malformed URL "
+ urlString, e );
+                        result.addError( ContinuumProjectBuildingResult.ERROR_MALFORMED_URL,
urlString );
+                        continue;
+                    }
+                    // we are in recursive loading mode
+                    readModules( moduleUrl, result, false, username, password, scmUrl + "/"
+ module, true );
                 }
-
-                readModules( moduleUrl, result, false, username, password, scmUrl + "/" +
module );
             }
         }
     }

Modified: maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadataTest.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadataTest.java?view=diff&rev=554646&r1=554645&r2=554646
==============================================================================
--- maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadataTest.java
(original)
+++ maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/core/action/CreateProjectsFromMetadataTest.java
Mon Jul  9 06:42:35 2007
@@ -61,13 +61,35 @@
             .will( returnValue( new Settings() ) );
     }
 
-    public void testExecute()
+    public void testExecuteWithNonRecursiveMode()
         throws Exception
     {
         Map context = new HashMap();
         context.put( CreateProjectsFromMetadataAction.KEY_URL,
                      "http://svn.apache.org/repos/asf/maven/continuum/trunk/pom.xml" );
         context.put( CreateProjectsFromMetadataAction.KEY_PROJECT_BUILDER_ID, "id" );
+        context.put( CreateProjectsFromMetadataAction.KEY_LOAD_RECURSIVE_PROJECTS, new Boolean(
true ) );
+
+        action.execute( context );
+
+        ContinuumProjectBuildingResult result = (ContinuumProjectBuildingResult) context
+            .get( CreateProjectsFromMetadataAction.KEY_PROJECT_BUILDING_RESULT );
+
+        if ( result.hasErrors() )
+        {
+            System.out.println( "Errors=" + result.getErrorsAsString() );
+        }
+        assertFalse( "Should not have errors", result.hasErrors() );
+    }
+
+    public void testExecuteWithRecursiveMode()
+        throws Exception
+    {
+        Map context = new HashMap();
+        context.put( CreateProjectsFromMetadataAction.KEY_URL,
+                     "http://svn.apache.org/repos/asf/maven/archiva/trunk/pom.xml" );
+        context.put( CreateProjectsFromMetadataAction.KEY_PROJECT_BUILDER_ID, "id" );
+        context.put( CreateProjectsFromMetadataAction.KEY_LOAD_RECURSIVE_PROJECTS, new Boolean(
false ) );
 
         action.execute( context );
 

Modified: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenTwoProjectAction.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenTwoProjectAction.java?view=diff&rev=554646&r1=554645&r2=554646
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenTwoProjectAction.java
(original)
+++ maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/AddMavenTwoProjectAction.java
Mon Jul  9 06:42:35 2007
@@ -50,6 +50,8 @@
 
     public static final String FILE_SCHEME = "file:/";
 
+    private boolean nonRecursiveProject;
+
     protected ContinuumProjectBuildingResult doExecute( String pomUrl, int selectedProjectGroup,
boolean checkProtocol,
                                                         boolean scmUseCache )
         throws ContinuumException
@@ -102,7 +104,8 @@
 
         if ( result == null )
         {
-            result = getContinuum().addMavenTwoProject( pomUrl, selectedProjectGroup, checkProtocol,
scmUseCache );
+            result = getContinuum().addMavenTwoProject( pomUrl, selectedProjectGroup, checkProtocol,
scmUseCache,
+                                                        !this.isNonRecursiveProject() );
         }
 
         return result;
@@ -144,4 +147,15 @@
     {
         setPomUrl( pomUrl );
     }
+
+    public boolean isNonRecursiveProject()
+    {
+        return nonRecursiveProject;
+    }
+
+    public void setNonRecursiveProject( boolean nonRecursiveProject )
+    {
+        this.nonRecursiveProject = nonRecursiveProject;
+    }
+
 }

Modified: maven/continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties?view=diff&rev=554646&r1=554645&r2=554646
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties
(original)
+++ maven/continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties
Mon Jul  9 06:42:35 2007
@@ -243,6 +243,7 @@
 add.m2.project.projectGroup = Project Group
 # TODO: remove this part once uploading of an m2 project with modules is supported ( CONTINUUM-1098
)
 add.m2.project.upload.modules.error = Cannot upload a Maven 2 project with modules.
+add.m2.project.nonRecursiveProject = For muli modules project, load only root as recursive
build
 
 # ----------------------------------------------------------------------
 # Page: AddProject (ant or shell)
@@ -614,5 +615,6 @@
 installation.maven1.type.label = Maven 1
 installation.envvar.type.label = Environment Variable
 installation.ant.type.label = ANT
+
 
 

Modified: maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/addMavenTwoProject.jsp
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/addMavenTwoProject.jsp?view=diff&rev=554646&r1=554645&r2=554646
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/addMavenTwoProject.jsp
(original)
+++ maven/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/addMavenTwoProject.jsp
Mon Jul  9 06:42:35 2007
@@ -76,6 +76,7 @@
                               <ww:select label="%{getText('add.m2.project.projectGroup')}"
name="selectedProjectGroup" 
                                          list="projectGroups" listKey="id" listValue="name"/>
                             </ww:else>
+                            <ww:checkbox label="%{getText('add.m2.project.nonRecursiveProject')}"
name="nonRecursiveProject" />
                           </tbody>
                         </table>
                         <div class="functnbar3">



Mime
View raw message