You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@continuum.apache.org by ba...@apache.org on 2015/02/21 06:04:25 UTC

svn commit: r1661277 - in /continuum/trunk: continuum-api/src/main/java/org/apache/continuum/utils/release/ continuum-api/src/main/resources/META-INF/ continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/ continu...

Author: batkinson
Date: Sat Feb 21 05:04:25 2015
New Revision: 1661277

URL: http://svn.apache.org/r1661277
Log:
Changed utility class from static methods to injected service.

Added:
    continuum/trunk/continuum-api/src/main/java/org/apache/continuum/utils/release/DefaultReleaseHelper.java
      - copied, changed from r1661276, continuum/trunk/continuum-api/src/main/java/org/apache/continuum/utils/release/ReleaseUtil.java
    continuum/trunk/continuum-api/src/main/java/org/apache/continuum/utils/release/ReleaseHelper.java
Removed:
    continuum/trunk/continuum-api/src/main/java/org/apache/continuum/utils/release/ReleaseUtil.java
Modified:
    continuum/trunk/continuum-api/src/main/resources/META-INF/spring-context.xml
    continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/ContinuumBuildAgentServiceImpl.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-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumServiceImpl.java

Copied: continuum/trunk/continuum-api/src/main/java/org/apache/continuum/utils/release/DefaultReleaseHelper.java (from r1661276, 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/DefaultReleaseHelper.java?p2=continuum/trunk/continuum-api/src/main/java/org/apache/continuum/utils/release/DefaultReleaseHelper.java&p1=continuum/trunk/continuum-api/src/main/java/org/apache/continuum/utils/release/ReleaseUtil.java&r1=1661276&r2=1661277&rev=1661277&view=diff
==============================================================================
--- continuum/trunk/continuum-api/src/main/java/org/apache/continuum/utils/release/ReleaseUtil.java (original)
+++ continuum/trunk/continuum-api/src/main/java/org/apache/continuum/utils/release/DefaultReleaseHelper.java Sat Feb 21 05:04:25 2015
@@ -27,6 +27,7 @@ import org.apache.maven.shared.release.v
 import org.codehaus.plexus.util.ReaderFactory;
 import org.codehaus.plexus.util.StringUtils;
 import org.codehaus.plexus.util.xml.Xpp3Dom;
+import org.springframework.stereotype.Service;
 
 import java.io.File;
 import java.util.HashMap;
@@ -34,7 +35,9 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
-public class ReleaseUtil
+@Service( "releaseHelper" )
+public class DefaultReleaseHelper
+    implements ReleaseHelper
 {
     /**
      * Extracts parameters specified for the maven-release-plugin from the given project's metadata.
@@ -44,7 +47,7 @@ public class ReleaseUtil
      * @return a map consisting of the release plugin parameters from project metadata
      * @throws Exception
      */
-    public static Map<String, Object> extractPluginParameters( String workingDirectory, String pomFilename )
+    public Map<String, Object> extractPluginParameters( String workingDirectory, String pomFilename )
         throws Exception
     {
         Map<String, Object> params = new HashMap<String, Object>();
@@ -153,8 +156,8 @@ public class ReleaseUtil
      * @param projects              the resulting list of parameter maps for the project and its modules
      * @throws Exception
      */
-    public static void buildVersionParams( String workingDirectory, String pomFilename, boolean autoVersionSubmodules,
-                                           List<Map<String, String>> projects )
+    public void buildVersionParams( String workingDirectory, String pomFilename, boolean autoVersionSubmodules,
+                                    List<Map<String, String>> projects )
         throws Exception
     {
         Model model = getMavenModel( workingDirectory, pomFilename );

Added: continuum/trunk/continuum-api/src/main/java/org/apache/continuum/utils/release/ReleaseHelper.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-api/src/main/java/org/apache/continuum/utils/release/ReleaseHelper.java?rev=1661277&view=auto
==============================================================================
--- continuum/trunk/continuum-api/src/main/java/org/apache/continuum/utils/release/ReleaseHelper.java (added)
+++ continuum/trunk/continuum-api/src/main/java/org/apache/continuum/utils/release/ReleaseHelper.java Sat Feb 21 05:04:25 2015
@@ -0,0 +1,58 @@
+package org.apache.continuum.utils.release;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.List;
+import java.util.Map;
+
+public interface ReleaseHelper
+{
+
+    /**
+     * Extracts parameters specified for the maven-release-plugin from the given project's metadata.
+     *
+     * @param workingDirectory working directory of project containing pom file
+     * @param pomFilename      the name of the pom file in working directory
+     * @return a map consisting of the release plugin parameters from project metadata
+     * @throws Exception
+     */
+    Map<String, Object> extractPluginParameters( String workingDirectory, String pomFilename )
+        throws Exception;
+
+    /**
+     * Constructs a list of release preparation parameters for the given project and its modules. The parameter map for
+     * each project consists of:
+     * <ul>
+     * <li>key - groupId:artifactId</li>
+     * <li>name - name or artifactId if none</li>
+     * <li>dev - the version the project will assume after preparation</li>
+     * <li>release - the version the project will ultimately released as when performing</li>
+     * </ul>
+     *
+     * @param workingDirectory      working directory of project
+     * @param pomFilename           the filename of the pom inside the working directory
+     * @param autoVersionSubmodules true sets all modules to the root project's version, false uses module versions
+     * @param projects              the resulting list of parameter maps for the project and its modules
+     * @throws Exception
+     */
+    public void buildVersionParams( String workingDirectory, String pomFilename, boolean autoVersionSubmodules,
+                                    List<Map<String, String>> projects )
+        throws Exception;
+}

Modified: continuum/trunk/continuum-api/src/main/resources/META-INF/spring-context.xml
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-api/src/main/resources/META-INF/spring-context.xml?rev=1661277&r1=1661276&r2=1661277&view=diff
==============================================================================
--- continuum/trunk/continuum-api/src/main/resources/META-INF/spring-context.xml (original)
+++ continuum/trunk/continuum-api/src/main/resources/META-INF/spring-context.xml Sat Feb 21 05:04:25 2015
@@ -31,5 +31,5 @@
   <context:component-scan
       base-package="org.apache.continuum.installation,org.apache.continuum.profile,
                   org.apache.maven.continuum.configuration,org.apache.maven.continuum.utils,
-                  org.apache.continuum.utils.shell"/>
+                  org.apache.continuum.utils.shell,org.apache.continuum.utils.release"/>
 </beans>
\ No newline at end of file

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=1661277&r1=1661276&r2=1661277&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 Sat Feb 21 05:04:25 2015
@@ -36,7 +36,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.continuum.utils.release.ReleaseHelper;
 import org.apache.maven.continuum.ContinuumException;
 import org.apache.maven.continuum.model.project.BuildResult;
 import org.apache.maven.continuum.model.scm.ChangeFile;
@@ -72,7 +72,6 @@ public class ContinuumBuildAgentServiceI
 
     private static final String FILE_SEPARATOR = System.getProperty( "file.separator" );
 
-
     @Requirement
     private BuildAgentConfigurationService buildAgentConfigurationService;
 
@@ -94,6 +93,9 @@ public class ContinuumBuildAgentServiceI
     @Requirement
     private BuildAgentPurgeManager purgeManager;
 
+    @Requirement
+    private ReleaseHelper releaseHelper;
+
     public void buildProjects( List<Map<String, Object>> projectsBuildContext )
         throws ContinuumBuildAgentException
     {
@@ -364,7 +366,7 @@ public class ContinuumBuildAgentServiceI
         try
         {
             log.debug( "Getting release plugin parameters of project {}", projectId );
-            return ReleaseUtil.extractPluginParameters( workingDirectory, pomFilename );
+            return releaseHelper.extractPluginParameters( workingDirectory, pomFilename );
         }
         catch ( Exception e )
         {
@@ -381,7 +383,7 @@ public class ContinuumBuildAgentServiceI
 
         try
         {
-            ReleaseUtil.buildVersionParams( workingDirectory, pomFilename, autoVersionSubmodules, projects );
+            releaseHelper.buildVersionParams( workingDirectory, pomFilename, autoVersionSubmodules, projects );
         }
         catch ( Exception e )
         {

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=1661277&r1=1661276&r2=1661277&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 Sat Feb 21 05:04:25 2015
@@ -24,7 +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.utils.release.ReleaseHelper;
 import org.apache.continuum.web.action.AbstractReleaseAction;
 import org.apache.continuum.web.util.AuditLog;
 import org.apache.continuum.web.util.AuditLogConstants;
@@ -38,6 +38,7 @@ import org.apache.maven.continuum.web.ex
 import org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository;
 import org.apache.maven.shared.release.ReleaseResult;
 import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.Requirement;
 import org.codehaus.plexus.util.StringUtils;
 
 import java.io.File;
@@ -82,6 +83,9 @@ public class ReleasePerformAction
 
     private int profileId;
 
+    @Requirement
+    private ReleaseHelper releaseHelper;
+
     private void init()
         throws Exception
     {
@@ -170,7 +174,7 @@ public class ReleasePerformAction
     private void getReleasePluginParameters( String workingDirectory, String pomFilename )
         throws Exception
     {
-        Map<String, Object> params = ReleaseUtil.extractPluginParameters( workingDirectory, pomFilename );
+        Map<String, Object> params = releaseHelper.extractPluginParameters( 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=1661277&r1=1661276&r2=1661277&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 Sat Feb 21 05:04:25 2015
@@ -23,7 +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.utils.release.ReleaseHelper;
 import org.apache.continuum.web.action.AbstractReleaseAction;
 import org.apache.continuum.web.util.AuditLog;
 import org.apache.continuum.web.util.AuditLogConstants;
@@ -38,6 +38,7 @@ import org.apache.maven.continuum.web.ex
 import org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository;
 import org.apache.maven.shared.release.ReleaseResult;
 import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.Requirement;
 import org.codehaus.plexus.util.StringUtils;
 
 import java.io.File;
@@ -104,6 +105,9 @@ public class ReleasePrepareAction
 
     private ReleaseListenerSummary listenerSummary;
 
+    @Requirement
+    private ReleaseHelper releaseHelper;
+
     public String input()
         throws Exception
     {
@@ -184,7 +188,7 @@ public class ReleasePrepareAction
 
                 getReleasePluginParameters( workingDirectory, "pom.xml" );
 
-                ReleaseUtil.buildVersionParams( workingDirectory, "pom.xml", autoVersionSubmodules, projects );
+                releaseHelper.buildVersionParams( workingDirectory, "pom.xml", autoVersionSubmodules, projects );
             }
             catch ( Exception e )
             {
@@ -204,7 +208,7 @@ public class ReleasePrepareAction
     private void getReleasePluginParameters( String workingDirectory, String pomFilename )
         throws Exception
     {
-        Map<String, Object> params = ReleaseUtil.extractPluginParameters( workingDirectory, pomFilename );
+        Map<String, Object> params = releaseHelper.extractPluginParameters( workingDirectory, pomFilename );
 
         // TODO: use constants for this
         if ( params.get( "scm-tag" ) != null )

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=1661277&r1=1661276&r2=1661277&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 Sat Feb 21 05:04:25 2015
@@ -34,7 +34,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.utils.release.ReleaseHelper;
 import org.apache.continuum.xmlrpc.release.ContinuumReleaseResult;
 import org.apache.continuum.xmlrpc.repository.DirectoryPurgeConfiguration;
 import org.apache.continuum.xmlrpc.repository.LocalRepository;
@@ -158,6 +158,9 @@ public class ContinuumServiceImpl
     @Requirement
     private DistributedBuildManager distributedBuildManager;
 
+    @Requirement
+    private ReleaseHelper releaseHelper;
+
     public boolean ping()
         throws ContinuumException
     {
@@ -4001,8 +4004,8 @@ public class ContinuumServiceImpl
             }
             else
             {
-                params = ReleaseUtil.extractPluginParameters( continuum.getWorkingDirectory( projectId ).getPath(),
-                                                              "pom.xml" );
+                params = releaseHelper.extractPluginParameters( continuum.getWorkingDirectory( projectId ).getPath(),
+                                                                "pom.xml" );
             }
 
             // set scm tag and scm tag base if no values yet
@@ -4076,8 +4079,9 @@ public class ContinuumServiceImpl
             }
             else
             {
-                ReleaseUtil.buildVersionParams( continuum.getWorkingDirectory( projectId ).getPath(), pomFilename,
-                                                autoVersionSubmodules, projects );
+                releaseHelper.buildVersionParams( continuum.getWorkingDirectory( projectId ).getPath(),
+                                                  pomFilename,
+                                                  autoVersionSubmodules, projects );
             }
 
             return projects;