diff --git a/maven-release-api/src/main/java/org/apache/maven/shared/release/config/ReleaseDescriptor.java b/maven-release-api/src/main/java/org/apache/maven/shared/release/config/ReleaseDescriptor.java
index dbf145331..48ff5ac97 100644
--- a/maven-release-api/src/main/java/org/apache/maven/shared/release/config/ReleaseDescriptor.java
+++ b/maven-release-api/src/main/java/org/apache/maven/shared/release/config/ReleaseDescriptor.java
@@ -284,6 +284,15 @@ public interface ReleaseDescriptor
*/
String getScmCommentPrefix();
+ /**
+ * Get whether to use a shallow clone with no history or a full clone containing the full history during the
+ * release.
+ *
+ * @return boolean
+ * @since 3.0.0-M6
+ */
+ boolean isScmShallowClone();
+
/**
* Get the SCM commit comment when setting pom.xml to release.
*
diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/config/ReleaseDescriptorBuilder.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/config/ReleaseDescriptorBuilder.java
index 60ab0fa18..6940d31da 100644
--- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/config/ReleaseDescriptorBuilder.java
+++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/config/ReleaseDescriptorBuilder.java
@@ -473,6 +473,19 @@ public ReleaseDescriptorBuilder setScmCommentPrefix( String scmCommentPrefix )
return this;
}
+ /**
+ *
setScmShallowClone.
+ *
+ * @param scmShallowClone a boolean
+ * @return a {@link org.apache.maven.shared.release.config.ReleaseDescriptorBuilder} object
+ * @since 3.0.0-M6
+ */
+ public ReleaseDescriptorBuilder setScmShallowClone( boolean scmShallowClone )
+ {
+ releaseDescriptor.setScmShallowClone( scmShallowClone );
+ return this;
+ }
+
/**
* setScmReleaseCommitComment.
*
diff --git a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckoutProjectFromScm.java b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckoutProjectFromScm.java
index 29e4308fd..1eb3682bd 100644
--- a/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckoutProjectFromScm.java
+++ b/maven-release-manager/src/main/java/org/apache/maven/shared/release/phase/CheckoutProjectFromScm.java
@@ -218,7 +218,8 @@ private ReleaseResult performCheckout( ReleaseDescriptor releaseDescriptor, Rele
checkoutDirectory.mkdirs();
CommandParameters commandParameters = new CommandParameters();
- commandParameters.setString( CommandParameter.SHALLOW, Boolean.TRUE.toString() );
+ commandParameters.setString( CommandParameter.SHALLOW,
+ Boolean.valueOf( releaseDescriptor.isScmShallowClone() ).toString() );
CheckOutScmResult scmResult = provider.checkOut( repository, new ScmFileSet( checkoutDirectory ),
new ScmTag( releaseDescriptor.getScmReleaseLabel() ), commandParameters );
diff --git a/maven-release-manager/src/main/mdo/release-descriptor.mdo b/maven-release-manager/src/main/mdo/release-descriptor.mdo
index 1e8eeff42..871637ace 100644
--- a/maven-release-manager/src/main/mdo/release-descriptor.mdo
+++ b/maven-release-manager/src/main/mdo/release-descriptor.mdo
@@ -68,6 +68,16 @@
The prefix of SCM modification messages
+
+ scmShallowClone
+ 3.0.0+
+ boolean
+ true
+
+ Get whether to use a shallow clone with no history or a full clone containing the full history during the
+ release
+
+
scmReleaseCommitComment
3.0.0+
diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/CheckoutProjectFromScmTest.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/CheckoutProjectFromScmTest.java
index c94acf393..998a62354 100644
--- a/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/CheckoutProjectFromScmTest.java
+++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/CheckoutProjectFromScmTest.java
@@ -22,7 +22,6 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail;
-import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.argThat;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
@@ -34,7 +33,7 @@
import java.util.List;
import org.apache.maven.project.MavenProject;
-import org.apache.maven.scm.CommandParameters;
+import org.apache.maven.scm.CommandParameter;
import org.apache.maven.scm.ScmFileSet;
import org.apache.maven.scm.ScmTag;
import org.apache.maven.scm.command.checkout.CheckOutScmResult;
@@ -86,8 +85,8 @@ public void testExecuteStandard()
when( scmProviderMock.checkOut( eq( repository ),
argThat( new IsScmFileSetEquals( new ScmFileSet( checkoutDirectory ) ) ),
argThat( new IsScmTagEquals( new ScmTag( "release-label" ) ) ),
- any( CommandParameters.class)))
- .thenReturn( new CheckOutScmResult( "",null ) );
+ argThat( new HasCommandParameter( CommandParameter.SHALLOW, true ) ) ) )
+ .thenReturn( new CheckOutScmResult( "", null ) );
ScmManagerStub stub = (ScmManagerStub) lookup( ScmManager.class );
stub.setScmProvider( scmProviderMock );
@@ -106,7 +105,7 @@ public void testExecuteStandard()
verify( scmProviderMock ).checkOut( eq( repository ),
argThat( new IsScmFileSetEquals( new ScmFileSet( checkoutDirectory ) ) ),
argThat( new IsScmTagEquals( new ScmTag( "release-label" ) ) ),
- any( CommandParameters.class ));
+ argThat( new HasCommandParameter( CommandParameter.SHALLOW, true ) ) );
verifyNoMoreInteractions( scmProviderMock );
}
@@ -129,7 +128,7 @@ public void testExecuteMultiModuleWithDeepSubprojects()
when( scmProviderMock.checkOut( eq( repository ),
argThat( new IsScmFileSetEquals( new ScmFileSet( checkoutDirectory ) ) ),
argThat( new IsScmTagEquals( new ScmTag( "release-label" ) ) ),
- any(CommandParameters.class)))
+ argThat( new HasCommandParameter( CommandParameter.SHALLOW, true ) ) ) )
.thenReturn( new CheckOutScmResult( "", null ) );
ScmManagerStub stub = (ScmManagerStub) lookup( ScmManager.class );
@@ -149,7 +148,7 @@ public void testExecuteMultiModuleWithDeepSubprojects()
verify( scmProviderMock ).checkOut( eq( repository ),
argThat( new IsScmFileSetEquals( new ScmFileSet( checkoutDirectory ) ) ),
argThat( new IsScmTagEquals( new ScmTag( "release-label" ) ) ),
- any( CommandParameters.class ));
+ argThat( new HasCommandParameter( CommandParameter.SHALLOW, true ) ) );
verifyNoMoreInteractions( scmProviderMock );
}
@@ -172,8 +171,8 @@ public void testExecuteFlatMultiModule()
when( scmProviderMock.checkOut( eq( repository ),
argThat( new IsScmFileSetEquals( new ScmFileSet( checkoutDirectory ) ) ),
argThat( new IsScmTagEquals( new ScmTag( "release-label" ) ) ),
- any( CommandParameters.class )) )
- .thenReturn( new CheckOutScmResult( "",null ) );
+ argThat( new HasCommandParameter( CommandParameter.SHALLOW, true ) ) ) )
+ .thenReturn( new CheckOutScmResult( "", null ) );
ScmManagerStub stub = (ScmManagerStub) lookup( ScmManager.class );
stub.setScmProvider( scmProviderMock );
@@ -193,7 +192,7 @@ public void testExecuteFlatMultiModule()
verify( scmProviderMock ).checkOut( eq( repository ),
argThat( new IsScmFileSetEquals( new ScmFileSet( checkoutDirectory ) ) ),
argThat( new IsScmTagEquals( new ScmTag( "release-label" ) ) ),
- any( CommandParameters.class ));
+ argThat( new HasCommandParameter( CommandParameter.SHALLOW, true ) ) );
verifyNoMoreInteractions( scmProviderMock );
}
@@ -257,4 +256,4 @@ public void testScmRepositoryExceptionThrown()
}
}
-}
\ No newline at end of file
+}
diff --git a/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/HasCommandParameter.java b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/HasCommandParameter.java
new file mode 100644
index 000000000..99c02fa65
--- /dev/null
+++ b/maven-release-manager/src/test/java/org/apache/maven/shared/release/phase/HasCommandParameter.java
@@ -0,0 +1,60 @@
+package org.apache.maven.shared.release.phase;
+
+/*
+ * 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.CommandParameter;
+import org.apache.maven.scm.CommandParameters;
+import org.apache.maven.scm.ScmException;
+import org.mockito.ArgumentMatcher;
+
+/**
+ * Mockito constraint to check if a command parameter has a specific value.
+ *
+ * @author Michael Cramer
+ */
+public class HasCommandParameter implements ArgumentMatcher
+{
+ private final CommandParameter commandParameter;
+
+ private final Object expected;
+
+ public HasCommandParameter( CommandParameter commandParameter, Object expected )
+ {
+ this.commandParameter = commandParameter;
+ this.expected = expected;
+ }
+
+ @Override
+ public boolean matches( CommandParameters argument )
+ {
+ CommandParameters commandParameters = (CommandParameters) argument;
+
+ try
+ {
+ return commandParameters.getString( this.commandParameter ).equals( String.valueOf( expected ) );
+ }
+ catch ( ScmException e )
+ {
+ return false;
+ }
+ }
+
+
+}
diff --git a/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/AbstractScmReleaseMojo.java b/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/AbstractScmReleaseMojo.java
index ee3283904..fcdda10b0 100644
--- a/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/AbstractScmReleaseMojo.java
+++ b/maven-release-plugin/src/main/java/org/apache/maven/plugins/release/AbstractScmReleaseMojo.java
@@ -89,6 +89,12 @@ public abstract class AbstractScmReleaseMojo
@Parameter( defaultValue = "[maven-release-plugin] ", property = "scmCommentPrefix" )
private String scmCommentPrefix;
+ /**
+ * When cloning a repository if it should be a shallow clone or a full clone.
+ */
+ @Parameter( defaultValue = "true", property = "scmShallowClone" )
+ private boolean scmShallowClone = true;
+
/**
* Implemented with git will or not push changes to the upstream repository.
* true
by default to preserve backward compatibility.
@@ -149,6 +155,7 @@ protected ReleaseDescriptorBuilder createReleaseDescriptor()
descriptor.setScmTagBase( tagBase );
descriptor.setScmUsername( username );
descriptor.setScmCommentPrefix( scmCommentPrefix );
+ descriptor.setScmShallowClone( scmShallowClone );
descriptor.setPushChanges( pushChanges );
descriptor.setWorkItem( workItem );