You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by be...@apache.org on 2009/01/17 23:58:36 UTC

svn commit: r735353 - in /maven/release/trunk/maven-release-plugin/src/it: forked-basic/ invoker-basic/ maven-scm-provider-dummy/ maven-scm-provider-stub/ maven-scm-provider-stub/src/ maven-scm-provider-stub/src/main/ maven-scm-provider-stub/src/main/j...

Author: bentmann
Date: Sat Jan 17 14:58:36 2009
New Revision: 735353

URL: http://svn.apache.org/viewvc?rev=735353&view=rev
Log:
o Added new SCM stub provider as preparation for more thorough integration testing

Added:
    maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/   (with props)
    maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/invoker.properties   (with props)
    maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/pom.xml   (with props)
    maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/src/
    maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/src/main/
    maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/src/main/java/
    maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/src/main/java/org/
    maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/src/main/java/org/apache/
    maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/src/main/java/org/apache/maven/
    maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/src/main/java/org/apache/maven/scm/
    maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/src/main/java/org/apache/maven/scm/provider/
    maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/src/main/java/org/apache/maven/scm/provider/stub/
    maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/src/main/java/org/apache/maven/scm/provider/stub/StubCheckInCommand.java   (with props)
    maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/src/main/java/org/apache/maven/scm/provider/stub/StubCheckOutCommand.java   (with props)
    maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/src/main/java/org/apache/maven/scm/provider/stub/StubScmProvider.java   (with props)
    maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/src/main/java/org/apache/maven/scm/provider/stub/StubScmProviderRepository.java   (with props)
    maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/src/main/java/org/apache/maven/scm/provider/stub/StubStatusCommand.java   (with props)
    maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/src/main/java/org/apache/maven/scm/provider/stub/StubTagCommand.java   (with props)
Modified:
    maven/release/trunk/maven-release-plugin/src/it/forked-basic/pom.xml
    maven/release/trunk/maven-release-plugin/src/it/invoker-basic/pom.xml
    maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-dummy/pom.xml

Modified: maven/release/trunk/maven-release-plugin/src/it/forked-basic/pom.xml
URL: http://svn.apache.org/viewvc/maven/release/trunk/maven-release-plugin/src/it/forked-basic/pom.xml?rev=735353&r1=735352&r2=735353&view=diff
==============================================================================
--- maven/release/trunk/maven-release-plugin/src/it/forked-basic/pom.xml (original)
+++ maven/release/trunk/maven-release-plugin/src/it/forked-basic/pom.xml Sat Jan 17 14:58:36 2009
@@ -20,7 +20,7 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
   <modelVersion>4.0.0</modelVersion>
 
-  <groupId>org.apache.maven.plugin.release.it</groupId>
+  <groupId>org.apache.maven.its.release</groupId>
   <artifactId>forked-basic</artifactId>
   <version>1.0-SNAPSHOT</version>
   <packaging>pom</packaging>
@@ -37,15 +37,16 @@
     <plugins>
       <plugin>
         <artifactId>maven-release-plugin</artifactId>
+        <version>@project.version@</version>
         <configuration>
           <arguments>-Dflag -Dfoo=bar -s "@project.build.directory@/it/interpolated-settings.xml" -D "maven.repo.local=@project.build.directory@/local-repo"</arguments>
           <mavenExecutorId>forked-path</mavenExecutorId>
         </configuration>
         <dependencies>
           <dependency>
-          	<groupId>org.apache.maven.its</groupId>
-          	<artifactId>maven-scm-provider-dummy</artifactId>
-          	<version>1.0</version>
+            <groupId>org.apache.maven.its.release</groupId>
+            <artifactId>maven-scm-provider-dummy</artifactId>
+            <version>1.0</version>
           </dependency>
         </dependencies>
       </plugin>

Modified: maven/release/trunk/maven-release-plugin/src/it/invoker-basic/pom.xml
URL: http://svn.apache.org/viewvc/maven/release/trunk/maven-release-plugin/src/it/invoker-basic/pom.xml?rev=735353&r1=735352&r2=735353&view=diff
==============================================================================
--- maven/release/trunk/maven-release-plugin/src/it/invoker-basic/pom.xml (original)
+++ maven/release/trunk/maven-release-plugin/src/it/invoker-basic/pom.xml Sat Jan 17 14:58:36 2009
@@ -20,7 +20,7 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
   <modelVersion>4.0.0</modelVersion>
 
