You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by br...@apache.org on 2005/03/29 00:23:57 UTC

svn commit: r159318 - in maven/maven-1/plugins/trunk/changelog: plugin.properties src/main/org/apache/maven/changelog/ChangeLog.java xdocs/changes.xml xdocs/index.xml

Author: brett
Date: Mon Mar 28 14:23:56 2005
New Revision: 159318

URL: http://svn.apache.org/viewcvs?view=rev&rev=159318
Log:
PR: MPCHANGELOG-23

Auto select factory from connection

Modified:
    maven/maven-1/plugins/trunk/changelog/plugin.properties
    maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/changelog/ChangeLog.java
    maven/maven-1/plugins/trunk/changelog/xdocs/changes.xml
    maven/maven-1/plugins/trunk/changelog/xdocs/index.xml

Modified: maven/maven-1/plugins/trunk/changelog/plugin.properties
URL: http://svn.apache.org/viewcvs/maven/maven-1/plugins/trunk/changelog/plugin.properties?view=diff&r1=159317&r2=159318
==============================================================================
--- maven/maven-1/plugins/trunk/changelog/plugin.properties (original)
+++ maven/maven-1/plugins/trunk/changelog/plugin.properties Mon Mar 28 14:23:56 2005
@@ -23,4 +23,3 @@
 maven.changelog.basedir=${basedir}
 
 maven.changelog.range = 30
-maven.changelog.factory = org.apache.maven.cvslib.CvsChangeLogFactory

Modified: maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/changelog/ChangeLog.java
URL: http://svn.apache.org/viewcvs/maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/changelog/ChangeLog.java?view=diff&r1=159317&r2=159318
==============================================================================
--- maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/changelog/ChangeLog.java (original)
+++ maven/maven-1/plugins/trunk/changelog/src/main/org/apache/maven/changelog/ChangeLog.java Mon Mar 28 14:23:56 2005
@@ -29,6 +29,8 @@
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
+import java.util.HashMap;
+import java.util.Map;
 import java.util.Properties;
 // commons imports
 import org.apache.commons.logging.Log;
@@ -48,7 +50,7 @@
  * @author <a href="mailto:dion@multitask.com.au">dIon Gillard</a>
  * @author <a href="mailto:bodewig@apache.org">Stefan Bodewig</a>
  * @author <a href="mailto:peter@apache.org">Peter Donald</a>
- * @version $Id: ChangeLog.java,v 1.6 2004/07/08 08:36:51 evenisse Exp $
+ * @version $Id$
  */
 public class ChangeLog
 {
@@ -71,8 +73,9 @@
      * The classname of our ChangeLogFactory, defaulting to Maven's built in
      * CVS factory.
      */
-    private String clFactoryClass = 
-        "org.apache.maven.cvslib.CvsChangeLogFactory";
+    private String clFactoryClass = null;
+
+    private static final Map FACTORIES = new HashMap();
 
     /** the connection string used to access the SCM */
     private String connection;
@@ -94,6 +97,15 @@
     /** output encoding for the xml document */
     private String outputEncoding;
 
+    static
+    {
+        FACTORIES.put( "cvs", "org.apache.maven.cvslib.CvsChangeLogFactory" );
+        FACTORIES.put( "svn", "org.apache.maven.svnlib.SvnChangeLogFactory" );
+        FACTORIES.put( "clearcase", "org.apache.maven.clearcaselib.ClearcaseChangeLogFactory" );
+        FACTORIES.put( "perforce", "org.apache.maven.perforcelib.PerforceChangeLogFactory" );
+        FACTORIES.put( "starteam", "org.apache.maven.starteamlib.StarteamChangeLogFactory" );
+    }
+
     /**
      * Set the ChangeLogFactory class name.  If this isn't set, the factory
      * defaults to Maven's build in CVS factory.
@@ -261,6 +273,24 @@
      */
     private ChangeLogFactory createFactory() throws IOException
     {
+        if ( clFactoryClass == null )
+        {
+            if ( connection == null || connection.length() < 7 || !connection.startsWith( "scm:" ) )
+            {
+                LOG.warn( "Connection does not appear valid" );
+            }
+            else
+            {
+                clFactoryClass = (String) FACTORIES.get( connection.substring( 4, 7 ) );
+            }
+
+            if ( clFactoryClass == null )
+            {
+                LOG.warn( "Could not derive factory from connection: using CVS (valid factories are: " + FACTORIES.keySet() + ")" );
+                clFactoryClass = "org.apache.maven.cvslib.CvsChangeLogFactory";
+            }
+        }
+
         try
         {
             Class clazz = Class.forName(clFactoryClass);

Modified: maven/maven-1/plugins/trunk/changelog/xdocs/changes.xml
URL: http://svn.apache.org/viewcvs/maven/maven-1/plugins/trunk/changelog/xdocs/changes.xml?view=diff&r1=159317&r2=159318
==============================================================================
--- maven/maven-1/plugins/trunk/changelog/xdocs/changes.xml (original)
+++ maven/maven-1/plugins/trunk/changelog/xdocs/changes.xml Mon Mar 28 14:23:56 2005
@@ -26,6 +26,7 @@
   </properties>
   <body>
     <release version="1.8-SNAPSHOT" date="in SVN">
+      <action dev="brett" type="fix" issue="MPCHANGELOG-23">Guess factory from connection</action>
       <action dev="brett" type="fix">Allow local CVSROOT to only have 5 tokens (no host name)</action>
     </release>
     <release version="1.7.2" date="2005-01-08">

Modified: maven/maven-1/plugins/trunk/changelog/xdocs/index.xml
URL: http://svn.apache.org/viewcvs/maven/maven-1/plugins/trunk/changelog/xdocs/index.xml?view=diff&r1=159317&r2=159318
==============================================================================
--- maven/maven-1/plugins/trunk/changelog/xdocs/index.xml (original)
+++ maven/maven-1/plugins/trunk/changelog/xdocs/index.xml Mon Mar 28 14:23:56 2005
@@ -44,14 +44,6 @@
         document.
       </p>
     </section>
-    <section name="Specifying the SCM">
-      <p>
-        The changelog plugin defaults to a CVS parser. To use an alternate
-        SCM, please set the <code>maven.changelog.factory</code> property.
-        For more information, please see the
-        <a href="properties.html">Changelog properties reference</a>.
-      </p>
-    </section>
     <section name="CVSNT users">
       <p>
         This plugin does <strong>not</strong> use the cvs executable on your 



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org