continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject svn commit: r1063962 - in /continuum/trunk: continuum-api/src/main/java/org/apache/continuum/utils/release/ continuum-api/src/main/java/org/apache/maven/continuum/release/ continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuu...
Date Thu, 27 Jan 2011 02:28:22 GMT
Author: ctan
Date: Thu Jan 27 02:28:22 2011
New Revision: 1063962

URL: http://svn.apache.org/viewvc?rev=1063962&view=rev
Log:
[CONTINUUM-2602] moved release helper methods in a utility class and expose method to retrieve
projects release and development versions in xmlrpc

Added:
    continuum/trunk/continuum-api/src/main/java/org/apache/continuum/utils/release/
    continuum/trunk/continuum-api/src/main/java/org/apache/continuum/utils/release/ReleaseUtil.java
Modified:
    continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/release/ContinuumReleaseManager.java
    continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/ContinuumBuildAgentServiceImpl.java
    continuum/trunk/continuum-release/src/main/java/org/apache/maven/continuum/release/DefaultContinuumReleaseManager.java
    continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ReleasePerformAction.java
    continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ReleasePrepareAction.java
    continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-api/src/main/java/org/apache/maven/continuum/xmlrpc/ContinuumService.java
    continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-client/src/main/java/org/apache/maven/continuum/xmlrpc/client/ContinuumXmlRpcClient.java
    continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumServiceImpl.java