-  <groupId>org.apache.maven.plugin.release.it</groupId>
+  <groupId>org.apache.maven.its.release</groupId>
   <artifactId>invoker-basic</artifactId>
   <version>1.0-SNAPSHOT</version>
   <packaging>pom</packaging>
@@ -37,13 +37,14 @@
     <plugins>
       <plugin>
         <artifactId>maven-release-plugin</artifactId>
+        <version>@project.version@</version>
         <configuration>
           <arguments>-Dflag -Dfoo=bar -s "@project.build.directory@/it/interpolated-settings.xml"</arguments>
           <mavenExecutorId>invoker</mavenExecutorId>
         </configuration>
         <dependencies>
           <dependency>
-          	<groupId>org.apache.maven.its</groupId>
+            <groupId>org.apache.maven.its.release</groupId>
           	<artifactId>maven-scm-provider-dummy</artifactId>
           	<version>1.0</version>
           </dependency>

Modified: maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-dummy/pom.xml
URL: http://svn.apache.org/viewvc/maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-dummy/pom.xml?rev=735353&r1=735352&r2=735353&view=diff
==============================================================================
--- maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-dummy/pom.xml (original)
+++ maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-dummy/pom.xml Sat Jan 17 14:58:36 2009
@@ -21,7 +21,7 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
   <modelVersion>4.0.0</modelVersion>
 
-  <groupId>org.apache.maven.its</groupId>
+  <groupId>org.apache.maven.its.release</groupId>
   <artifactId>maven-scm-provider-dummy</artifactId>
   <version>1.0</version>
 
@@ -32,7 +32,7 @@
     <dependency>
       <groupId>org.apache.maven.scm</groupId>
       <artifactId>maven-scm-api</artifactId>
-      <version>1.0</version>
+      <version>1.1</version>
     </dependency>
   </dependencies>
 

Propchange: maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sat Jan 17 14:58:36 2009
@@ -0,0 +1,5 @@
+target
+bin
+.settings
+.project
+.classpath

Added: maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/invoker.properties
URL: http://svn.apache.org/viewvc/maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/invoker.properties?rev=735353&view=auto
==============================================================================
--- maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/invoker.properties (added)
+++ maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/invoker.properties Sat Jan 17 14:58:36 2009
@@ -0,0 +1 @@
+invoker.goals = install

