maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r526078 - in /maven/release/trunk/maven-release-manager/src: main/java/org/apache/maven/shared/release/ main/java/org/apache/maven/shared/release/scm/ main/resources/META-INF/plexus/ test/java/org/apache/maven/shared/release/
Date Fri, 06 Apr 2007 07:17:40 GMT
Author: evenisse
Date: Fri Apr  6 00:17:39 2007
New Revision: 526078

URL: http://svn.apache.org/viewvc?view=rev&rev=526078
Log:
[MRELEASE-208] Support for ClearCase, and other SCMs that do checkout projects to subdirectories
of the checkout directory
Submitted by: Arne Degenring

Added:
    maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/scm/ClearCaseScmTranslator.java
  (with props)
Modified:
    maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/DefaultReleaseManager.java
    maven/release/trunk/maven-release-manager/src/main/resources/META-INF/plexus/components.xml
    maven/release/trunk/maven-release-manager/src/test/java/org/apache/maven/shared/release/DefaultReleaseManagerTest.java

Modified: maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/DefaultReleaseManager.java
URL: http://svn.apache.org/viewvc/maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/DefaultReleaseManager.java?view=diff&rev=526078&r1=526077&r2=526078
==============================================================================
--- maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/DefaultReleaseManager.java
(original)
+++ maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/DefaultReleaseManager.java
Fri Apr  6 00:17:39 2007
@@ -431,7 +431,8 @@
 
         try
         {
-            mavenExecutor.executeGoals( checkoutDirectory, goals, config.isInteractive(),
additionalArguments,
+            File workingDirectory = determineWorkingDirectory(checkoutDirectory, scmResult.getRelativePathProjectDirectory());
+            mavenExecutor.executeGoals( workingDirectory, goals, config.isInteractive(),
additionalArguments,
                                         config.getPomFileName(), result );
         }
         catch ( MavenExecutorException e )
@@ -448,6 +449,30 @@
         updateListener( listener, "cleanup", PHASE_END );
 
         updateListener( listener, "perform", GOAL_END );
+    }
+
+    /**
+     * Determines the path of the working directory. By default, this is the
+     * checkout directory. For some SCMs, the project root directory is not the
+     * checkout directory itself, but a SCM-specific subdirectory.
+     * 
+     * @param checkoutDirectory
+     *            The checkout directory as java.io.File
+     * @param relativePathProjectDirectory
+     *            The relative path of the project directory within the checkout
+     *            directory or ""
+     * @return The working directory
+     */
+    protected File determineWorkingDirectory( File checkoutDirectory, String relativePathProjectDirectory)
+    {
+        if ( StringUtils.isNotEmpty( relativePathProjectDirectory ) )
+        {
+            return new File( checkoutDirectory, relativePathProjectDirectory );
+        }
+        else
+        {
+            return checkoutDirectory;
+        }
     }
 
     private ReleaseDescriptor loadReleaseDescriptor( ReleaseDescriptor releaseDescriptor,

Added: maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/scm/ClearCaseScmTranslator.java
URL: http://svn.apache.org/viewvc/maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/scm/ClearCaseScmTranslator.java?view=auto&rev=526078
==============================================================================
--- maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/scm/ClearCaseScmTranslator.java
(added)
+++ maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/scm/ClearCaseScmTranslator.java
Fri Apr  6 00:17:39 2007
@@ -0,0 +1,46 @@
+package org.apache.maven.shared.release.scm;
+
+/*
+ * 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.
+ */
+
+/**
+ * ClearCase tag translator.
+ *
+ * @author <a href="mailto:arne@degenring.com">Arne Degenring</a>
+ */
+public class ClearCaseScmTranslator
+    implements ScmTranslator
+{
+    public String translateTagUrl( String url, String tag, String tagBase )
+    {
+        return url;
+    }
+
+    public String resolveTag( String tag )
+    {
+        if ( !"HEAD".equals( tag ) )
+        {
+            return tag;
+        }
+        else
+        {
+            return null;
+        }
+    }
+}

Propchange: maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/scm/ClearCaseScmTranslator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/release/trunk/maven-release-manager/src/main/java/org/apache/maven/shared/release/scm/ClearCaseScmTranslator.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Modified: maven/release/trunk/maven-release-manager/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewvc/maven/release/trunk/maven-release-manager/src/main/resources/META-INF/plexus/components.xml?view=diff&rev=526078&r1=526077&r2=526078
==============================================================================
--- maven/release/trunk/maven-release-manager/src/main/resources/META-INF/plexus/components.xml
(original)
+++ maven/release/trunk/maven-release-manager/src/main/resources/META-INF/plexus/components.xml
Fri Apr  6 00:17:39 2007
@@ -266,6 +266,11 @@
       <implementation>org.apache.maven.shared.release.scm.CvsScmTranslator</implementation>
     </component>
     <component>
+      <role>org.apache.maven.shared.release.scm.ScmTranslator</role>
+      <role-hint>clearcase</role-hint>
+      <implementation>org.apache.maven.shared.release.scm.ClearCaseScmTranslator</implementation>
+    </component>
+    <component>
       <role>org.apache.maven.shared.release.exec.MavenExecutor</role>
       <implementation>org.apache.maven.shared.release.exec.ForkedMavenExecutor</implementation>
       <requirements>

Modified: maven/release/trunk/maven-release-manager/src/test/java/org/apache/maven/shared/release/DefaultReleaseManagerTest.java
URL: http://svn.apache.org/viewvc/maven/release/trunk/maven-release-manager/src/test/java/org/apache/maven/shared/release/DefaultReleaseManagerTest.java?view=diff&rev=526078&r1=526077&r2=526078
==============================================================================
--- maven/release/trunk/maven-release-manager/src/test/java/org/apache/maven/shared/release/DefaultReleaseManagerTest.java
(original)
+++ maven/release/trunk/maven-release-manager/src/test/java/org/apache/maven/shared/release/DefaultReleaseManagerTest.java
Fri Apr  6 00:17:39 2007
@@ -43,6 +43,7 @@
 import org.apache.maven.shared.release.scm.ReleaseScmRepositoryException;
 import org.apache.maven.shared.release.scm.ScmRepositoryConfigurator;
 import org.codehaus.plexus.PlexusTestCase;
+import org.codehaus.plexus.util.FileUtils;
 import org.jmock.Mock;
 import org.jmock.core.Constraint;
 import org.jmock.core.constraint.IsAnything;
@@ -762,4 +763,28 @@
         }
     }
 
+    public void testDetermineWorkingDirectory()
+        throws Exception
+    {
+        DefaultReleaseManager defaultReleaseManager = new DefaultReleaseManager();
+        
+        File checkoutDir = getTestFile( "target/checkout" );
+        FileUtils.forceDelete( checkoutDir );
+        checkoutDir.mkdirs();
+
+        File projectDir = getTestFile( "target/checkout/my/project" );
+        projectDir.mkdirs();
+
+        // only checkout dir
+        assertEquals( checkoutDir, defaultReleaseManager.determineWorkingDirectory( checkoutDir,
"" ) );
+        assertEquals( checkoutDir, defaultReleaseManager.determineWorkingDirectory( checkoutDir,
null ) );
+
+        // checkout dir and relative path project dir
+        assertEquals( projectDir, defaultReleaseManager.determineWorkingDirectory( checkoutDir,
"my/project" ) );
+        assertEquals( projectDir, defaultReleaseManager.determineWorkingDirectory( checkoutDir,
"my/project/" ) );
+        assertEquals( projectDir, defaultReleaseManager.determineWorkingDirectory( checkoutDir,
"my"
+                + File.separator + "project" ) );
+
+        FileUtils.forceDelete( checkoutDir);
+    }
 }



Mime
View raw message