Added: continuum/trunk/continuum-api/src/main/java/org/apache/continuum/utils/release/ReleaseUtil.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-api/src/main/java/org/apache/continuum/utils/release/ReleaseUtil.java?rev=1063962&view=auto
==============================================================================
--- continuum/trunk/continuum-api/src/main/java/org/apache/continuum/utils/release/ReleaseUtil.java
(added)
+++ continuum/trunk/continuum-api/src/main/java/org/apache/continuum/utils/release/ReleaseUtil.java
Thu Jan 27 02:28:22 2011
@@ -0,0 +1,176 @@
+package org.apache.continuum.utils.release;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.maven.model.Model;
+import org.apache.maven.model.Plugin;
+import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
+import org.apache.maven.shared.release.versions.DefaultVersionInfo;
+import org.apache.maven.shared.release.versions.VersionInfo;
+import org.codehaus.plexus.util.ReaderFactory;
+import org.codehaus.plexus.util.StringUtils;
+import org.codehaus.plexus.util.xml.Xpp3Dom;
+
+public class ReleaseUtil
+{
+    @SuppressWarnings( "unchecked" )
+    public static Map<String, Object> getReleasePluginParameters( String workingDirectory,
String pomFilename )
+        throws Exception
+    {
+        Map<String, Object> params = new HashMap<String, Object>();
+
+        // TODO: Use the model reader so we'll can get the plugin configuration from parent
too
+        Model model = getMavenModel( workingDirectory, pomFilename );
+
+        if ( model.getBuild() != null && model.getBuild().getPlugins() != null )
+        {
+            for ( Plugin plugin : (List<Plugin>) model.getBuild().getPlugins() )
+            {
+                if ( plugin.getGroupId() != null && plugin.getGroupId().equals( "org.apache.maven.plugins"
) &&
+                    plugin.getArtifactId() != null && plugin.getArtifactId().equals(
"maven-release-plugin" ) )
+                {
+                    Xpp3Dom dom = (Xpp3Dom) plugin.getConfiguration();
+
+                    // TODO: use constants
+                    if ( dom != null )
+                    {
+                        Xpp3Dom configuration = dom.getChild( "releaseLabel" );
+                        if ( configuration != null )
+                        {
+                            params.put( "scm-tag", configuration.getValue() );
+                        }
+
+                        configuration = dom.getChild( "tag" );
+                        if ( configuration != null )
+                        {
+                            params.put( "scm-tag", configuration.getValue() );
+                        }
+
+                        configuration = dom.getChild( "tagBase" );
+                        if ( configuration != null )
+                        {
+                            params.put( "scm-tagbase", configuration.getValue() );
+                        }
+
+                        configuration = dom.getChild( "preparationGoals" );
+                        if ( configuration != null )
+                        {
+                            params.put( "preparation-goals", configuration.getValue() );
+                        }
+
+                        configuration = dom.getChild( "arguments" );
+                        if ( configuration != null )
+                        {
+                            params.put( "arguments", configuration.getValue() );
+                        }
+
+                        configuration = dom.getChild( "scmCommentPrefix" );
+                        if ( configuration != null )
+                        {
+                            params.put( "scm-comment-prefix", configuration.getValue() );
+                        }
+
+                        configuration = dom.getChild( "autoVersionSubmodules" );
+                        if ( configuration != null )
+                        {
+                            params.put( "auto-version-submodules", Boolean.valueOf( configuration.getValue()
) );
+                        }
+
+                        configuration = dom.getChild( "addSchema" );
+                        if ( configuration != null )
+                        {
+                            params.put( "add-schema", Boolean.valueOf( configuration.getValue()
) );
+                        }
+
+                        configuration = dom.getChild( "useReleaseProfile" );
+                        if ( configuration != null )
+                        {
+                            params.put( "use-release-profile", Boolean.valueOf( configuration.getValue()
) );
+                        }
+
+                        configuration = dom.getChild( "goals" );
+                        if ( configuration != null )
+                        {
+                            String goals = configuration.getValue();
+                            if ( model.getDistributionManagement() != null &&
+                                model.getDistributionManagement().getSite() != null )
+                            {
+                                goals += " site-deploy";
+                            }
+
+                            params.put( "perform-goals", goals );
+                        }
+                    }
+                }
+            }
+        }
+        return params;
+    }
+
+    public static void processProject( String workingDirectory, String pomFilename, boolean
autoVersionSubmodules,
+                                       List<Map<String, String>> projects )
+        throws Exception
+    {
+        Model model = getMavenModel( workingDirectory, pomFilename );
+
+        if ( model.getGroupId() == null )
+        {
+            model.setGroupId( model.getParent().getGroupId() );
+        }
+
+        if ( model.getVersion() == null )
+        {
+            model.setVersion( model.getParent().getVersion() );
+        }
+
+        setProperties( model, autoVersionSubmodules, projects );
+
+        for ( Iterator modules = model.getModules().iterator(); modules.hasNext(); )
+        {
+            String module = StringUtils.replace( modules.next().toString(), '\\', '/' );
+
+            processProject( workingDirectory + "/" + module, "pom.xml", autoVersionSubmodules,
+                            projects );
+        }
+    }
+
+    private static void setProperties( Model model, boolean autoVersionSubmodules, List<Map<String,
String>> projects )
+        throws Exception
+    {
+        Map<String, String> params = new HashMap<String, String>();
+    
+        params.put( "key", model.getGroupId() + ":" + model.getArtifactId() );
+    
+        if ( model.getName() == null )
+        {
+            model.setName( model.getArtifactId() );
+        }
+        params.put( "name", model.getName() );
+    
+        if ( !autoVersionSubmodules || projects.size() == 0 )
+        {
+            VersionInfo version = new DefaultVersionInfo( model.getVersion() );
+            params.put( "release", version.getReleaseVersionString() );
+            params.put( "dev", version.getNextVersion().getSnapshotVersionString() );
+        }
+        else
+        {
+            Map<String, String> rootParams = projects.get( 0 ); // get the root map
+            params.put( "release", rootParams.get( "release" ) );
+            params.put( "dev", rootParams.get( "dev" ) );
+        }
+
+        projects.add( params );
+    }
+
+    private static Model getMavenModel( String workingDirectory, String pomFilename )
+        throws Exception
+    {
+        MavenXpp3Reader pomReader = new MavenXpp3Reader();
+        return pomReader.read( ReaderFactory.newXmlReader( new File( workingDirectory, pomFilename
) ) );
+    }
+}

Modified: continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/release/ContinuumReleaseManager.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/release/ContinuumReleaseManager.java?rev=1063962&r1=1063961&r2=1063962&view=diff
==============================================================================
--- continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/release/ContinuumReleaseManager.java
(original)
+++ continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/release/ContinuumReleaseManager.java
Thu Jan 27 02:28:22 2011
@@ -153,14 +153,4 @@ public interface ContinuumReleaseManager
      */
     ReleaseListenerSummary getListener( String releaseId );
 
