You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mi...@apache.org on 2020/12/24 17:28:06 UTC
[maven-deploy-plugin] branch master updated: [MDEPLOY-265] Allow
old alt*DeploymentRepository property format if default layout is used
This is an automated email from the ASF dual-hosted git repository.
michaelo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-deploy-plugin.git
The following commit(s) were added to refs/heads/master by this push:
new 02a055b [MDEPLOY-265] Allow old alt*DeploymentRepository property format if default layout is used
02a055b is described below
commit 02a055bde67f23cf908f97a04813c044d16c5490
Author: Phil Clay <ph...@users.noreply.github.com>
AuthorDate: Tue Dec 22 08:37:41 2020 -0800
[MDEPLOY-265] Allow old alt*DeploymentRepository property format if default layout is used
The legacy format (<=2.x) of alt*DeploymentRepository is id::layout::url.
The new format (>= 3.x) of alt*DeploymentRepository is id::url which is
equivalent to id::default:url from the legacy format.
This change introduces backwards compatibility with 2.x by supporting
alt*DeploymentRepository values in the id::layout::url format if and only if
the layout is equal to "default". The "default" layout is the most commonly
used layout, so this should maintain backwards compatibility with the large
majority of projects using the alt*DeploymentRepository properties.
* Usage of the legacy format with the "default" layout will result in a warning
message being logged.
* Usage of the legacy format with layouts other than "default" will result in
an exception being thrown.
This closes #15
---
.../apache/maven/plugins/deploy/DeployMojo.java | 7 +++---
.../maven/plugins/deploy/DeployMojoTest.java | 29 ++++++----------------
2 files changed, 11 insertions(+), 25 deletions(-)
diff --git a/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java b/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java
index ab0c72b..ae26134 100644
--- a/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java
+++ b/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java
@@ -259,10 +259,9 @@ public class DeployMojo
if ( "default".equals( layout ) )
{
- throw new MojoFailureException( altDeploymentRepo,
- "Invalid legacy syntax for repository.",
- "Invalid legacy syntax for alternative repository. Use \"" + id + "::" + url + "\" instead."
- );
+ getLog().warn( "Using legacy syntax for alternative repository. "
+ + "Use \"" + id + "::" + url + "\" instead." );
+ repo = createDeploymentArtifactRepository( id, url );
}
else
{
diff --git a/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java b/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java
index 9a02b1c..63fe2de 100644
--- a/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java
+++ b/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java
@@ -568,16 +568,10 @@ public class DeployMojoTest
new ProjectDeployerRequest()
.setProject( project )
.setAltDeploymentRepository( "altDeploymentRepository::default::http://localhost" );
- try
- {
- mojo.getDeploymentRepository( pdr );
- fail( "Should throw: Invalid legacy syntax for repository." );
- }
- catch( MojoFailureException e )
- {
- assertEquals( e.getMessage(), "Invalid legacy syntax for repository.");
- assertEquals( e.getLongMessage(), "Invalid legacy syntax for alternative repository. Use \"altDeploymentRepository::http://localhost\" instead.");
- }
+
+ assertEquals( repository,
+ mojo.getDeploymentRepository( pdr ) );
+
}
public void testLegacyAltDeploymentRepositoryWithLegacyLayout()
@@ -640,7 +634,7 @@ public class DeployMojoTest
DeployMojo mojo = spy( new DeployMojo() );
ArtifactRepository repository = mock( ArtifactRepository.class );
- when( mojo.createDeploymentArtifactRepository( "altDeploymentRepository", "http://localhost"
+ when( mojo.createDeploymentArtifactRepository( "altDeploymentRepository", "scm:svn:http://localhost"
) ).thenReturn( repository );
project.setVersion( "1.0-SNAPSHOT" );
@@ -649,16 +643,9 @@ public class DeployMojoTest
new ProjectDeployerRequest()
.setProject( project )
.setAltDeploymentRepository( "altDeploymentRepository::default::scm:svn:http://localhost" );
- try
- {
- mojo.getDeploymentRepository( pdr );
- fail( "Should throw: Invalid legacy syntax for repository." );
- }
- catch( MojoFailureException e )
- {
- assertEquals( e.getMessage(), "Invalid legacy syntax for repository.");
- assertEquals( e.getLongMessage(), "Invalid legacy syntax for alternative repository. Use \"altDeploymentRepository::scm:svn:http://localhost\" instead.");
- }
+
+ assertEquals( repository,
+ mojo.getDeploymentRepository( pdr ) );
}
public void testLegacyScmSvnAltDeploymentRepository()
throws Exception