Propchange: maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/invoker.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/invoker.properties
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/pom.xml
URL: http://svn.apache.org/viewvc/maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/pom.xml?rev=735353&view=auto
==============================================================================
--- maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/pom.xml (added)
+++ maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/pom.xml Sat Jan 17 14:58:36 2009
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.its.release</groupId>
+  <artifactId>maven-scm-provider-stub</artifactId>
+  <version>1.0</version>
+
+  <name>Maven SCM Stub Provider</name>
+  <description>
+    Provides a minimal, file-based SCM provider to test the SCM operations of the Maven Release Plugin.
+  </description>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven.scm</groupId>
+      <artifactId>maven-scm-api</artifactId>
+      <version>1.1</version>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <version>2.0.2</version>
+        <configuration>
+          <source>1.4</source>
+          <target>1.4</target>
+          <encoding>UTF-8</encoding>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.codehaus.plexus</groupId>
+        <artifactId>plexus-maven-plugin</artifactId>
+        <version>1.3.8</version>
+        <executions>
+          <execution>
+            <goals>
+              <goal>descriptor</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Propchange: maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/src/main/java/org/apache/maven/scm/provider/stub/StubCheckInCommand.java
URL: http://svn.apache.org/viewvc/maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/src/main/java/org/apache/maven/scm/provider/stub/StubCheckInCommand.java?rev=735353&view=auto
==============================================================================
--- maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/src/main/java/org/apache/maven/scm/provider/stub/StubCheckInCommand.java (added)
+++ maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/src/main/java/org/apache/maven/scm/provider/stub/StubCheckInCommand.java Sat Jan 17 14:58:36 2009
@@ -0,0 +1,107 @@
+package org.apache.maven.scm.provider.stub;
+
+/*
+ * 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.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.maven.scm.CommandParameters;
+import org.apache.maven.scm.ScmException;
+import org.apache.maven.scm.ScmFile;
+import org.apache.maven.scm.ScmFileSet;
+import org.apache.maven.scm.ScmFileStatus;
+import org.apache.maven.scm.ScmResult;
+import org.apache.maven.scm.command.AbstractCommand;
+import org.apache.maven.scm.command.checkin.CheckInScmResult;
+import org.apache.maven.scm.provider.ScmProviderRepository;
+import org.codehaus.plexus.util.FileUtils;
+
+/**
+ * A dummy check-in command.
+ * 
+ * @author Benjamin Bentmann
+ * @version $Id$
+ */
+class StubCheckInCommand
+    extends AbstractCommand
+{
+
+    protected ScmResult executeCommand( ScmProviderRepository repository, ScmFileSet fileSet,
+                                        CommandParameters parameters )
+        throws ScmException
+    {
+        List checkedInFiles = new ArrayList();
+
+        try
+        {
+            StubScmProviderRepository stubRepo = (StubScmProviderRepository) repository;
+
+            File workingCopyRoot = stubRepo.getWorkingCopyRoot( fileSet );
+            File repoRoot = stubRepo.getRoot();
+
+            getLogger().info( "Committing: " + workingCopyRoot + " > " + repoRoot );
+
+            List paths = stubRepo.getPaths( workingCopyRoot, fileSet );
+
+            for ( Iterator it = paths.iterator(); it.hasNext(); )
+            {
+                String path = (String) it.next();
+                File srcFile = new File( workingCopyRoot, path );
+                File dstFile = new File( repoRoot, path );
+
+                getLogger().info( "  " + path );
+
+                if ( dstFile.isDirectory() )
+                {
+                    if ( !srcFile.isDirectory() )
+                    {
+                        throw new IOException( "Cannot commit a normal file to a directory: " + srcFile + " -> "
+                            + dstFile );
+                    }
+                }
+                else if ( dstFile.isFile() )
+                {
+                    if ( !srcFile.isFile() )
+                    {
+                        throw new IOException( "Cannot commit a directory to a normal file: " + srcFile + " -> "
+                            + dstFile );
+                    }
+                    FileUtils.copyFile( srcFile, dstFile );
+                }
+                else
+                {
+                    throw new IOException( "Cannot commit to non-existing location: " + srcFile + " -> " + dstFile );
+                }
+
+                checkedInFiles.add( new ScmFile( path, ScmFileStatus.CHECKED_IN ) );
+            }
+        }
+        catch ( IOException e )
+        {
+            throw new ScmException( "Error while checking in the files.", e );
+        }
+
+        return new CheckInScmResult( null, checkedInFiles );
+    }
+
+}

