You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by kh...@apache.org on 2019/03/14 21:29:21 UTC
[maven-deploy-plugin] 01/01: [MDEPLOY-244] - maven deploy plugin
3.0.0-M1 breaks RPM deploys
This is an automated email from the ASF dual-hosted git repository.
khmarbaise pushed a commit to branch MDEPLOY-244
in repository https://gitbox.apache.org/repos/asf/maven-deploy-plugin.git
commit 5ae22c929e6f6fa63a2c03e59989b70c636b6989
Author: Karl Heinz Marbaise <kh...@apache.org>
AuthorDate: Sat Oct 13 13:05:55 2018 +0200
[MDEPLOY-244] - maven deploy plugin 3.0.0-M1 breaks RPM deploys
---
.../apache/maven/plugins/deploy/DeployMojo.java | 26 +++++++++++++------
src/site/apt/index.apt.vm | 2 +-
.../maven/plugins/deploy/DeployMojoTest.java | 29 ++++++++++++++++++++++
3 files changed, 48 insertions(+), 9 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 5953d6e..084c411 100644
--- a/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java
+++ b/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java
@@ -55,6 +55,8 @@ public class DeployMojo
private static final Pattern ALT_REPO_SYNTAX_PATTERN = Pattern.compile( "(.+)::(.+)" );
+ private static final Pattern OLD_ALT_REPO_SYNTAX_PATTERN = Pattern.compile( "(.+)::(.+)::(.+)" );
+
/**
* When building with multiple threads, reaching the last project doesn't have to mean that all projects are ready
* to be deployed
@@ -85,7 +87,6 @@ public class DeployMojo
/**
* Specifies an alternative repository to which the project artifacts should be deployed ( other than those
* specified in <distributionManagement> ). <br/>
- * Format: <code>id::url</code>
* <dl>
* <dt>id</dt>
* <dd>The id can be used to pick up the correct credentials from the settings.xml</dd>
@@ -240,20 +241,24 @@ public class DeployMojo
{
getLog().info( "Using alternate deployment repository " + altDeploymentRepo );
- Matcher matcher = ALT_REPO_SYNTAX_PATTERN.matcher( altDeploymentRepo );
+ if ( matchesOldSyntax( altDeploymentRepo ) )
+ {
+ throw new MojoFailureException( altDeploymentRepo,
+ "The syntax for the alternative repository has been changed.",
+ "Please use \"id::url\" instead of \"id::layout::url\"." );
+ }
+ Matcher matcher = ALT_REPO_SYNTAX_PATTERN.matcher( altDeploymentRepo );
if ( !matcher.matches() )
{
throw new MojoFailureException( altDeploymentRepo, "Invalid syntax for repository.",
"Invalid syntax for alternative repository. Use \"id::url\"." );
}
- else
- {
- String id = matcher.group( 1 ).trim();
- String url = matcher.group( 2 ).trim();
- repo = createDeploymentArtifactRepository( id, url );
- }
+ String id = matcher.group( 1 ).trim();
+ String url = matcher.group( 2 ).trim();
+
+ repo = createDeploymentArtifactRepository( id, url );
}
if ( repo == null )
@@ -272,4 +277,9 @@ public class DeployMojo
return repo;
}
+ private boolean matchesOldSyntax( String repo )
+ {
+ return OLD_ALT_REPO_SYNTAX_PATTERN.matcher( repo ).matches();
+ }
+
}
diff --git a/src/site/apt/index.apt.vm b/src/site/apt/index.apt.vm
index a23f6a0..2616c71 100644
--- a/src/site/apt/index.apt.vm
+++ b/src/site/apt/index.apt.vm
@@ -92,7 +92,7 @@ ${project.name}
[]
- As of Maven 3, snapshot artifacts will always be deployed using a timestamped version.
+ As of Maven 3, snapshot artifacts will always be deployed using a time stamped version.
* Usage
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 6c6f938..50dc2dc 100644
--- a/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java
+++ b/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java
@@ -32,6 +32,7 @@ import java.util.Properties;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugin.testing.AbstractMojoTestCase;
import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
import org.apache.maven.plugins.deploy.stubs.ArtifactDeployerStub;
@@ -43,6 +44,7 @@ import org.apache.maven.repository.internal.MavenRepositorySystemSession;
import org.apache.maven.shared.transfer.project.deploy.ProjectDeployerRequest;
import org.codehaus.plexus.util.FileUtils;
import org.junit.Ignore;
+import org.junit.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
@@ -589,7 +591,34 @@ public class DeployMojoTest
assertEquals( repository,
mojo.getDeploymentRepository( pdr ));
}
+
+
+ public void testWrongOldRepositoryformatForDeploymentRepository()
+ throws MojoExecutionException, MojoFailureException
+ {
+ DeployMojo mojo = spy( new DeployMojo() );
+
+ ArtifactRepository repository = mock( ArtifactRepository.class );
+ when( mojo.createDeploymentArtifactRepository( "altReleaseDeploymentRepository",
+ "http://localhost" ) ).thenReturn( repository );
+
+ project.setVersion( "1.0" );
+
+ ProjectDeployerRequest pdr =
+ new ProjectDeployerRequest().setProject( project ).setAltDeploymentRepository( "altDeploymentRepository::layout::http://localhost" );
+
+ try
+ {
+ mojo.getDeploymentRepository( pdr );
+ fail( "We have expected an MojoFailureException" );
+ }
+ catch ( MojoFailureException e )
+ {
+ // Intentionally empty.
+ }
+ }
+
private void addFileToList( File file, List<String> fileList )
{
if( !file.isDirectory() )