Skip to content

Commit 02a055b

Browse files
philsttrmichael-o
authored andcommitted
[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
1 parent 92d7e74 commit 02a055b

File tree

2 files changed

+11
-25
lines changed

2 files changed

+11
-25
lines changed

src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,10 +259,9 @@ else if ( !ArtifactUtils.isSnapshot( project.getVersion() ) && altReleaseDeploym
259259

260260
if ( "default".equals( layout ) )
261261
{
262-
throw new MojoFailureException( altDeploymentRepo,
263-
"Invalid legacy syntax for repository.",
264-
"Invalid legacy syntax for alternative repository. Use \"" + id + "::" + url + "\" instead."
265-
);
262+
getLog().warn( "Using legacy syntax for alternative repository. "
263+
+ "Use \"" + id + "::" + url + "\" instead." );
264+
repo = createDeploymentArtifactRepository( id, url );
266265
}
267266
else
268267
{

src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -568,16 +568,10 @@ public void testLegacyAltDeploymentRepositoryWithDefaultLayout()
568568
new ProjectDeployerRequest()
569569
.setProject( project )
570570
.setAltDeploymentRepository( "altDeploymentRepository::default::http://localhost" );
571-
try
572-
{
573-
mojo.getDeploymentRepository( pdr );
574-
fail( "Should throw: Invalid legacy syntax for repository." );
575-
}
576-
catch( MojoFailureException e )
577-
{
578-
assertEquals( e.getMessage(), "Invalid legacy syntax for repository.");
579-
assertEquals( e.getLongMessage(), "Invalid legacy syntax for alternative repository. Use \"altDeploymentRepository::http://localhost\" instead.");
580-
}
571+
572+
assertEquals( repository,
573+
mojo.getDeploymentRepository( pdr ) );
574+
581575
}
582576

583577
public void testLegacyAltDeploymentRepositoryWithLegacyLayout()
@@ -640,7 +634,7 @@ public void testDefaultScmSvnAltDeploymentRepository()
640634
DeployMojo mojo = spy( new DeployMojo() );
641635

642636
ArtifactRepository repository = mock( ArtifactRepository.class );
643-
when( mojo.createDeploymentArtifactRepository( "altDeploymentRepository", "http://localhost"
637+
when( mojo.createDeploymentArtifactRepository( "altDeploymentRepository", "scm:svn:http://localhost"
644638
) ).thenReturn( repository );
645639

646640
project.setVersion( "1.0-SNAPSHOT" );
@@ -649,16 +643,9 @@ public void testDefaultScmSvnAltDeploymentRepository()
649643
new ProjectDeployerRequest()
650644
.setProject( project )
651645
.setAltDeploymentRepository( "altDeploymentRepository::default::scm:svn:http://localhost" );
652-
try
653-
{
654-
mojo.getDeploymentRepository( pdr );
655-
fail( "Should throw: Invalid legacy syntax for repository." );
656-
}
657-
catch( MojoFailureException e )
658-
{
659-
assertEquals( e.getMessage(), "Invalid legacy syntax for repository.");
660-
assertEquals( e.getLongMessage(), "Invalid legacy syntax for alternative repository. Use \"altDeploymentRepository::scm:svn:http://localhost\" instead.");
661-
}
646+
647+
assertEquals( repository,
648+
mojo.getDeploymentRepository( pdr ) );
662649
}
663650
public void testLegacyScmSvnAltDeploymentRepository()
664651
throws Exception

0 commit comments

Comments
 (0)