Propchange: maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/src/main/java/org/apache/maven/scm/provider/stub/StubCheckInCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/src/main/java/org/apache/maven/scm/provider/stub/StubCheckInCommand.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/src/main/java/org/apache/maven/scm/provider/stub/StubCheckOutCommand.java
URL: http://svn.apache.org/viewvc/maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/src/main/java/org/apache/maven/scm/provider/stub/StubCheckOutCommand.java?rev=735353&view=auto
==============================================================================
--- maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/src/main/java/org/apache/maven/scm/provider/stub/StubCheckOutCommand.java (added)
+++ maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/src/main/java/org/apache/maven/scm/provider/stub/StubCheckOutCommand.java Sat Jan 17 14:58:36 2009
@@ -0,0 +1,130 @@
+package org.apache.maven.scm.provider.stub;
+
+/*
+ * 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.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.maven.scm.CommandParameter;
+import org.apache.maven.scm.CommandParameters;
+import org.apache.maven.scm.ScmBranch;
+import org.apache.maven.scm.ScmException;
+import org.apache.maven.scm.ScmFile;
+import org.apache.maven.scm.ScmFileSet;
+import org.apache.maven.scm.ScmFileStatus;
+import org.apache.maven.scm.ScmResult;
+import org.apache.maven.scm.ScmTag;
+import org.apache.maven.scm.ScmVersion;
+import org.apache.maven.scm.command.AbstractCommand;
+import org.apache.maven.scm.command.checkout.CheckOutScmResult;
+import org.apache.maven.scm.provider.ScmProviderRepository;
+import org.codehaus.plexus.util.FileUtils;
+
+/**
+ * A dummy check-out command.
+ * 
+ * @author Benjamin Bentmann
+ * @version $Id$
+ */
+class StubCheckOutCommand
+    extends AbstractCommand
+{
+
+    protected ScmResult executeCommand( ScmProviderRepository repository, ScmFileSet fileSet,
+                                        CommandParameters parameters )
+        throws ScmException
+    {
+        List checkedOutFiles = new ArrayList();
+
+        try
+        {
+            StubScmProviderRepository stubRepo = (StubScmProviderRepository) repository;
+
+            File workingCopyRoot = fileSet.getBasedir();
+            ScmVersion version = parameters.getScmVersion( CommandParameter.SCM_VERSION );
+            File revRoot;
+            if ( version instanceof ScmTag )
+            {
+                revRoot = new File( stubRepo.getTagBase(), version.getName() );
+            }
+            else if ( version instanceof ScmBranch )
+            {
+                revRoot = new File( stubRepo.getBranchBase(), version.getName() );
+            }
+            else
+            {
+                revRoot = stubRepo.getRoot();
+            }
+
+            getLogger().info( "Checking out: " + revRoot + " > " + workingCopyRoot );
+
+            if ( workingCopyRoot.isFile() )
+            {
+                throw new IOException( "Cannot check out into exising file" );
+            }
+            if ( workingCopyRoot.isDirectory() && workingCopyRoot.list().length > 0 )
+            {
+                throw new IOException( "Cannot check out into non-empty directory" );
+            }
+
+            List paths = stubRepo.getPaths( workingCopyRoot, fileSet );
+            if ( paths.isEmpty() )
+            {
+                paths.add( "." );
+            }
+
+            new File( workingCopyRoot, StubScmProviderRepository.WORKING_COPY_ROOT_MARKER_FILE ).createNewFile();
+
+            for ( Iterator it = paths.iterator(); it.hasNext(); )
+            {
+                String path = (String) it.next();
+                File srcFile = new File( revRoot, path );
+                File dstFile = new File( workingCopyRoot, path );
+
+                getLogger().info( "  " + path );
+
+                if ( srcFile.isDirectory() )
+                {
+                    FileUtils.copyDirectoryStructure( srcFile, dstFile );
+                }
+                else if ( srcFile.isFile() )
+                {
+                    FileUtils.copyFile( srcFile, dstFile );
+                }
+                else
+                {
+                    throw new IOException( "Cannot check out non-existing file: " + srcFile );
+                }
+
+                checkedOutFiles.add( new ScmFile( path, ScmFileStatus.CHECKED_OUT ) );
+            }
+        }
+        catch ( IOException e )
+        {
+            throw new ScmException( "Error while checking out the files.", e );
+        }
+
+        return new CheckOutScmResult( null, checkedOutFiles );
+    }
+
+}

