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/01/10 12:52:29 UTC

svn commit: r124794 - /maven/maven-1/plugins/branches/scm-1.5-branch/plugin.jelly /maven/maven-1/plugins/branches/scm-1.5-branch/src/main/org/apache/maven/plugins/scm/ScmDiffBean.java

Author: brett
Date: Mon Jan 10 03:52:26 2005
New Revision: 124794

URL: http://svn.apache.org/viewcvs?view=rev&rev=124794
Log:
utilise diff command for create-patch

Added:
   maven/maven-1/plugins/branches/scm-1.5-branch/src/main/org/apache/maven/plugins/scm/ScmDiffBean.java   (contents, props changed)
Modified:
   maven/maven-1/plugins/branches/scm-1.5-branch/plugin.jelly

Modified: maven/maven-1/plugins/branches/scm-1.5-branch/plugin.jelly
Url: http://svn.apache.org/viewcvs/maven/maven-1/plugins/branches/scm-1.5-branch/plugin.jelly?view=diff&rev=124794&p1=maven/maven-1/plugins/branches/scm-1.5-branch/plugin.jelly&r1=124793&p2=maven/maven-1/plugins/branches/scm-1.5-branch/plugin.jelly&r2=124794
==============================================================================
--- maven/maven-1/plugins/branches/scm-1.5-branch/plugin.jelly	(original)
+++ maven/maven-1/plugins/branches/scm-1.5-branch/plugin.jelly	Mon Jan 10 03:52:26 2005
@@ -55,6 +55,11 @@
        method="checkin"     
        className="org.apache.maven.plugins.scm.ScmCheckinBean"
     />
+    <define:jellybean
+       name="diff"
+       method="diff"     
+       className="org.apache.maven.plugins.scm.ScmDiffBean"
+    />
   </define:taglib>
 
   <goal name="scm:find-connection">
@@ -127,7 +132,7 @@
     </j:if> 
     <ant:echo>${msg}</ant:echo>
 
-    <scm:update var="scmUpdateBean" url="${scmConnection}" workingDirectory="${basedir}" tag="${maven.scm.tag}" />
+    <scm:update var="scmUpdateBean" url="${scmConnection}" workingDirectory="${basedir}" />
   </goal>
 
   <goal name="scm:tag" prereqs="scm:find-connection" description="Tag the project in the current directory in SCM">
@@ -231,6 +236,12 @@
     <scm:tag var="scmTagBean" url="${scmConnection}" workingDirectory="${basedir}" tag="${tag_name}" tagBase="${maven.scm.svn.tag.base}" />
   </goal>
 
+  <goal name="scm:create-patch" description="Create a patch file for changes single last SCM update" prereqs="scm:find-connection">
+    <ant:mkdir  dir="${maven.scm.patch.dir}"/>
+    <scm:diff var="scmDiffBean" url="${scmConnection}" workingDirectory="${basedir}" outputFile="${maven.scm.patch.dir}/${maven.scm.patch.file}" />
+    <ant:echo>Patch created in ${maven.scm.patch.dir}/${maven.scm.patch.file}</ant:echo>
+  </goal>
+
   <!--
     DEPRECATED METHODS
   -->
@@ -264,8 +275,7 @@
   </goal>
 
   <goal name="scm:checkout-project"
-    prereqs="scm:validate"
-    description="Checkout a project">
+    prereqs="scm:validate">
     <ant:echo>DEPRECATED: please use scm:checkout</ant:echo>
     <j:choose>
       <j:when test="${scmMethod == 'cvs'}">
@@ -353,6 +363,16 @@
         <j:set var="maven.scm.tag" value="${maven.scm.cvs.sticky.tag}" />
       </j:if>
     </j:if>