-    /**
-     * Get the release plugin parameters
-     * 
-     * @param workingDirectory
-     * @param pomFilename
-     * @return
-     * @throws ContinuumReleaseException
-     */
-    Map<String, Object> getReleasePluginParameters( String workingDirectory, String
pomFilename )
-        throws ContinuumReleaseException;
 }

Modified: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/ContinuumBuildAgentServiceImpl.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/ContinuumBuildAgentServiceImpl.java?rev=1063962&r1=1063961&r2=1063962&view=diff
==============================================================================
--- continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/ContinuumBuildAgentServiceImpl.java
(original)
+++ continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/ContinuumBuildAgentServiceImpl.java
Thu Jan 27 02:28:22 2011
@@ -44,6 +44,7 @@ import org.apache.continuum.buildagent.u
 import org.apache.continuum.taskqueue.BuildProjectTask;
 import org.apache.continuum.taskqueue.manager.TaskQueueManagerException;
 import org.apache.continuum.utils.build.BuildTrigger;
+import org.apache.continuum.utils.release.ReleaseUtil;
 import org.apache.maven.continuum.ContinuumException;
 import org.apache.maven.continuum.model.project.BuildResult;
 import org.apache.maven.continuum.model.scm.ChangeFile;
@@ -313,150 +314,16 @@ public class ContinuumBuildAgentServiceI
     public Map<String, Object> getReleasePluginParameters( int projectId, String pomFilename
)
         throws ContinuumBuildAgentException
     {
-        Map<String, Object> releaseParameters = new HashMap<String, Object>();
-
         String workingDirectory = buildAgentConfigurationService.getWorkingDirectory( projectId
).getPath();
 
-        MavenXpp3Reader pomReader = new MavenXpp3Reader();
         try
         {
-            Model model = pomReader.read( ReaderFactory.newXmlReader( new File( workingDirectory,
pomFilename ) ) );
-
-            if ( model.getBuild() != null && model.getBuild().getPlugins() != null
)
-            {
-                for ( Plugin plugin : (List<Plugin>) model.getBuild().getPlugins()
)
-                {
-                    if ( plugin.getGroupId() != null && plugin.getGroupId().equals(
"org.apache.maven.plugins" ) &&
-                        plugin.getArtifactId() != null && plugin.getArtifactId().equals(
"maven-release-plugin" ) )
-                    {
-                        Xpp3Dom dom = (Xpp3Dom) plugin.getConfiguration();
-
-                        if ( dom != null )
-                        {
-                            Xpp3Dom configuration = dom.getChild( "releaseLabel" );
-                            if ( configuration != null )
-                            {
-                                releaseParameters.put( ContinuumBuildAgentUtil.KEY_SCM_TAG,
configuration.getValue() );
-                            }
-                            else
-                            {
-                                releaseParameters.put( ContinuumBuildAgentUtil.KEY_SCM_TAG,
"" );
-                            }
-
-                            configuration = dom.getChild( "tag" );
-                            if ( configuration != null )
-                            {
-                                releaseParameters.put( ContinuumBuildAgentUtil.KEY_SCM_TAG,
configuration.getValue() );
-                            }
-                            else
-                            {
-                                releaseParameters.put( ContinuumBuildAgentUtil.KEY_SCM_TAG,
"" );
-                            }
-
-                            configuration = dom.getChild( "tagBase" );
-                            if ( configuration != null )
-                            {
-                                releaseParameters.put( ContinuumBuildAgentUtil.KEY_SCM_TAGBASE,
-                                                       configuration.getValue() );
-                            }
-                            else
-                            {
-                                releaseParameters.put( ContinuumBuildAgentUtil.KEY_SCM_TAGBASE,
"" );
-                            }
-
-                            configuration = dom.getChild( "preparationGoals" );
-                            if ( configuration != null )
-                            {
-                                releaseParameters.put( ContinuumBuildAgentUtil.KEY_PREPARE_GOALS,
-                                                       configuration.getValue() );
-                            }
-                            else
-                            {
-                                releaseParameters.put( ContinuumBuildAgentUtil.KEY_PREPARE_GOALS,
"" );
-                            }
-
-                            configuration = dom.getChild( "arguments" );
-                            if ( configuration != null )
-                            {
-                                releaseParameters.put( ContinuumBuildAgentUtil.KEY_ARGUMENTS,
-                                                       configuration.getValue() );
-                            }
-                            else
-                            {
-                                releaseParameters.put( ContinuumBuildAgentUtil.KEY_ARGUMENTS,
"" );
-                            }
-
-                            configuration = dom.getChild( "scmCommentPrefix" );
-                            if ( configuration != null )
-                            {
-                                releaseParameters.put( ContinuumBuildAgentUtil.KEY_SCM_COMMENT_PREFIX,
-                                                       configuration.getValue() );
-                            }
-                            else
-                            {
-                                releaseParameters.put( ContinuumBuildAgentUtil.KEY_SCM_COMMENT_PREFIX,
"" );
-                            }
-
-                            configuration = dom.getChild( "autoVersionSubmodules" );
-                            if ( configuration != null )
-                            {
-                                releaseParameters.put( ContinuumBuildAgentUtil.KEY_AUTO_VERSION_SUBMODULES,
-                                                       Boolean.valueOf( configuration.getValue()
) );
-                            }
-                            else
-                            {
-                                releaseParameters.put( ContinuumBuildAgentUtil.KEY_AUTO_VERSION_SUBMODULES,
false );
-                            }
-
-                            configuration = dom.getChild( "addSchema" );
-                            if ( configuration != null )
-                            {
-                                releaseParameters.put( ContinuumBuildAgentUtil.KEY_ADD_SCHEMA,
-                                                       Boolean.valueOf( configuration.getValue()
) );
-                            }
-                            else
-                            {
-                                releaseParameters.put( ContinuumBuildAgentUtil.KEY_ADD_SCHEMA,
false );
-                            }
-
-                            configuration = dom.getChild( "useReleaseProfile" );
-                            if ( configuration != null )
-                            {
-                                releaseParameters.put( ContinuumBuildAgentUtil.KEY_USE_RELEASE_PROFILE,
-                                                       Boolean.valueOf( configuration.getValue()
) );
-                            }
-                            else
-                            {
-                                releaseParameters.put( ContinuumBuildAgentUtil.KEY_USE_RELEASE_PROFILE,
false );
-                            }
-
-                            configuration = dom.getChild( "goals" );
-                            if ( configuration != null )
-                            {
-                                String goals = configuration.getValue();
-                                if ( model.getDistributionManagement() != null &&
-                                    model.getDistributionManagement().getSite() != null )
-                                {
-                                    goals += "site-deploy";
-                                }
-
-                                releaseParameters.put( ContinuumBuildAgentUtil.KEY_PERFORM_GOALS,
goals );
-                            }
-                            else
-                            {
-                                releaseParameters.put( ContinuumBuildAgentUtil.KEY_PERFORM_GOALS,
"" );
-                            }
-                        }
-                    }
-                }
-            }
+            return ReleaseUtil.getReleasePluginParameters( workingDirectory, pomFilename
);
         }
         catch ( Exception e )
         {
             throw new ContinuumBuildAgentException( "Error getting release plugin parameters
from pom file", e );
         }
-
-        return releaseParameters;
     }
 
     public List<Map<String, String>> processProject( int projectId, String pomFilename,
boolean autoVersionSubmodules )
@@ -468,7 +335,7 @@ public class ContinuumBuildAgentServiceI
 
         try
         {
-            processProject( workingDirectory, pomFilename, autoVersionSubmodules, projects
);
+            ReleaseUtil.processProject( workingDirectory, pomFilename, autoVersionSubmodules,
projects );
         }
         catch ( Exception e )
         {
@@ -1033,58 +900,6 @@ public class ContinuumBuildAgentServiceI
         }
     }
 