Propchange: maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/src/main/java/org/apache/maven/scm/provider/stub/StubCheckOutCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/src/main/java/org/apache/maven/scm/provider/stub/StubCheckOutCommand.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/src/main/java/org/apache/maven/scm/provider/stub/StubScmProvider.java
URL: http://svn.apache.org/viewvc/maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/src/main/java/org/apache/maven/scm/provider/stub/StubScmProvider.java?rev=735353&view=auto
==============================================================================
--- maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/src/main/java/org/apache/maven/scm/provider/stub/StubScmProvider.java (added)
+++ maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/src/main/java/org/apache/maven/scm/provider/stub/StubScmProvider.java Sat Jan 17 14:58:36 2009
@@ -0,0 +1,92 @@
+package org.apache.maven.scm.provider.stub;
+
+/*
+ * 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 org.apache.maven.scm.CommandParameters;
+import org.apache.maven.scm.ScmException;
+import org.apache.maven.scm.ScmFileSet;
+import org.apache.maven.scm.ScmResult;
+import org.apache.maven.scm.command.Command;
+import org.apache.maven.scm.command.checkin.CheckInScmResult;
+import org.apache.maven.scm.command.checkout.CheckOutScmResult;
+import org.apache.maven.scm.command.status.StatusScmResult;
+import org.apache.maven.scm.command.tag.TagScmResult;
+import org.apache.maven.scm.provider.AbstractScmProvider;
+import org.apache.maven.scm.provider.ScmProviderRepository;
+import org.apache.maven.scm.repository.ScmRepositoryException;
+
+/**
+ * A stub SCM provider used for the Maven Release Plugin when doing integration testing.
+ * 
+ * @plexus.component role="org.apache.maven.scm.provider.ScmProvider" role-hint="stub"
+ * @author Benjamin Bentmann
+ * @version $Id$
+ */
+public class StubScmProvider
+    extends AbstractScmProvider
+{
+
+    public String getScmType()
+    {
+        return "stub";
+    }
+
+    public ScmProviderRepository makeProviderScmRepository( String scmSpecificUrl, char delimiter )
+        throws ScmRepositoryException
+    {
+        return new StubScmProviderRepository( scmSpecificUrl );
+    }
+
+    protected ScmResult executeCommand( Command command, ScmProviderRepository repository, ScmFileSet fileSet,
+                                        CommandParameters parameters )
+        throws ScmException
+    {
+        command.setLogger( getLogger() );
+
+        return command.execute( repository, fileSet, parameters );
+    }
+
+    protected StatusScmResult status( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters )
+        throws ScmException
+    {
+        return (StatusScmResult) executeCommand( new StubStatusCommand(), repository, fileSet, parameters );
+    }
+
+    protected CheckInScmResult checkin( ScmProviderRepository repository, ScmFileSet fileSet,
+                                        CommandParameters parameters )
+        throws ScmException
+    {
+        return (CheckInScmResult) executeCommand( new StubCheckInCommand(), repository, fileSet, parameters );
+    }
+
+    protected CheckOutScmResult checkout( ScmProviderRepository repository, ScmFileSet fileSet,
+                                          CommandParameters parameters )
+        throws ScmException
+    {
+        return (CheckOutScmResult) executeCommand( new StubCheckOutCommand(), repository, fileSet, parameters );
+    }
+
+    protected TagScmResult tag( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters )
+        throws ScmException
+    {
+        return (TagScmResult) executeCommand( new StubTagCommand(), repository, fileSet, parameters );
+    }
+
+}