+    <j:set var="scmPatchDir" value="${maven.scm.cvs.patch.dir}"/>
+    <j:if test="${!empty(scmPatchDir)}">
+        <ant:echo>DEPRECATED: maven.scm.cvs.patch.dir replaced by maven.scm.patch.dir</ant:echo>
+      <j:set var="maven.scm.patch.dir" value="${maven.scm.cvs.patch.dir}" />
+    </j:if>
+    <j:set var="scmPatchDir" value="${maven.scm.cvs.patch.file}"/>
+    <j:if test="${!empty(scmPatchFile)}">
+        <ant:echo>DEPRECATED: maven.scm.cvs.patch.file replaced by maven.scm.patch.file</ant:echo>
+      <j:set var="maven.scm.patch.file" value="${maven.scm.cvs.patch.file}" />
+    </j:if>
   </goal>
 
   <goal name="scm:bootstrap-project" prereqs="scm:checkout-project">
@@ -403,17 +423,9 @@
     <attainGoal name="scm:prepare-release"/>
   </goal>
 
-  <!-- TODO: the below needs to be ported -->
-
-  <goal name="scm:cvs-create-patch">
-    <ant:delete dir="${maven.scm.cvs.patch.dir}"/>
-    <ant:mkdir  dir="${maven.scm.cvs.patch.dir}"/>
-    <cvs command="diff -u -w -N -R" output="${maven.scm.cvs.patch.dir}/${maven.scm.cvs.patch.file}"
-      quiet="${maven.scm.cvs.quiet}"
-      cvsRsh="${maven.scm.cvs.rsh}"
-      cvsRoot="${maven.scm.cvs.root}"
-      failonerror="false"/>
-    <ant:echo>Patch created in ${maven.scm.cvs.patch.dir}/${maven.scm.cvs.patch.file}</ant:echo>
+  <goal name="scm:cvs-create-patch" prereqs="scm:check-deprecated-cvs-vars">
+    <ant:echo>DEPRECATED: the scm:cvs-create-patch goal has been replaced by scm:create-patch</ant:echo>
+    <attainGoal name="scm:create-patch" />
   </goal>
 
 </project>

Added: maven/maven-1/plugins/branches/scm-1.5-branch/src/main/org/apache/maven/plugins/scm/ScmDiffBean.java
Url: http://svn.apache.org/viewcvs/maven/maven-1/plugins/branches/scm-1.5-branch/src/main/org/apache/maven/plugins/scm/ScmDiffBean.java?view=auto&rev=124794
==============================================================================
--- (empty file)
+++ maven/maven-1/plugins/branches/scm-1.5-branch/src/main/org/apache/maven/plugins/scm/ScmDiffBean.java	Mon Jan 10 03:52:26 2005
@@ -0,0 +1,62 @@
+package org.apache.maven.plugins.scm;
+
+/* ====================================================================
+ *   Copyright 2001-2004 The Apache Software Foundation.
+ *
+ *   Licensed 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 org.apache.maven.scm.ScmFileSet;
+import org.apache.maven.scm.command.diff.DiffScmResult;
+import org.apache.maven.scm.manager.ScmManager;
+import org.apache.maven.scm.repository.ScmRepository;
+import org.codehaus.plexus.embed.Embedder;
+
+import java.io.File;
+
+/**
+ * A bean for using the Maven SCM API because wrangling objects in Jelly is no fun.
+ *
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ */
+public class ScmDiffBean extends ScmPatternBean
+{
+    private String patchFile;
+
+    public void diff()
+        throws Exception
+    {
+        ScmManager scmManager = lookupScmManager();
+
+        ScmRepository repository = scmManager.makeScmRepository( getUrl() );
+
+        ScmFileSet fileSet = new ScmFileSet( new File( getWorkingDirectory() ), getIncludes(), getExcludes() );
+        DiffScmResult result = scmManager.diff( repository, fileSet, null, null );
+        checkResult( result );
+
+        // TODO: create patch file
+    }
+
+    public void setPatchFile( String patchFile )
+    {
+        this.patchFile = patchFile;
+    }
+
+    public String getPatchFile()
+    {
+        return patchFile;
+    }
+
+}
+

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