-    private void processProject( String workingDirectory, String pomFilename, boolean autoVersionSubmodules,
-                                 List<Map<String, String>> projects )
-        throws Exception
-    {
-        MavenXpp3Reader pomReader = new MavenXpp3Reader();
-        Model model = pomReader.read( ReaderFactory.newXmlReader( new File( workingDirectory,
pomFilename ) ) );
-
-        if ( model.getGroupId() == null )
-        {
-            model.setGroupId( model.getParent().getGroupId() );
-        }
-
-        if ( model.getVersion() == null )
-        {
-            model.setVersion( model.getParent().getVersion() );
-        }
-
-        setProperties( model, projects );
-
-        if ( !autoVersionSubmodules )
-        {
-            for ( Iterator modules = model.getModules().iterator(); modules.hasNext(); )
-            {
-                String module = StringUtils.replace( modules.next().toString(), '\\', '/'
);
-            	
-                processProject( workingDirectory + "/" + module, "pom.xml", autoVersionSubmodules,
-                                projects );
-            }
-        }
-    }
-
-    private void setProperties( Model model, List<Map<String, String>> projects
)
-        throws Exception
-    {
-        Map<String, String> params = new HashMap<String, String>();
-
-        params.put( "key", model.getGroupId() + ":" + model.getArtifactId() );
-
-        if ( model.getName() == null )
-        {
-            model.setName( model.getArtifactId() );
-        }
-        params.put( "name", model.getName() );
-
-        VersionInfo version = new DefaultVersionInfo( model.getVersion() );
-
-        params.put( "release", version.getReleaseVersionString() );
-        params.put( "dev", version.getNextVersion().getSnapshotVersionString() );
-
-        projects.add( params );
-    }
-
     private List<BuildContext> initializeBuildContext( List<Map<String, Object>>
projectsBuildContext )
     {
         List<BuildContext> buildContext = new ArrayList<BuildContext>();

Modified: continuum/trunk/continuum-release/src/main/java/org/apache/maven/continuum/release/DefaultContinuumReleaseManager.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-release/src/main/java/org/apache/maven/continuum/release/DefaultContinuumReleaseManager.java?rev=1063962&r1=1063961&r2=1063962&view=diff
==============================================================================
--- continuum/trunk/continuum-release/src/main/java/org/apache/maven/continuum/release/DefaultContinuumReleaseManager.java
(original)
+++ continuum/trunk/continuum-release/src/main/java/org/apache/maven/continuum/release/DefaultContinuumReleaseManager.java
Thu Jan 27 02:28:22 2011
@@ -23,6 +23,7 @@ import java.io.File;
 import java.io.IOException;
 import java.util.HashMap;
 import java.util.Hashtable;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
@@ -45,6 +46,8 @@ import org.apache.maven.shared.release.R
 import org.apache.maven.shared.release.config.ReleaseDescriptor;
 import org.apache.maven.shared.release.config.ReleaseDescriptorStore;
 import org.apache.maven.shared.release.config.ReleaseDescriptorStoreException;
+import org.apache.maven.shared.release.versions.DefaultVersionInfo;
+import org.apache.maven.shared.release.versions.VersionInfo;
 import org.codehaus.plexus.taskqueue.Task;
 import org.codehaus.plexus.taskqueue.TaskQueue;
 import org.codehaus.plexus.taskqueue.TaskQueueException;
@@ -386,110 +389,4 @@ public class DefaultContinuumReleaseMana
 
         return null;
     }
-
-    public Map<String, Object> getReleasePluginParameters( String workingDirectory,
String pomFilename )
-        throws ContinuumReleaseException
-    {
-        Map<String, Object> params = new HashMap<String, Object>();
-
-        // TODO: Use the model reader so we'll can get the plugin configuration from parent
too
-        MavenXpp3Reader pomReader = new MavenXpp3Reader();
-        Model model;
-        try
-        {
-            model = pomReader.read( ReaderFactory.newXmlReader( new File( workingDirectory,
pomFilename ) ) );
-        }
-        catch ( IOException e )
-        {
-            throw new ContinuumReleaseException( "Failed to read pom file to get the release
plugin parameters: " + pomFilename );
-        }
-        catch ( XmlPullParserException e )
-        {
-            throw new ContinuumReleaseException( "Failed to parse pom file to get the release
plugin parameters: " + pomFilename );
-        }
-
-        if ( model.getBuild() != null && model.getBuild().getPlugins() != null )
-        {
-            for ( Plugin plugin : (List<Plugin>) model.getBuild().getPlugins() )
-            {
-                if ( plugin.getGroupId() != null && plugin.getGroupId().equals( "org.apache.maven.plugins"
) &&
-                    plugin.getArtifactId() != null && plugin.getArtifactId().equals(
"maven-release-plugin" ) )
-                {
-                    Xpp3Dom dom = (Xpp3Dom) plugin.getConfiguration();
-
-                    // TODO: use constants
-                    if ( dom != null )
-                    {
-                        Xpp3Dom configuration = dom.getChild( "releaseLabel" );
-                        if ( configuration != null )
-                        {
-                            params.put( "scm-tag", configuration.getValue() );
-                        }
-
-                        configuration = dom.getChild( "tag" );
-                        if ( configuration != null )
-                        {
-                            params.put( "scm-tag", configuration.getValue() );
-                        }
-
-                        configuration = dom.getChild( "tagBase" );
-                        if ( configuration != null )
-                        {
-                            params.put( "scm-tagbase", configuration.getValue() );
-                        }
-
-                        configuration = dom.getChild( "preparationGoals" );
-                        if ( configuration != null )
-                        {
-                            params.put( "preparation-goals", configuration.getValue() );
-                        }
-
-                        configuration = dom.getChild( "arguments" );
-                        if ( configuration != null )
-                        {
-                            params.put( "arguments", configuration.getValue() );
-                        }
-
-                        configuration = dom.getChild( "scmCommentPrefix" );
-                        if ( configuration != null )
-                        {
-                            params.put( "scm-comment-prefix", configuration.getValue() );
-                        }
-
-                        configuration = dom.getChild( "autoVersionSubmodules" );
-                        if ( configuration != null )
-                        {
-                            params.put( "auto-version-submodules", Boolean.valueOf( configuration.getValue()
) );
-                        }
-
-                        configuration = dom.getChild( "addSchema" );
-                        if ( configuration != null )
-                        {
-                            params.put( "add-schema", Boolean.valueOf( configuration.getValue()
) );
-                        }
-
-                        configuration = dom.getChild( "useReleaseProfile" );
-                        if ( configuration != null )
-                        {
-                            params.put( "use-release-profile", Boolean.valueOf( configuration.getValue()
) );
-                        }
-
-                        configuration = dom.getChild( "goals" );
-                        if ( configuration != null )
-                        {
-                            String goals = configuration.getValue();
-                            if ( model.getDistributionManagement() != null &&
-                                model.getDistributionManagement().getSite() != null )
-                            {
-                                goals += " site-deploy";
-                            }
-
-                            params.put( "perform-goals", goals );
-                        }
-                    }
-                }
-            }
-        }
-        return params;
-    }
 }

Modified: continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ReleasePerformAction.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ReleasePerformAction.java?rev=1063962&r1=1063961&r2=1063962&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ReleasePerformAction.java
(original)
+++ continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ReleasePerformAction.java
Thu Jan 27 02:28:22 2011
@@ -24,6 +24,7 @@ import org.apache.continuum.model.reposi
 import org.apache.continuum.release.config.ContinuumReleaseDescriptor;
 import org.apache.continuum.release.distributed.DistributedReleaseUtil;
 import org.apache.continuum.release.distributed.manager.DistributedReleaseManager;
+import org.apache.continuum.utils.release.ReleaseUtil;
 import org.apache.continuum.web.action.AbstractReleaseAction;
 import org.apache.continuum.web.util.AuditLog;
 import org.apache.continuum.web.util.AuditLogConstants;
@@ -176,7 +177,7 @@ public class ReleasePerformAction
     private void getReleasePluginParameters( String workingDirectory, String pomFilename
)
         throws Exception
     {
-        Map<String, Object> params = getContinuum().getReleaseManager().getReleasePluginParameters(
workingDirectory, pomFilename );
+        Map<String, Object> params = ReleaseUtil.getReleasePluginParameters( workingDirectory,
pomFilename );
 
         if ( params.get( "use-release-profile" ) != null )
         {

Modified: continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ReleasePrepareAction.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ReleasePrepareAction.java?rev=1063962&r1=1063961&r2=1063962&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ReleasePrepareAction.java
(original)
+++ continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ReleasePrepareAction.java
Thu Jan 27 02:28:22 2011
@@ -23,6 +23,7 @@ import org.apache.continuum.configuratio
 import org.apache.continuum.model.release.ReleaseListenerSummary;
 import org.apache.continuum.release.distributed.DistributedReleaseUtil;
 import org.apache.continuum.release.distributed.manager.DistributedReleaseManager;
+import org.apache.continuum.utils.release.ReleaseUtil;
 import org.apache.continuum.web.action.AbstractReleaseAction;
 import org.apache.continuum.web.util.AuditLog;
 import org.apache.continuum.web.util.AuditLogConstants;
@@ -190,7 +191,7 @@ public class ReleasePrepareAction
         
                 getReleasePluginParameters( workingDirectory, "pom.xml" );
         
-                processProject( workingDirectory, "pom.xml" );
+                ReleaseUtil.processProject( workingDirectory, "pom.xml", autoVersionSubmodules,
projects );
             }
             catch ( Exception e )
             {   
@@ -210,7 +211,7 @@ public class ReleasePrepareAction
     private void getReleasePluginParameters( String workingDirectory, String pomFilename
)
         throws Exception
     {
-        Map<String, Object> params = getContinuum().getReleaseManager().getReleasePluginParameters(
workingDirectory, pomFilename );
+        Map<String, Object> params = ReleaseUtil.getReleasePluginParameters( workingDirectory,
pomFilename );
 
         // TODO: use constants for this
         if ( params.get( "scm-tag" ) != null )
@@ -464,56 +465,6 @@ public class ReleasePrepareAction
         return status;
     }
 
-    private void processProject( String workingDirectory, String pomFilename )
-        throws Exception
-    {
-        MavenXpp3Reader pomReader = new MavenXpp3Reader();
-        Model model = pomReader.read( ReaderFactory.newXmlReader( new File( workingDirectory,
pomFilename ) ) );
-
-        if ( model.getGroupId() == null )
-        {
-            model.setGroupId( model.getParent().getGroupId() );
-        }
-
-        if ( model.getVersion() == null )
-        {
-            model.setVersion( model.getParent().getVersion() );
-        }
-
-        setProperties( model );
-
-        if ( !autoVersionSubmodules )
-        {
-            for ( Iterator modules = model.getModules().iterator(); modules.hasNext(); )
-            {
-            	String module = StringUtils.replace( modules.next().toString(), '\\', '/' );
-            	
-                processProject( workingDirectory + "/" + module, "pom.xml" );
-            }
-        }
-    }
-
-    private void setProperties( Model model )
-        throws Exception
-    {
-        Map<String, String> params = new HashMap<String, String>();
-
-        params.put( "key", model.getGroupId() + ":" + model.getArtifactId() );
-
-        if ( model.getName() == null )
-        {
-            model.setName( model.getArtifactId() );
-        }
-        params.put( "name", model.getName() );
-
-        VersionInfo version = new DefaultVersionInfo( model.getVersion() );
-
-        params.put( "release", version.getReleaseVersionString() );
-        params.put( "dev", version.getNextVersion().getSnapshotVersionString() );
-
-        projects.add( params );
-    }
-
     private Map<String, String> getDevVersionMap()
     {
         return getVersionMap( projectKeys, devVersions );

Modified: continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-api/src/main/java/org/apache/maven/continuum/xmlrpc/ContinuumService.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-api/src/main/java/org/apache/maven/continuum/xmlrpc/ContinuumService.java?rev=1063962&r1=1063961&r2=1063962&view=diff
==============================================================================
--- continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-api/src/main/java/org/apache/maven/continuum/xmlrpc/ContinuumService.java
(original)
+++ continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-api/src/main/java/org/apache/maven/continuum/xmlrpc/ContinuumService.java
Thu Jan 27 02:28:22 2011
@@ -1592,6 +1592,9 @@ public interface ContinuumService
     Map<String, Object> getReleasePluginParameters( int projectId )
         throws Exception;
 
+    List<Map<String, String>> getProjectReleaseAndDevelopmentVersions( int projectId,
String pomFilename, boolean autoVersionSubmodules )
+        throws Exception;
+
     /**
      * Add/Register build agent to Continuum Master
      * 

Modified: continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-client/src/main/java/org/apache/maven/continuum/xmlrpc/client/ContinuumXmlRpcClient.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-client/src/main/java/org/apache/maven/continuum/xmlrpc/client/ContinuumXmlRpcClient.java?rev=1063962&r1=1063961&r2=1063962&view=diff
==============================================================================
--- continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-client/src/main/java/org/apache/maven/continuum/xmlrpc/client/ContinuumXmlRpcClient.java
(original)
+++ continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-client/src/main/java/org/apache/maven/continuum/xmlrpc/client/ContinuumXmlRpcClient.java
Thu Jan 27 02:28:22 2011
@@ -1284,4 +1284,11 @@ public class ContinuumXmlRpcClient
     {
         return continuum.getReleasePluginParameters( projectId );
     }
+
+    public List<Map<String, String>> getProjectReleaseAndDevelopmentVersions(
int projectId, String pomFilename,
+                                                                              boolean autoVersionSubmodules
)
+        throws Exception
+    {
+        return continuum.getProjectReleaseAndDevelopmentVersions( projectId, pomFilename,
autoVersionSubmodules );
+    }
 }

Modified: continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumServiceImpl.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumServiceImpl.java?rev=1063962&r1=1063961&r2=1063962&view=diff
==============================================================================
--- continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumServiceImpl.java
(original)
+++ continuum/trunk/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumServiceImpl.java
Thu Jan 27 02:28:22 2011
@@ -43,6 +43,7 @@ import org.apache.continuum.dao.SystemCo
 import org.apache.continuum.purge.ContinuumPurgeManagerException;
 import org.apache.continuum.purge.PurgeConfigurationServiceException;
 import org.apache.continuum.repository.RepositoryServiceException;
+import org.apache.continuum.utils.release.ReleaseUtil;
 import org.apache.continuum.xmlrpc.release.ContinuumReleaseResult;
 import org.apache.continuum.xmlrpc.repository.DirectoryPurgeConfiguration;
 import org.apache.continuum.xmlrpc.repository.LocalRepository;
@@ -3236,9 +3237,8 @@ public class ContinuumServiceImpl
             }
             else
             {
-                params =
-                    continuum.getReleaseManager().getReleasePluginParameters( continuum.getWorkingDirectory(
projectId ).getPath(),
-                                                                              "pom.xml" );
+                params = ReleaseUtil.getReleasePluginParameters( continuum.getWorkingDirectory(
projectId ).getPath(),
+                                                                 "pom.xml" );
             }
 
             // set scm tag and scm tag base if no values yet
@@ -3295,6 +3295,35 @@ public class ContinuumServiceImpl
         }
     }
 
+    public List<Map<String, String>> getProjectReleaseAndDevelopmentVersions(
int projectId, String pomFilename, 
+                                                                              boolean autoVersionSubmodules
)
+        throws Exception
+    {
+        org.apache.maven.continuum.model.project.Project project = continuum.getProject(
projectId );
+
+        if ( project != null )
+        {
+            checkBuildProjectInGroupAuthorization( project.getProjectGroup().getName() );
+            List<Map<String, String>> projects = new ArrayList<Map<String,
String>>();
+
+            if ( continuum.getConfiguration().isDistributedBuildEnabled() )
+            {
+                projects = continuum.getDistributedReleaseManager().processProject( projectId,
pomFilename, autoVersionSubmodules );
+            }
+            else
+            {
+                ReleaseUtil.processProject( continuum.getWorkingDirectory( projectId ).getPath(),
pomFilename,
+                                            autoVersionSubmodules, projects );
+            }
+
+            return projects;
+        }
+        else
+        {
+            throw new Exception( "Unable to get release plugin parameters for project with
id " + projectId );
+        }
+    }
+
     private ReleaseListenerSummary processListenerMap( Map context )
     {
         ReleaseListenerSummary listenerSummary = new ReleaseListenerSummary();



Mime
View raw message