Propchange: maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/src/main/java/org/apache/maven/scm/provider/stub/StubScmProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/src/main/java/org/apache/maven/scm/provider/stub/StubScmProvider.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/src/main/java/org/apache/maven/scm/provider/stub/StubScmProviderRepository.java
URL: http://svn.apache.org/viewvc/maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/src/main/java/org/apache/maven/scm/provider/stub/StubScmProviderRepository.java?rev=735353&view=auto
==============================================================================
--- maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/src/main/java/org/apache/maven/scm/provider/stub/StubScmProviderRepository.java (added)
+++ maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/src/main/java/org/apache/maven/scm/provider/stub/StubScmProviderRepository.java Sat Jan 17 14:58:36 2009
@@ -0,0 +1,163 @@
+package org.apache.maven.scm.provider.stub;
+
+/*
+ * 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.io.File;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.maven.scm.ScmFileSet;
+import org.apache.maven.scm.provider.ScmProviderRepository;
+
+/**
+ * A stub SCM repository used for the Maven Release Plugin when doing integration testing.
+ * 
+ * @author Benjamin Bentmann
+ * @version $Id$
+ */
+class StubScmProviderRepository
+    extends ScmProviderRepository
+{
+
+    /**
+     * The root directory of the remote copy that corresponds to the root directory of the working copy.
+     */
+    private File root;
+
+    /**
+     * The root directory to create tags in. This path is derived from the root directory, assuming SVN conventions.
+     */
+    private File tagBase;
+
+    /**
+     * The root directory to create branches in. This path is derived from the root directory, assuming SVN conventions.
+     */
+    private File branchBase;
+
+    /**
+     * The simple name of the file used to mark the root directory of the working copy.
+     */
+    static final String WORKING_COPY_ROOT_MARKER_FILE = "_base.properties";
+
+    public StubScmProviderRepository( String url )
+    {
+        root = new File( url ).getAbsoluteFile();
+        initTagBranchBase();
+    }
+
+    private void initTagBranchBase()
+    {
+        File base;
+        for ( base = root; base != null; base = base.getParentFile() )
+        {
+            if ( "trunk".equals( base.getName() ) )
+            {
+                base = base.getParentFile();
+                break;
+            }
+        }
+        if ( base == null )
+        {
+            base = root.getParentFile();
+        }
+        tagBase = new File( base, "tags" );
+        branchBase = new File( base, "branches" );
+    }
+
+    public File getRoot()
+    {
+        return root;
+    }
+
+    public File getTagBase()
+    {
+        return tagBase;
+    }
+
+    public File getBranchBase()
+    {
+        return branchBase;
+    }
+
+    public List getPaths( File workingCopyRoot, ScmFileSet fileSet )
+    {
+        List paths = new ArrayList();
+
+        Collection files = fileSet.getFileList();
+        if ( files != null && !files.isEmpty() )
+        {
+            for ( Iterator it = files.iterator(); it.hasNext(); )
+            {
+                File file = (File) it.next();
+                if ( !file.isAbsolute() )
+                {
+                    file = new File( fileSet.getBasedir(), file.getPath() );
+                }
+
+                String path = getPath( workingCopyRoot, file );
+                paths.add( path );
+            }
+        }
+
+        return paths;
+    }
+
+    private String getPath( File root, File file )
+    {
+        StringBuffer path = new StringBuffer( 256 );
+
+        for ( File parent = file; !root.equals( parent ); )
+        {
+            if ( path.length() > 0 )
+            {
+                path.insert( 0, '/' );
+            }
+            path.insert( 0, parent.getName() );
+
+            parent = parent.getParentFile();
+            if ( parent == null )
+            {
+                throw new IllegalArgumentException( "Cannot relativize " + file + " against " + root );
+            }
+        }
+
+        return path.toString();
+    }
+
+    public File getWorkingCopyRoot( ScmFileSet fileSet )
+    {
+        for ( File root = fileSet.getBasedir(); root != null; root = root.getParentFile() )
+        {
+            if ( new File( root, WORKING_COPY_ROOT_MARKER_FILE ).isFile() )
+            {
+                return root;
+            }
+        }
+        throw new IllegalArgumentException( "SCM file set is not part of stub working copy: " + fileSet );
+    }
+
+    public String toString()
+    {
+        return "StubScmProviderRepository[root=" + root + ", tags=" + tagBase + ", branches=" + branchBase + "]";
+    }
+
+}

Propchange: maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/src/main/java/org/apache/maven/scm/provider/stub/StubScmProviderRepository.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/src/main/java/org/apache/maven/scm/provider/stub/StubScmProviderRepository.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/src/main/java/org/apache/maven/scm/provider/stub/StubStatusCommand.java
URL: http://svn.apache.org/viewvc/maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/src/main/java/org/apache/maven/scm/provider/stub/StubStatusCommand.java?rev=735353&view=auto
==============================================================================
--- maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/src/main/java/org/apache/maven/scm/provider/stub/StubStatusCommand.java (added)
+++ maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/src/main/java/org/apache/maven/scm/provider/stub/StubStatusCommand.java Sat Jan 17 14:58:36 2009
@@ -0,0 +1,52 @@
+package org.apache.maven.scm.provider.stub;
+
+/*
+ * 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.ArrayList;
+import java.util.List;
+
+import org.apache.maven.scm.CommandParameters;
+import org.apache.maven.scm.ScmException;
+import org.apache.maven.scm.ScmFileSet;
+import org.apache.maven.scm.ScmResult;
+import org.apache.maven.scm.command.AbstractCommand;
+import org.apache.maven.scm.command.status.StatusScmResult;
+import org.apache.maven.scm.provider.ScmProviderRepository;
+
+/**
+ * A dummy status command.
+ * 
+ * @author Benjamin Bentmann
+ * @version $Id$
+ */
+class StubStatusCommand
+    extends AbstractCommand
+{
+
+    protected ScmResult executeCommand( ScmProviderRepository repository, ScmFileSet fileSet,
+                                        CommandParameters parameters )
+        throws ScmException
+    {
+        List changedFiles = new ArrayList();
+
+        return new StatusScmResult( null, changedFiles );
+    }
+
+}

Propchange: maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/src/main/java/org/apache/maven/scm/provider/stub/StubStatusCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/src/main/java/org/apache/maven/scm/provider/stub/StubStatusCommand.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/src/main/java/org/apache/maven/scm/provider/stub/StubTagCommand.java
URL: http://svn.apache.org/viewvc/maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/src/main/java/org/apache/maven/scm/provider/stub/StubTagCommand.java?rev=735353&view=auto
==============================================================================
--- maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/src/main/java/org/apache/maven/scm/provider/stub/StubTagCommand.java (added)
+++ maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/src/main/java/org/apache/maven/scm/provider/stub/StubTagCommand.java Sat Jan 17 14:58:36 2009
@@ -0,0 +1,110 @@
+package org.apache.maven.scm.provider.stub;
+
+/*
+ * 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.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.maven.scm.CommandParameter;
+import org.apache.maven.scm.CommandParameters;
+import org.apache.maven.scm.ScmException;
+import org.apache.maven.scm.ScmFile;
+import org.apache.maven.scm.ScmFileSet;
+import org.apache.maven.scm.ScmFileStatus;
+import org.apache.maven.scm.ScmResult;
+import org.apache.maven.scm.command.AbstractCommand;
+import org.apache.maven.scm.command.tag.TagScmResult;
+import org.apache.maven.scm.provider.ScmProviderRepository;
+import org.codehaus.plexus.util.FileUtils;
+
+/**
+ * A dummy tag command.
+ * 
+ * @author Benjamin Bentmann
+ * @version $Id$
+ */
+class StubTagCommand
+    extends AbstractCommand
+{
+
+    protected ScmResult executeCommand( ScmProviderRepository repository, ScmFileSet fileSet,
+                                        CommandParameters parameters )
+        throws ScmException
+    {
+        List taggedFiles = new ArrayList();
+
+        try
+        {
+            StubScmProviderRepository stubRepo = (StubScmProviderRepository) repository;
+
+            File workingCopyRoot = stubRepo.getWorkingCopyRoot( fileSet );
+            File repoRoot = stubRepo.getRoot();
+            String tagName = parameters.getString( CommandParameter.TAG_NAME );
+            File tagRoot = new File( stubRepo.getTagBase(), tagName );
+
+            getLogger().info( "Tagging: " + repoRoot + " > " + tagRoot );
+
+            if ( tagRoot.exists() )
+            {
+                throw new IOException( "Cannot override existing tag" );
+            }
+
+            List paths = stubRepo.getPaths( workingCopyRoot, fileSet );
+            if ( paths.isEmpty() )
+            {
+                paths.add( "." );
+            }
+
+            for ( Iterator it = paths.iterator(); it.hasNext(); )
+            {
+                String path = (String) it.next();
+                File srcFile = new File( repoRoot, path );
+                File dstFile = new File( tagRoot, path );
+
+                getLogger().info( "  " + path );
+
+                if ( srcFile.isDirectory() )
+                {
+                    FileUtils.copyDirectoryStructure( srcFile, dstFile );
+                }
+                else if ( srcFile.isFile() )
+                {
+                    FileUtils.copyFile( srcFile, dstFile );
+                }
+                else
+                {
+                    throw new IOException( "Cannot tag non-existing file: " + srcFile );
+                }
+
+                taggedFiles.add( new ScmFile( path, ScmFileStatus.TAGGED ) );
+            }
+        }
+        catch ( IOException e )
+        {
+            throw new ScmException( "Error while tagging the files.", e );
+        }
+
+        return new TagScmResult( null, taggedFiles );
+    }
+
+}

Propchange: maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/src/main/java/org/apache/maven/scm/provider/stub/StubTagCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/release/trunk/maven-release-plugin/src/it/maven-scm-provider-stub/src/main/java/org/apache/maven/scm/provider/stub/StubTagCommand.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision