You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by gn...@apache.org on 2022/03/08 10:48:22 UTC
[maven-deploy-plugin] branch mvn4 updated: runtime support
This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a commit to branch mvn4
in repository https://gitbox.apache.org/repos/asf/maven-deploy-plugin.git
The following commit(s) were added to refs/heads/mvn4 by this push:
new 1b5577e runtime support
1b5577e is described below
commit 1b5577e5aa5cecf6b85a62ba5b217d0c46cb884c
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Tue Mar 8 11:48:20 2022 +0100
runtime support
---
pom.xml | 76 +-
.../maven/plugins/deploy/AbstractDeployMojo.java | 6 +-
.../maven/plugins/deploy/DeployFileMojo.java | 35 +-
.../apache/maven/plugins/deploy/DeployMojo.java | 41 +-
.../maven/plugins/deploy/DeployFileMojoTest.java | 332 ++++-----
.../plugins/deploy/DeployFileMojoUnitTest.java | 101 +--
.../maven/plugins/deploy/DeployMojoTest.java | 762 ++++++---------------
.../org/apache/maven/plugins/deploy/Utils.java | 2 +-
.../deploy/stubs/ArtifactRepositoryStub.java | 134 ----
.../deploy/stubs/ArtifactRepositoryStub2.java | 60 --
.../maven/plugins/deploy/stubs/ArtifactStub.java | 189 +++++
.../plugins/deploy/stubs/AttachedArtifactStub.java | 38 -
.../plugins/deploy/stubs/DeployArtifactStub.java | 139 ----
.../plugins/deploy/stubs/MavenProjectStub.java | 35 -
.../plugins/deploy/stubs/ProjectDeployerStub.java | 34 -
.../maven/plugins/deploy/stubs/ProjectStub.java | 45 +-
.../maven/plugins/deploy/stubs/SessionStub.java | 217 ++++++
.../unit/basic-deploy-pom/plugin-config.xml | 39 --
.../unit/basic-deploy-scp/plugin-config.xml | 38 -
.../target/deploy-test-file-1.0-SNAPSHOT.jar | 1 -
.../target/deploy-test-file-1.0-SNAPSHOT.jar | 1 -
.../plugin-config.xml | 41 --
.../target/deploy-test-file-1.0-SNAPSHOT.jar | 1 -
.../attached-artifact-test-1.0-SNAPSHOT.jar} | 0
.../deploy-test-file-1.0-SNAPSHOT.jar | 0
.../deploy-test-file-1.0-SNAPSHOT.pom | 0
.../plugin-config.xml | Bin 3254 -> 4414 bytes
.../deploy-test-file-1.0-SNAPSHOT.jar | 0
.../target => deploy-file}/deploy-test-file.zip | 0
.../plugin-config-artifact-not-jar.xml} | 4 +-
.../plugin-config-classifier.xml} | 4 +-
.../plugin-config-pom-file.xml} | Bin 3166 -> 3116 bytes
.../plugin-config-test.xml} | 2 +-
33 files changed, 855 insertions(+), 1522 deletions(-)
diff --git a/pom.xml b/pom.xml
index ac1076f..81a6d24 100644
--- a/pom.xml
+++ b/pom.xml
@@ -26,7 +26,6 @@ under the License.
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugins</artifactId>
<version>35-SNAPSHOT</version>
- <relativePath>../../pom/maven/maven-plugins/pom.xml</relativePath>
</parent>
<artifactId>maven-deploy-plugin</artifactId>
@@ -73,84 +72,50 @@ under the License.
<groupId>org.apache.maven</groupId>
<artifactId>maven-core-api</artifactId>
<version>${mavenVersion}</version>
+ <scope>provided</scope>
</dependency>
<dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-core</artifactId>
- <version>${mavenVersion}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-model</artifactId>
- <version>${mavenVersion}</version>
- </dependency>
-<!-- <dependency>-->
-<!-- <groupId>org.apache.maven</groupId>-->
-<!-- <artifactId>maven-artifact</artifactId>-->
-<!-- <version>${mavenVersion}</version>-->
-<!-- </dependency>-->
-
-<!-- <dependency>-->
-<!-- <groupId>org.apache.maven.shared</groupId>-->
-<!-- <artifactId>maven-artifact-transfer</artifactId>-->
-<!-- <version>2.0.0-SNAPSHOT</version>-->
-<!-- </dependency>-->
- <!-- Upgrade of transitive dependency. -->
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- <version>2.5</version>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.7.5</version>
+ <scope>provided</scope>
</dependency>
-
- <!-- dependencies to annotations -->
<dependency>
- <groupId>org.apache.maven.plugin-tools</groupId>
- <artifactId>maven-plugin-annotations</artifactId>
- <scope>provided</scope>
+ <groupId>org.apache.maven.shared</groupId>
+ <artifactId>maven-shared-utils</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
- <version>3.2.0</version>
</dependency>
+
<dependency>
<groupId>org.apache.maven.plugin-testing</groupId>
<artifactId>maven-plugin-testing-harness</artifactId>
<version>3.4.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
- <dependency> <!-- used by maven-plugin-testing-harness, don't give it compile scope! -->
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-compat</artifactId>
- <version>${mavenVersion}</version>
- <scope>test</scope>
- </dependency>
<dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- <version>2.28.2</version>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>2.6</version>
<scope>test</scope>
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.13.1</version>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-core</artifactId>
+ <version>${mavenVersion}</version>
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.sonatype.aether</groupId>
- <artifactId>aether-connector-file</artifactId>
- <version>1.7</version>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-junit-jupiter</artifactId>
+ <version>2.28.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <version>1.7.5</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
<version>1.7.5</version>
<scope>test</scope>
@@ -177,6 +142,11 @@ under the License.
</excludes>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>3.0.0-M5</version>
+ </plugin>
</plugins>
</build>
<profiles>
diff --git a/src/main/java/org/apache/maven/plugins/deploy/AbstractDeployMojo.java b/src/main/java/org/apache/maven/plugins/deploy/AbstractDeployMojo.java
index 5d03ecb..e708899 100644
--- a/src/main/java/org/apache/maven/plugins/deploy/AbstractDeployMojo.java
+++ b/src/main/java/org/apache/maven/plugins/deploy/AbstractDeployMojo.java
@@ -24,6 +24,7 @@ import org.apache.maven.api.Session;
import org.apache.maven.api.plugin.Mojo;
import org.apache.maven.api.plugin.MojoException;
import org.apache.maven.api.plugin.annotations.Parameter;
+import org.apache.maven.api.plugin.annotations.Component;
import org.apache.maven.api.services.RepositoryFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -51,7 +52,7 @@ public abstract class AbstractDeployMojo implements Mojo
@Parameter( property = "retryFailedDeploymentCount", defaultValue = "1" )
private int retryFailedDeploymentCount;
- @Parameter( defaultValue = "${session}", readonly = true, required = true )
+ @Component
private Session session;
/* Setters and Getters */
@@ -76,8 +77,9 @@ public abstract class AbstractDeployMojo implements Mojo
.createRemote( id, url );
}
- protected final Session getSession()
+ protected Session getSession()
{
return session;
}
+
}
diff --git a/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java b/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java
index de87828..103f550 100644
--- a/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java
+++ b/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java
@@ -42,7 +42,6 @@ import org.apache.maven.api.Artifact;
import org.apache.maven.api.Project;
import org.apache.maven.api.RemoteRepository;
import org.apache.maven.api.plugin.MojoException;
-import org.apache.maven.api.plugin.annotations.Component;
import org.apache.maven.api.plugin.annotations.Mojo;
import org.apache.maven.api.plugin.annotations.Parameter;
import org.apache.maven.api.services.ArtifactDeployer;
@@ -74,25 +73,6 @@ import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
public class DeployFileMojo
extends AbstractDeployMojo
{
- @Component
- private ArtifactDeployer artifactDeployer;
-
- @Component
- private ArtifactManager artifactManager;
-
- /**
- * Used for attaching the artifacts to deploy to the project.
- */
- @Component
- private ProjectManager projectManager;
-
- /**
- * Used for creating the project to which the artifacts to deploy will be attached.
- */
- @Component
- private ProjectBuilder projectBuilder;
-
-
/**
* GroupId of the artifact to be deployed. Retrieved from POM file if specified.
*/
@@ -335,6 +315,10 @@ public class DeployFileMojo
throw new MojoException( "No transfer protocol found." );
}
+ ArtifactManager artifactManager = getSession().getService( ArtifactManager.class );
+ ProjectManager projectManager = getSession().getService( ProjectManager.class );
+ ArtifactDeployer artifactDeployer = getSession().getService( ArtifactDeployer.class );
+
Project project = createMavenProject();
Artifact artifact = project.getArtifact();
@@ -343,7 +327,7 @@ public class DeployFileMojo
throw new MojoException( "Cannot deploy artifact from the local repository: " + file );
}
- List<Artifact> deployableArtifacts = new ArrayList<Artifact>();
+ List<Artifact> deployableArtifacts = new ArrayList<>();
if ( classifier == null )
{
@@ -352,7 +336,7 @@ public class DeployFileMojo
}
else
{
- projectManager.attachArtifact( project, packaging, classifier, file.toPath() );
+ projectManager.attachArtifact( getSession(), project, packaging, classifier, file.toPath() );
}
// Upload the POM if requested, generating one if need be
@@ -383,12 +367,12 @@ public class DeployFileMojo
if ( sources != null )
{
- projectManager.attachArtifact( project, "jar", "sources", sources.toPath() );
+ projectManager.attachArtifact( getSession(), project, "jar", "sources", sources.toPath() );
}
if ( javadoc != null )
{
- projectManager.attachArtifact( project, "jar", "javadoc", javadoc.toPath() );
+ projectManager.attachArtifact( getSession(), project, "jar", "javadoc", javadoc.toPath() );
}
if ( files != null )
@@ -444,7 +428,7 @@ public class DeployFileMojo
{
String classifier = classifiers.substring( ci, nci ).trim();
String type = types.substring( ti, nti ).trim();
- projectManager.attachArtifact( project, type, classifier, file.toPath() );
+ projectManager.attachArtifact( getSession(), project, type, classifier, file.toPath() );
}
else
{
@@ -744,4 +728,5 @@ public class DeployFileMojo
return null;
}
}
+
}
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 f4083ec..f0f7a51 100644
--- a/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java
+++ b/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java
@@ -19,30 +19,25 @@ package org.apache.maven.plugins.deploy;
* under the License.
*/
+import java.nio.file.Path;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
import org.apache.maven.api.Artifact;
import org.apache.maven.api.Project;
import org.apache.maven.api.RemoteRepository;
import org.apache.maven.api.plugin.MojoException;
-import org.apache.maven.api.plugin.annotations.Component;
import org.apache.maven.api.plugin.annotations.LifecyclePhase;
import org.apache.maven.api.plugin.annotations.Mojo;
import org.apache.maven.api.plugin.annotations.Parameter;
import org.apache.maven.api.services.ArtifactDeployer;
+import org.apache.maven.api.services.ArtifactDeployerException;
import org.apache.maven.api.services.ArtifactDeployerRequest;
import org.apache.maven.api.services.ArtifactManager;
-import org.apache.maven.api.services.ProjectDeployer;
-import org.apache.maven.api.services.ProjectDeployerException;
-import org.apache.maven.api.services.ProjectDeployerRequest;
import org.apache.maven.api.services.ProjectManager;
import org.apache.maven.api.services.RepositoryFactory;
import org.apache.maven.model.DistributionManagement;
@@ -144,21 +139,11 @@ public class DeployMojo
@Parameter( property = "maven.deploy.skip", defaultValue = "false" )
private String skip = Boolean.FALSE.toString();
- /**
- * Component used to deploy project.
- */
- @Component
- private ProjectDeployer projectDeployer;
-
- @Component
- private ArtifactManager artifactManager;
-
- @Component
- private ArtifactDeployer artifactDeployer;
-
public void execute()
throws MojoException
{
+ ArtifactManager artifactManager = getSession().getService( ArtifactManager.class );
+
boolean addedDeployRequest = false;
boolean isSnapshot = artifactManager.isSnapshot( project.getVersion() );
if ( Boolean.parseBoolean( skip )
@@ -184,13 +169,28 @@ public class DeployMojo
artifactManager.setPath( pomArtifact, project.getPomPath() );
deployables.add( pomArtifact );
}
+ else
+ {
+ artifactManager.setPath( project.getArtifact(), project.getPomPath() );
+ }
ProjectManager projectManager = getSession().getService( ProjectManager.class );
deployables.addAll( projectManager.getAttachedArtifacts( project ) );
+ for ( Artifact artifact : deployables )
+ {
+ Path path = artifactManager.getPath( artifact ).orElse( null );
+ if ( path == null )
+ {
+ throw new MojoException( "The packaging for this project did not assign "
+ + "a file to the build artifact" );
+ }
+ }
+
// CHECKSTYLE_OFF: LineLength
// @formatter:off
ArtifactDeployerRequest adr = ArtifactDeployerRequest.builder()
+ .session( getSession() )
.repository( getDeploymentRepository( isSnapshot ) )
.artifacts( deployables )
.retryFailedDeploymentCount( getRetryFailedDeploymentCount() )
@@ -232,9 +232,10 @@ public class DeployMojo
{
try
{
+ ArtifactDeployer artifactDeployer = getSession().getService( ArtifactDeployer.class );
artifactDeployer.deploy( adr );
}
- catch ( ProjectDeployerException e )
+ catch ( ArtifactDeployerException e )
{
throw new MojoException( "ProjectDeployerException", e );
}
diff --git a/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoTest.java b/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoTest.java
index 3f7eb14..5a0c89c 100644
--- a/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoTest.java
+++ b/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoTest.java
@@ -19,290 +19,218 @@ package org.apache.maven.plugins.deploy;
* under the License.
*/
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
+import static org.apache.maven.api.plugin.testing.MojoExtension.getVariableValueFromObject;
+import static org.codehaus.plexus.testing.PlexusExtension.getBasedir;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.doNothing;
import java.io.File;
+import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
-import org.apache.maven.execution.MavenSession;
+import com.google.inject.Inject;
+import com.google.inject.Provides;
+import com.google.inject.Singleton;
+import org.apache.maven.api.Artifact;
+import org.apache.maven.api.Session;
+import org.apache.maven.api.services.ArtifactDeployer;
+import org.apache.maven.api.services.ArtifactDeployerRequest;
+import org.apache.maven.api.services.ArtifactManager;
+import org.apache.maven.api.services.ProjectBuilder;
+import org.apache.maven.api.services.ProjectManager;
import org.apache.maven.model.Model;
-import org.apache.maven.plugin.testing.AbstractMojoTestCase;
-import org.apache.maven.project.ProjectBuildingRequest;
-import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
-import org.eclipse.aether.DefaultRepositorySystemSession;
-import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory;
-import org.eclipse.aether.repository.LocalRepository;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.apache.maven.api.plugin.testing.InjectMojo;
+import org.apache.maven.api.plugin.testing.MojoTest;
+import org.apache.maven.plugins.deploy.stubs.ArtifactStub;
+import org.apache.maven.plugins.deploy.stubs.SessionStub;
+import org.junit.jupiter.api.Test;
+import org.mockito.ArgumentCaptor;
/**
* @author <a href="mailto:aramirez@apache.org">Allan Ramirez</a>
*/
+@MojoTest
public class DeployFileMojoTest
- extends AbstractMojoTestCase
{
- private String LOCAL_REPO = getBasedir() + "/target/local-repo";
+ private static final String LOCAL_REPO = getBasedir() + "/target/local-repo";
- private List<String> expectedFiles;
+ @Inject @SuppressWarnings( "unused" )
+ private Session session;
- private List<String> fileList;
+ @Inject @SuppressWarnings( "unused" )
+ private ArtifactDeployer artifactDeployer;
- private File remoteRepo;
-
- @Mock
- private MavenSession session;
-
- @InjectMocks
- private DeployFileMojo mojo;
+ @Inject @SuppressWarnings( "unused" )
+ private ArtifactManager artifactManager;
- public void setUp()
- throws Exception
+ @Test
+ @InjectMojo( goal = "deploy-file", pom = "classpath:/unit/deploy-file/plugin-config-test.xml" )
+ public void testDeployTestEnvironment( DeployFileMojo mojo )
{
- super.setUp();
-
- remoteRepo = new File( getBasedir(), "target/remote-repo" );
-
- if ( !remoteRepo.exists() )
- {
- remoteRepo.mkdirs();
- }
- }
-
- public void testDeployTestEnvironment()
- throws Exception
- {
- File testPom = new File( getBasedir(), "target/test-classes/unit/deploy-file-test/plugin-config.xml" );
-
- AbstractDeployMojo mojo = (AbstractDeployMojo) lookupMojo( "deploy-file", testPom );
-
assertNotNull( mojo );
}
- public void testBasicDeployFile()
+ @Test
+ @InjectMojo( goal = "deploy-file", pom = "classpath:/unit/deploy-file/plugin-config-test.xml" )
+ public void testBasicDeployFile( DeployFileMojo mojo )
throws Exception
{
- File testPom = new File( getBasedir(), "target/test-classes/unit/deploy-file-test/plugin-config.xml" );
-
- mojo = (DeployFileMojo) lookupMojo( "deploy-file", testPom );
-
- MockitoAnnotations.initMocks( this );
-
assertNotNull( mojo );
- ProjectBuildingRequest buildingRequest = mock ( ProjectBuildingRequest.class );
- when( session.getProjectBuildingRequest() ).thenReturn( buildingRequest );
- DefaultRepositorySystemSession repositorySession = MavenRepositorySystemUtils.newSession();
- repositorySession.setLocalRepositoryManager( new SimpleLocalRepositoryManagerFactory()
- .newInstance( repositorySession, new LocalRepository( LOCAL_REPO ) ) );
- when( buildingRequest.getRepositorySession() ).thenReturn( repositorySession );
-
String groupId = (String) getVariableValueFromObject( mojo, "groupId" );
-
String artifactId = (String) getVariableValueFromObject( mojo, "artifactId" );
-
String version = (String) getVariableValueFromObject( mojo, "version" );
-
String packaging = (String) getVariableValueFromObject( mojo, "packaging" );
-
File file = (File) getVariableValueFromObject( mojo, "file" );
-
String repositoryId = (String) getVariableValueFromObject( mojo, "repositoryId" );
-
String url = (String) getVariableValueFromObject( mojo, "url" );
assertEquals( "org.apache.maven.test", groupId );
-
assertEquals( "maven-deploy-file-test", artifactId );
-
assertEquals( "1.0", version );
-
assertEquals( "jar", packaging );
-
assertTrue( file.exists() );
-
assertEquals( "deploy-test", repositoryId );
-
assertEquals( "file://" + getBasedir() + "/target/remote-repo/deploy-file-test", url );
-
- mojo.execute();
- //check the generated pom
- File pom = new File( remoteRepo, "deploy-file-test/" + groupId.replace( '.', '/' ) +
- "/" + artifactId + "/" + version + "/" + artifactId +
- "-" + version + ".pom" );
+ ArtifactDeployerRequest request = execute( mojo );
+
+ assertNotNull( request );
+ List<Artifact> artifacts = new ArrayList<>( request.getArtifacts() );
+ assertEquals( 2, artifacts.size() );
+ Artifact a1 = artifacts.get( 0 );
+ Path p1 = artifactManager.getPath( a1 ).orElse( null );
+ assertEquals( file.toPath(), p1 );
+ Artifact a2 = artifacts.get( 1 );
+ Path p2 = artifactManager.getPath( a2 ).orElse( null );
+ assertNotNull( p2 );
+ assertTrue( p2.toString().endsWith( ".pom" ) );
+
+ assertNotNull( request.getRepository() );
+ assertEquals( url, request.getRepository().getUrl() );
+ //check the generated pom
+ File pom = p2.toFile();
assertTrue( pom.exists() );
Model model = mojo.readModel( pom );
-
assertEquals( "4.0.0", model.getModelVersion() );
-
assertEquals( groupId, model.getGroupId() );
-
assertEquals( artifactId, model.getArtifactId() );
-
assertEquals( version, model.getVersion() );
-
assertEquals( packaging, model.getPackaging() );
-
assertEquals( "POM was created from deploy:deploy-file", model.getDescription() );
-
- //check the remote-repo
- expectedFiles = new ArrayList<String>();
- fileList = new ArrayList<String>();
-
- File repo = new File( remoteRepo, "deploy-file-test" );
-
- File[] files = repo.listFiles();
-
- for (File file1 : files) {
- addFileToList(file1, fileList);
- }
-
- expectedFiles.add( "org" );
- expectedFiles.add( "apache" );
- expectedFiles.add( "maven" );
- expectedFiles.add( "test" );
- expectedFiles.add( "maven-deploy-file-test" );
- expectedFiles.add( "1.0" );
- expectedFiles.add( "maven-metadata.xml" );
- expectedFiles.add( "maven-metadata.xml.md5" );
- expectedFiles.add( "maven-metadata.xml.sha1" );
- expectedFiles.add( "maven-deploy-file-test-1.0.jar" );
- expectedFiles.add( "maven-deploy-file-test-1.0.jar.md5" );
- expectedFiles.add( "maven-deploy-file-test-1.0.jar.sha1" );
- expectedFiles.add( "maven-deploy-file-test-1.0.pom" );
- expectedFiles.add( "maven-deploy-file-test-1.0.pom.md5" );
- expectedFiles.add( "maven-deploy-file-test-1.0.pom.sha1" );
-
- assertEquals( expectedFiles.size(), fileList.size() );
-
- assertEquals( 0, getSizeOfExpectedFiles( fileList, expectedFiles ) );
}
- public void testDeployIfClassifierIsSet()
+ @Test
+ @InjectMojo( goal = "deploy-file", pom = "classpath:/unit/deploy-file/plugin-config-classifier.xml" )
+ public void testDeployIfClassifierIsSet( DeployFileMojo mojo )
throws Exception
{
- File testPom = new File( getBasedir(), "target/test-classes/unit/deploy-file-classifier/plugin-config.xml" );
-
- mojo = (DeployFileMojo) lookupMojo( "deploy-file", testPom );
-
- MockitoAnnotations.initMocks( this );
-
assertNotNull( mojo );
- ProjectBuildingRequest buildingRequest = mock ( ProjectBuildingRequest.class );
- when( session.getProjectBuildingRequest() ).thenReturn( buildingRequest );
- DefaultRepositorySystemSession repositorySession = MavenRepositorySystemUtils.newSession();
- repositorySession.setLocalRepositoryManager( new SimpleLocalRepositoryManagerFactory()
- .newInstance( repositorySession, new LocalRepository( LOCAL_REPO ) ) );
- when( buildingRequest.getRepositorySession() ).thenReturn( repositorySession );
-
- String classifier = ( String ) getVariableValueFromObject( mojo, "classifier" );
-
String groupId = ( String ) getVariableValueFromObject( mojo, "groupId" );
-
String artifactId = ( String ) getVariableValueFromObject( mojo, "artifactId" );
-
- String version = ( String ) getVariableValueFromObject( mojo, "version" );
-
+ String classifier = ( String ) getVariableValueFromObject( mojo, "classifier" );
assertEquals( "bin", classifier );
+ String version = ( String ) getVariableValueFromObject( mojo, "version" );
+ String url = (String) getVariableValueFromObject( mojo, "url" );
- mojo.execute();
-
- File deployedArtifact = new File( remoteRepo, "deploy-file-classifier/" + groupId.replace( '.', '/' ) +
- "/" + artifactId + "/" + version + "/" + artifactId +
- "-" + version + "-" + classifier + ".jar");
-
- assertTrue( deployedArtifact.exists() );
-
- mojo.setClassifier( "prod" );
-
- assertEquals( "prod", mojo.getClassifier() );
-
- mojo.execute();
-
- File prodDeployedArtifact = new File( remoteRepo, "deploy-file-classifier/" + groupId.replace( '.', '/' ) +
- "/" + artifactId + "/" + version + "/" + artifactId +
- "-" + version + "-" + mojo.getClassifier() + ".jar");
-
- assertTrue( prodDeployedArtifact.exists() );
+ ArtifactDeployerRequest request = execute( mojo );
+
+ assertNotNull( request );
+ List<Artifact> artifacts = new ArrayList<>( request.getArtifacts() );
+ assertEquals( 2, artifacts.size() );
+ // first artifact
+ Artifact a1 = artifacts.get( 0 );
+ assertEquals( new ArtifactStub( groupId, artifactId, "", version, "pom" ), a1 );
+ Path p1 = artifactManager.getPath( a1 ).orElse( null );
+ assertNotNull( p1 );
+ assertTrue( p1.toString().endsWith( ".pom" ) );
+ // second artifact
+ Artifact a2 = artifacts.get( 1 );
+ assertEquals( new ArtifactStub( groupId, artifactId, "bin", version, "jar" ), a2 );
+ Path p2 = artifactManager.getPath( a2 ).orElse( null );
+ assertNotNull( p2 );
+ assertTrue( p2.toString().endsWith( "deploy-test-file-1.0-SNAPSHOT.jar" ) );
+ // remote repository
+ assertNotNull( request.getRepository() );
+ assertEquals( url, request.getRepository().getUrl() );
}
- public void testDeployIfArtifactIsNotJar()
+ @Test
+ @InjectMojo( goal = "deploy-file", pom = "classpath:/unit/deploy-file/plugin-config-artifact-not-jar.xml" )
+ public void testDeployIfArtifactIsNotJar( DeployFileMojo mojo )
throws Exception
{
- File testPom = new File( getBasedir(), "target/test-classes/unit/deploy-file-artifact-not-jar/plugin-config.xml" );
-
- mojo = (DeployFileMojo) lookupMojo( "deploy-file", testPom );
-
- MockitoAnnotations.initMocks( this );
-
assertNotNull( mojo );
-
- ProjectBuildingRequest buildingRequest = mock ( ProjectBuildingRequest.class );
- when( session.getProjectBuildingRequest() ).thenReturn( buildingRequest );
- DefaultRepositorySystemSession repositorySession = MavenRepositorySystemUtils.newSession();
- repositorySession.setLocalRepositoryManager( new SimpleLocalRepositoryManagerFactory()
- .newInstance( repositorySession, new LocalRepository( LOCAL_REPO ) ) );
- when( buildingRequest.getRepositorySession() ).thenReturn( repositorySession );
String groupId = (String) getVariableValueFromObject( mojo, "groupId" );
-
String artifactId = (String) getVariableValueFromObject( mojo, "artifactId" );
-
String version = (String) getVariableValueFromObject( mojo, "version" );
-
assertEquals( "org.apache.maven.test", groupId );
-
assertEquals( "maven-deploy-file-test", artifactId );
-
assertEquals( "1.0", version );
+ ArtifactDeployerRequest request = execute( mojo );
+
+ assertNotNull( request );
+ List<Artifact> artifacts = new ArrayList<>( request.getArtifacts() );
+ assertEquals( 2, artifacts.size() );
+ Artifact a1 = artifacts.get( 0 );
+ Artifact a2 = artifacts.get( 1 );
+ Path p1 = artifactManager.getPath( a1 ).orElse( null );
+ Path p2 = artifactManager.getPath( a2 ).orElse( null );
+ assertNotNull( p1 );
+ assertTrue( p1.toString().endsWith( "deploy-test-file.zip" ) );
+ assertNotNull( p2 );
+ assertTrue( p2.toString().endsWith( ".pom" ) );
+
+ assertNotNull( request.getRepository() );
+ assertEquals( "file://" + getBasedir() + "/target/remote-repo/deploy-file", request.getRepository().getUrl() );
+ }
+
+ private ArtifactDeployerRequest execute( DeployFileMojo mojo )
+ {
+ ArgumentCaptor<ArtifactDeployerRequest> requestCaptor = ArgumentCaptor.forClass( ArtifactDeployerRequest.class );
+ doNothing().when( artifactDeployer ).deploy( requestCaptor.capture() );
+
mojo.execute();
- File file = new File( remoteRepo, "deploy-file-artifact-not-jar/" + groupId.replace( '.', '/' ) +
- "/" + artifactId + "/" + version + "/" + artifactId +
- "-" + version + ".zip");
+ return requestCaptor.getValue();
+ }
- assertTrue( file.exists() );
+ @Provides @Singleton @SuppressWarnings( "unused" )
+ private Session getMockSession()
+ {
+ return SessionStub.getMockSession( LOCAL_REPO );
+ }
+
+ @Provides @SuppressWarnings( "unused" )
+ private ArtifactDeployer getMockArtifactDeployer( Session session )
+ {
+ return session.getService( ArtifactDeployer.class );
+ }
+
+ @Provides @SuppressWarnings( "unused" )
+ private ArtifactManager getMockArtifactManager( Session session )
+ {
+ return session.getService( ArtifactManager.class );
}
- private void addFileToList( File file, List<String> fileList )
+ @Provides @SuppressWarnings( "unused" )
+ private ProjectManager getMockProjectManager( Session session )
{
- if ( !file.isDirectory() )
- {
- fileList.add( file.getName() );
- }
- else
- {
- fileList.add( file.getName() );
-
- File[] files = file.listFiles();
-
- for (File file1 : files) {
- addFileToList(file1, fileList);
- }
- }
+ return session.getService( ProjectManager.class );
}
- private int getSizeOfExpectedFiles( List<String> fileList, List<String> expectedFiles )
+ @Provides @SuppressWarnings( "unused" )
+ private ProjectBuilder getMockProjectBuilder( Session session )
{
- for ( String fileName : fileList )
- {
- if ( expectedFiles.contains( fileName ) )
- {
- expectedFiles.remove( fileName );
- }
- else
- {
- fail( fileName + " is not included in the expected files" );
- }
- }
- return expectedFiles.size();
+ return session.getService( ProjectBuilder.class );
}
}
diff --git a/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoUnitTest.java b/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoUnitTest.java
index 0b6a0a9..ea7c1cd 100644
--- a/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoUnitTest.java
+++ b/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoUnitTest.java
@@ -19,37 +19,25 @@ package org.apache.maven.plugins.deploy;
* under the License.
*/
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
import org.apache.maven.api.plugin.MojoException;
import org.apache.maven.model.Model;
import org.apache.maven.model.Parent;
-import org.apache.maven.plugin.MojoExecutionException;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.io.File;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
/**
* @author <a href="jerome@coffeebreaks.org">Jerome Lacoste</a>
*/
public class DeployFileMojoUnitTest
- extends TestCase
{
- public static void main( String[] args )
- {
- junit.textui.TestRunner.run( suite() );
- }
-
- public static Test suite()
- {
- TestSuite suite = new TestSuite( DeployFileMojoUnitTest.class );
-
- return suite;
- }
-
MockDeployFileMojo mojo;
Parent parent;
+ @BeforeEach
public void setUp()
{
Model pomModel = new Model();
@@ -63,114 +51,55 @@ public class DeployFileMojoUnitTest
mojo = new MockDeployFileMojo( pomModel );
}
- public void tearDown()
- {
- mojo = null;
- }
-
- class MockDeployFileMojo extends DeployFileMojo {
- private Model model;
+ static class MockDeployFileMojo extends DeployFileMojo {
+ private final Model model;
public MockDeployFileMojo(Model model) {
this.model = model;
}
- public void setModel(Model model) {
- this.model = model;
- }
-
protected Model readModel(File pomFile) throws MojoException {
return model;
}
}
- public void testProcessPomFromPomFileWithParent1() throws MojoExecutionException
- {
- mojo.setPomFile( new File( "foo.bar" ) );
-
- setMojoModel( mojo.model, null, null, null, null, parent );
-
- try {
- mojo.initProperties();
- } catch (MojoException expected) {
- assertTrue( true ); // missing artifactId and packaging
- }
-
- checkMojoProperties("parentGroup", null, "parentVersion", null);
- }
-
- public void testProcessPomFromPomFileWithParent2() throws MojoExecutionException
- {
- mojo.setPomFile( new File( "foo.bar" ) );
- setMojoModel( mojo.model, null, "artifact", null, null, parent );
-
- try {
- mojo.initProperties();
- } catch (MojoException expected) {
- assertTrue( true ); // missing packaging
- }
-
- checkMojoProperties("parentGroup", "artifact", "parentVersion", null );
-
- }
-
- public void testProcessPomFromPomFileWithParent3() throws MojoExecutionException
- {
- mojo.setPomFile( new File( "foo.bar" ) );
- setMojoModel( mojo.model, null, "artifact", "version", null, parent );
-
- try {
- mojo.initProperties();
- } catch (MojoException expected) {
- assertTrue( true ); // missing version and packaging
- }
-
- checkMojoProperties( "parentGroup", "artifact", "version", null );
- }
-
- public void testProcessPomFromPomFileWithParent4() throws MojoExecutionException
+ @Test
+ public void testProcessPomFromPomFileWithParent4()
{
mojo.setPomFile( new File( "foo.bar" ) );
setMojoModel( mojo.model, null, "artifact", "version", "packaging", parent );
-
mojo.initProperties();
-
checkMojoProperties("parentGroup", "artifact", "version", "packaging");
}
- public void testProcessPomFromPomFileWithParent5() throws MojoExecutionException
+ @Test
+ public void testProcessPomFromPomFileWithParent5()
{
mojo.setPomFile( new File( "foo.bar" ) );
setMojoModel( mojo.model, "group", "artifact", "version", "packaging", parent );
-
mojo.initProperties();
-
checkMojoProperties("group", "artifact", "version", "packaging");
}
- public void testProcessPomFromPomFileWithParent6() throws MojoExecutionException
+ @Test
+ public void testProcessPomFromPomFileWithParent6()
{
mojo.setPomFile( new File( "foo.bar" ) );
setMojoModel( mojo.model, "group", "artifact", "version", "packaging", null );
-
mojo.initProperties();
-
checkMojoProperties("group", "artifact", "version", "packaging");
-
}
- public void testProcessPomFromPomFileWithOverrides() throws MojoExecutionException
+ @Test
+ public void testProcessPomFromPomFileWithOverrides()
{
mojo.setPomFile( new File( "foo.bar" ) );
setMojoModel( mojo.model, "group", "artifact", "version", "packaging", null );
-
mojo.setGroupId( "groupO" );
mojo.setArtifactId( "artifactO" );
mojo.setVersion( "versionO" );
mojo.setPackaging( "packagingO" );
-
mojo.initProperties();
-
checkMojoProperties("groupO", "artifactO", "versionO", "packagingO");
}
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 c747633..cdb4640 100644
--- a/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java
+++ b/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java
@@ -20,31 +20,45 @@ package org.apache.maven.plugins.deploy;
*/
import java.io.File;
-import java.util.ArrayList;
+import java.nio.file.Paths;
+import java.util.Arrays;
import java.util.Collections;
+import java.util.HashSet;
import java.util.List;
-import java.util.Properties;
+import java.util.Set;
+import com.google.inject.Inject;
+import com.google.inject.Provides;
+import com.google.inject.Singleton;
+import org.apache.maven.api.Artifact;
+import org.apache.maven.api.Project;
import org.apache.maven.api.RemoteRepository;
import org.apache.maven.api.Session;
import org.apache.maven.api.plugin.MojoException;
-import org.apache.maven.plugin.testing.AbstractMojoTestCase;
-import org.apache.maven.plugins.deploy.stubs.ArtifactRepositoryStub;
-import org.apache.maven.plugins.deploy.stubs.DeployArtifactStub;
-import org.apache.maven.plugins.deploy.stubs.ProjectDeployerStub;
+import org.apache.maven.api.services.ArtifactDeployer;
+import org.apache.maven.api.services.ArtifactDeployerRequest;
+import org.apache.maven.api.services.ArtifactManager;
+import org.apache.maven.api.services.ProjectBuilder;
+import org.apache.maven.api.services.ProjectManager;
+import org.apache.maven.api.plugin.testing.InjectMojo;
+import org.apache.maven.api.plugin.testing.MojoTest;
+import org.apache.maven.plugins.deploy.stubs.ArtifactStub;
import org.apache.maven.plugins.deploy.stubs.ProjectStub;
-import org.apache.maven.project.MavenProject;
-import org.apache.maven.project.ProjectBuildingRequest;
-import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
-import org.codehaus.plexus.util.FileUtils;
-import org.eclipse.aether.DefaultRepositorySystemSession;
-import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory;
-import org.eclipse.aether.repository.LocalRepository;
-import org.junit.Ignore;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-
+import org.apache.maven.plugins.deploy.stubs.SessionStub;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.ArgumentCaptor;
+import org.mockito.junit.jupiter.MockitoExtension;
+
+import static org.apache.maven.api.plugin.testing.MojoExtension.getVariableValueFromObject;
+import static org.apache.maven.api.plugin.testing.MojoExtension.setVariableValueToObject;
+import static org.codehaus.plexus.testing.PlexusExtension.getBasedir;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
@@ -52,670 +66,292 @@ import static org.mockito.Mockito.when;
/**
* @author <a href="mailto:aramirez@apache.org">Allan Ramirez</a>
*/
+@MojoTest
+@ExtendWith( MockitoExtension.class )
public class DeployMojoTest
- extends AbstractMojoTestCase
-{
- private File remoteRepo;
-
- private File localRepo;
-
- private String LOCAL_REPO = getBasedir() + "/target/local-repo";
-
- private String REMOTE_REPO = getBasedir() + "/target/remote-repo";
-
- DeployArtifactStub artifact;
+{
+
+ private final String LOCAL_REPO = getBasedir() + "/target/local-repo";
- @Mock
+ @Inject @SuppressWarnings( "unused" )
private Session session;
-
- @InjectMocks
- private DeployMojo mojo;
- public void setUp()
- throws Exception
- {
- super.setUp();
-
- remoteRepo = new File( REMOTE_REPO );
-
- remoteRepo.mkdirs();
-
- localRepo = new File( LOCAL_REPO );
+ @Inject @SuppressWarnings( "unused" )
+ private ArtifactManager artifactManager;
- if ( localRepo.exists() )
- {
- FileUtils.deleteDirectory( localRepo );
- }
+ @Inject @SuppressWarnings( "unused" )
+ private ProjectManager projectManager;
- if ( remoteRepo.exists() )
- {
- FileUtils.deleteDirectory( remoteRepo );
- }
-
-
- }
+ @Inject @SuppressWarnings( "unused" )
+ private ArtifactDeployer artifactDeployer;
- public void tearDown()
- throws Exception
- {
- super.tearDown();
-
- if( remoteRepo.exists() )
- {
- //FileUtils.deleteDirectory( remoteRepo );
- }
- }
-
- public void testDeployTestEnvironment()
- throws Exception
+ @Test
+ @InjectMojo( goal = "deploy", pom = "classpath:/unit/basic-deploy/plugin-config.xml" )
+ public void testDeployTestEnvironment( DeployMojo mojo )
{
- File testPom = new File( getBasedir(),
- "target/test-classes/unit/basic-deploy-test/plugin-config.xml" );
-
- DeployMojo mojo = ( DeployMojo ) lookupMojo( "deploy", testPom );
-
assertNotNull( mojo );
}
-
- public void testBasicDeploy()
+
+ @Test
+ @InjectMojo( goal = "deploy", pom = "classpath:/unit/basic-deploy/plugin-config.xml" )
+ public void testBasicDeploy( DeployMojo mojo )
throws Exception
{
- File testPom = new File( getBasedir(), "target/test-classes/unit/basic-deploy-test/plugin-config.xml" );
-
- mojo = ( DeployMojo ) lookupMojo( "deploy", testPom );
-
- MockitoAnnotations.initMocks( this );
-
assertNotNull( mojo );
- ProjectBuildingRequest buildingRequest = mock ( ProjectBuildingRequest.class );
- DefaultRepositorySystemSession repositorySession = MavenRepositorySystemUtils.newSession();
- repositorySession.setLocalRepositoryManager( new SimpleLocalRepositoryManagerFactory()
- .newInstance( repositorySession, new LocalRepository( LOCAL_REPO ) ) );
- when( buildingRequest.getRepositorySession() ).thenReturn( repositorySession );
-
- File file = new File( getBasedir(),
- "target/test-classes/unit/basic-deploy-test/target/" +
- "deploy-test-file-1.0-SNAPSHOT.jar" );
-
+ File file = new File( getBasedir(), "target/test-classes/unit/basic-deploy/deploy-test-file-1.0-SNAPSHOT.jar" );
assertTrue( file.exists() );
-
- MavenProject project = (MavenProject) getVariableValueFromObject( mojo, "project" );
-
+ Project project = (Project) getVariableValueFromObject( mojo, "project" );
setVariableValueToObject( mojo, "reactorProjects", Collections.singletonList( project ) );
-
- artifact = ( DeployArtifactStub ) project.getArtifact();
-
String packaging = project.getPackaging();
-
assertEquals( "jar", packaging );
-
- artifact.setFile( file );
-
- ArtifactRepositoryStub repo = getRepoStub( mojo );
+ artifactManager.setPath( project.getArtifact(), file.toPath() );
- assertNotNull( repo );
-
- repo.setAppendToUrl( "basic-deploy-test" );
-
- assertEquals( "deploy-test", repo.getId() );
- assertEquals( "deploy-test", repo.getKey() );
- assertEquals( "file", repo.getProtocol() );
- assertEquals( "file://" + getBasedir() + "/target/remote-repo/basic-deploy-test", repo.getUrl() );
-
- mojo.execute();
-
- //check the artifact in local repository
- List<String> expectedFiles = new ArrayList<String>();
- List<String> fileList = new ArrayList<String>();
-
- expectedFiles.add( "org" );
- expectedFiles.add( "apache" );
- expectedFiles.add( "maven" );
- expectedFiles.add( "test" );
- expectedFiles.add( "maven-deploy-test" );
- expectedFiles.add( "1.0-SNAPSHOT" );
- expectedFiles.add( "maven-metadata-deploy-test.xml" );
- // expectedFiles.add( "maven-deploy-test-1.0-SNAPSHOT.jar" );
- // expectedFiles.add( "maven-deploy-test-1.0-SNAPSHOT.pom" );
- // as we are in SNAPSHOT the file is here twice
- expectedFiles.add( "maven-metadata-deploy-test.xml" );
- // extra Aether files
- expectedFiles.add( "resolver-status.properties" );
- expectedFiles.add( "resolver-status.properties" );
-
- File localRepo = new File( LOCAL_REPO, "" );
-
- File[] files = localRepo.listFiles();
-
- for (File file2 : files) {
- addFileToList(file2, fileList);
- }
-
- assertEquals( expectedFiles.size(), fileList.size() );
+ ArtifactDeployerRequest request = execute( mojo );
- assertEquals( 0, getSizeOfExpectedFiles( fileList, expectedFiles ) );
-
- //check the artifact in remote repository
- expectedFiles = new ArrayList<String>();
- fileList = new ArrayList<String>();
-
- expectedFiles.add( "org" );
- expectedFiles.add( "apache" );
- expectedFiles.add( "maven" );
- expectedFiles.add( "test" );
- expectedFiles.add( "maven-deploy-test" );
- expectedFiles.add( "1.0-SNAPSHOT" );
- expectedFiles.add( "maven-metadata.xml" );
- expectedFiles.add( "maven-metadata.xml.md5" );
- expectedFiles.add( "maven-metadata.xml.sha1" );
- expectedFiles.add( "maven-deploy-test-1.0-SNAPSHOT.jar" );
- expectedFiles.add( "maven-deploy-test-1.0-SNAPSHOT.jar.md5" );
- expectedFiles.add( "maven-deploy-test-1.0-SNAPSHOT.jar.sha1" );
- expectedFiles.add( "maven-deploy-test-1.0-SNAPSHOT.pom" );
- expectedFiles.add( "maven-deploy-test-1.0-SNAPSHOT.pom.md5" );
- expectedFiles.add( "maven-deploy-test-1.0-SNAPSHOT.pom.sha1" );
- // as we are in SNAPSHOT the file is here twice
- expectedFiles.add( "maven-metadata.xml" );
- expectedFiles.add( "maven-metadata.xml.md5" );
- expectedFiles.add( "maven-metadata.xml.sha1" );
-
- remoteRepo = new File( remoteRepo, "basic-deploy-test" );
-
- files = remoteRepo.listFiles();
-
- for (File file1 : files) {
- addFileToList(file1, fileList);
- }
-
- assertEquals( expectedFiles.size(), fileList.size() );
-
- assertEquals( 0, getSizeOfExpectedFiles( fileList, expectedFiles ) );
+ assertNotNull( request );
+ Set<Artifact> artifacts = new HashSet<>( request.getArtifacts() );
+ assertEquals( new HashSet<>( Arrays.asList(
+ new ArtifactStub( "org.apache.maven.test", "maven-deploy-test", "", "1.0-SNAPSHOT", "jar"),
+ new ArtifactStub( "org.apache.maven.test", "maven-deploy-test", "", "1.0-SNAPSHOT", "pom")
+ ) ), artifacts );
+ assertEquals( getBasedir(), request.getRepository().getUrl() );
}
- public void testSkippingDeploy()
+ @Test
+ @InjectMojo( goal = "deploy", pom = "classpath:/unit/basic-deploy/plugin-config.xml" )
+ public void testSkippingDeploy( DeployMojo mojo )
throws Exception
{
- File testPom = new File( getBasedir(), "target/test-classes/unit/basic-deploy-test/plugin-config.xml" );
-
- DeployMojo mojo = (DeployMojo) lookupMojo( "deploy", testPom );
-
assertNotNull( mojo );
- File file = new File( getBasedir(), "target/test-classes/unit/basic-deploy-test/target/"
- + "deploy-test-file-1.0-SNAPSHOT.jar" );
-
+ File file = new File( getBasedir(), "target/test-classes/unit/basic-deploy/deploy-test-file-1.0-SNAPSHOT.jar" );
assertTrue( file.exists() );
-
- MavenProject project = (MavenProject) getVariableValueFromObject( mojo, "project" );
-
+ Project project = (Project) getVariableValueFromObject( mojo, "project" );
setVariableValueToObject( mojo, "reactorProjects", Collections.singletonList( project ) );
-
- artifact = (DeployArtifactStub) project.getArtifact();
-
String packaging = project.getPackaging();
-
assertEquals( "jar", packaging );
-
- artifact.setFile( file );
-
- ArtifactRepositoryStub repo = getRepoStub( mojo );
-
- assertNotNull( repo );
-
- repo.setAppendToUrl( "basic-deploy-test" );
-
- assertEquals( "deploy-test", repo.getId() );
- assertEquals( "deploy-test", repo.getKey() );
- assertEquals( "file", repo.getProtocol() );
- assertEquals( "file://" + getBasedir() + "/target/remote-repo/basic-deploy-test", repo.getUrl() );
+ artifactManager.setPath( project.getArtifact(), file.toPath() );
setVariableValueToObject( mojo, "skip", Boolean.TRUE.toString() );
-
- mojo.execute();
-
- File localRepo = new File( LOCAL_REPO, "" );
-
- File[] files = localRepo.listFiles();
- assertNull( files );
-
- remoteRepo = new File( remoteRepo, "basic-deploy-test" );
-
- files = remoteRepo.listFiles();
+ ArtifactDeployerRequest request = execute( mojo );
+ assertNull( request );
+ }
- assertNull( files );
- }
-
- public void testBasicDeployWithPackagingAsPom()
+ @Test
+ @InjectMojo( goal = "deploy", pom = "classpath:/unit/basic-deploy/plugin-config.xml" )
+ public void testBasicDeployWithPackagingAsPom( DeployMojo mojo )
throws Exception
{
- File testPom = new File( getBasedir(),
- "target/test-classes/unit/basic-deploy-pom/plugin-config.xml" );
-
- mojo = ( DeployMojo ) lookupMojo( "deploy", testPom );
-
- MockitoAnnotations.initMocks( this );
-
assertNotNull( mojo );
- ProjectBuildingRequest buildingRequest = mock ( ProjectBuildingRequest.class );
- DefaultRepositorySystemSession repositorySession = MavenRepositorySystemUtils.newSession();
- repositorySession.setLocalRepositoryManager( new SimpleLocalRepositoryManagerFactory()
- .newInstance( repositorySession, new LocalRepository( LOCAL_REPO ) ) );
- when( buildingRequest.getRepositorySession() ).thenReturn( repositorySession );
-
- File pomFile = new File( getBasedir(),
- "target/test-classes/unit/basic-deploy-pom/target/" +
- "deploy-test-file-1.0-SNAPSHOT.pom" );
-
+ File pomFile = new File( getBasedir(), "target/test-classes/unit/basic-deploy/deploy-test-file-1.0-SNAPSHOT.pom" );
assertTrue( pomFile.exists() );
-
- MavenProject project = (MavenProject) getVariableValueFromObject( mojo, "project" );
-
+ ProjectStub project = (ProjectStub) getVariableValueFromObject( mojo, "project" );
+ project.setPackaging( "pom" );
+ ((ArtifactStub) project.getArtifact()).setExtension( "pom" );
setVariableValueToObject( mojo, "reactorProjects", Collections.singletonList( project ) );
+ artifactManager.setPath( project.getArtifact(), pomFile.toPath() );
- artifact = (DeployArtifactStub) project.getArtifact();
-
- artifact.setArtifactHandlerExtension( project.getPackaging() );
-
- artifact.setFile( pomFile );
-
- ArtifactRepositoryStub repo = getRepoStub( mojo );
-
- repo.setAppendToUrl( "basic-deploy-pom" );
-
- mojo.execute();
-
- List<String> expectedFiles = new ArrayList<String>();
- List<String> fileList = new ArrayList<String>();
-
- expectedFiles.add( "org" );
- expectedFiles.add( "apache" );
- expectedFiles.add( "maven" );
- expectedFiles.add( "test" );
- expectedFiles.add( "maven-deploy-test" );
- expectedFiles.add( "1.0-SNAPSHOT" );
- expectedFiles.add( "maven-metadata.xml" );
- expectedFiles.add( "maven-metadata.xml.md5" );
- expectedFiles.add( "maven-metadata.xml.sha1" );
- expectedFiles.add( "maven-deploy-test-1.0-SNAPSHOT.pom" );
- expectedFiles.add( "maven-deploy-test-1.0-SNAPSHOT.pom.md5" );
- expectedFiles.add( "maven-deploy-test-1.0-SNAPSHOT.pom.sha1" );
- // as we are in SNAPSHOT the file is here twice
- expectedFiles.add( "maven-metadata.xml" );
- expectedFiles.add( "maven-metadata.xml.md5" );
- expectedFiles.add( "maven-metadata.xml.sha1" );
- remoteRepo = new File( remoteRepo, "basic-deploy-pom" );
-
- File[] files = remoteRepo.listFiles();
-
- for (File file : files) {
- addFileToList(file, fileList);
- }
-
- assertEquals( expectedFiles.size(), fileList.size() );
+ ArtifactDeployerRequest request = execute( mojo );
- assertEquals( 0, getSizeOfExpectedFiles( fileList, expectedFiles ) );
+ assertNotNull( request );
+ Set<Artifact> artifacts = new HashSet<>( request.getArtifacts() );
+ assertEquals( new HashSet<>( Collections.singletonList(
+ new ArtifactStub( "org.apache.maven.test", "maven-deploy-test", "", "1.0-SNAPSHOT", "pom" )
+ ) ), artifacts );
+ assertEquals( getBasedir(), request.getRepository().getUrl() );
}
- public void testDeployIfArtifactFileIsNull()
+ @Test
+ @InjectMojo( goal = "deploy", pom = "classpath:/unit/basic-deploy/plugin-config.xml" )
+ public void testDeployIfArtifactFileIsNull( DeployMojo mojo )
throws Exception
{
- File testPom = new File( getBasedir(),
- "target/test-classes/unit/basic-deploy-test/plugin-config.xml" );
-
- DeployMojo mojo = ( DeployMojo ) lookupMojo( "deploy", testPom );
-
- MockitoAnnotations.initMocks( this );
-
- ProjectBuildingRequest buildingRequest = mock ( ProjectBuildingRequest.class );
-
- setVariableValueToObject( mojo, "session", session );
-
assertNotNull( mojo );
- MavenProject project = (MavenProject) getVariableValueFromObject( mojo, "project" );
-
+ Project project = (Project) getVariableValueFromObject( mojo, "project" );
setVariableValueToObject( mojo, "reactorProjects", Collections.singletonList( project ) );
+ artifactManager.setPath( project.getArtifact(), null );
- artifact = (DeployArtifactStub) project.getArtifact();
-
- artifact.setFile( null );
-
- assertNull( artifact.getFile() );
-
- try
- {
- mojo.execute();
-
- fail( "Did not throw mojo execution exception" );
- }
- catch( MojoException e )
- {
- //expected
- }
+ assertThrows( MojoException.class, mojo::execute, "Did not throw mojo execution exception" );
}
-
- public void testDeployWithAttachedArtifacts()
- throws Exception
- {
- File testPom = new File( getBasedir(),
- "target/test-classes/unit/basic-deploy-with-attached-artifacts/" +
- "plugin-config.xml" );
-
- mojo = ( DeployMojo ) lookupMojo( "deploy", testPom );
-
- MockitoAnnotations.initMocks( this );
-
- assertNotNull( mojo );
-
- ProjectBuildingRequest buildingRequest = mock ( ProjectBuildingRequest.class );
- DefaultRepositorySystemSession repositorySession = MavenRepositorySystemUtils.newSession();
- repositorySession.setLocalRepositoryManager( new SimpleLocalRepositoryManagerFactory()
- .newInstance( repositorySession, new LocalRepository( LOCAL_REPO ) ) );
- when( buildingRequest.getRepositorySession() ).thenReturn( repositorySession );
-
- MavenProject project = (MavenProject) getVariableValueFromObject( mojo, "project" );
-
- setVariableValueToObject( mojo, "reactorProjects", Collections.singletonList( project ) );
-
- artifact = (DeployArtifactStub) project.getArtifact();
-
- File file = new File( getBasedir(),
- "target/test-classes/unit/basic-deploy-with-attached-artifacts/target/" +
- "deploy-test-file-1.0-SNAPSHOT.jar" );
-
- artifact.setFile( file );
-
- ArtifactRepositoryStub repo = getRepoStub( mojo );
-
- repo.setAppendToUrl( "basic-deploy-with-attached-artifacts" );
-
- mojo.execute();
-
- //check the artifacts in remote repository
- List<String> expectedFiles = new ArrayList<String>();
- List<String> fileList = new ArrayList<String>();
-
- expectedFiles.add( "org" );
- expectedFiles.add( "apache" );
- expectedFiles.add( "maven" );
- expectedFiles.add( "test" );
- expectedFiles.add( "maven-deploy-test" );
- expectedFiles.add( "1.0-SNAPSHOT" );
- expectedFiles.add( "maven-metadata.xml" );
- expectedFiles.add( "maven-metadata.xml.md5" );
- expectedFiles.add( "maven-metadata.xml.sha1" );
- expectedFiles.add( "maven-deploy-test-1.0-SNAPSHOT.jar" );
- expectedFiles.add( "maven-deploy-test-1.0-SNAPSHOT.jar.md5" );
- expectedFiles.add( "maven-deploy-test-1.0-SNAPSHOT.jar.sha1" );
- expectedFiles.add( "maven-deploy-test-1.0-SNAPSHOT.pom" );
- expectedFiles.add( "maven-deploy-test-1.0-SNAPSHOT.pom.md5" );
- expectedFiles.add( "maven-deploy-test-1.0-SNAPSHOT.pom.sha1" );
- // as we are in SNAPSHOT the file is here twice
- expectedFiles.add( "maven-metadata.xml" );
- expectedFiles.add( "maven-metadata.xml.md5" );
- expectedFiles.add( "maven-metadata.xml.sha1" );
- expectedFiles.add( "attached-artifact-test-0" );
- expectedFiles.add( "1.0-SNAPSHOT" );
- expectedFiles.add( "maven-metadata.xml" );
- expectedFiles.add( "maven-metadata.xml.md5" );
- expectedFiles.add( "maven-metadata.xml.sha1" );
- expectedFiles.add( "attached-artifact-test-0-1.0-SNAPSHOT.jar" );
- expectedFiles.add( "attached-artifact-test-0-1.0-SNAPSHOT.jar.md5" );
- expectedFiles.add( "attached-artifact-test-0-1.0-SNAPSHOT.jar.sha1" );
- // as we are in SNAPSHOT the file is here twice
- expectedFiles.add( "maven-metadata.xml" );
- expectedFiles.add( "maven-metadata.xml.md5" );
- expectedFiles.add( "maven-metadata.xml.sha1" );
-
- remoteRepo = new File( remoteRepo, "basic-deploy-with-attached-artifacts" );
-
- File[] files = remoteRepo.listFiles();
- for (File file1 : files) {
- addFileToList(file1, fileList);
- }
-
- assertEquals( expectedFiles.size(), fileList.size() );
-
- assertEquals( 0, getSizeOfExpectedFiles( fileList, expectedFiles ) );
- }
-
- @Ignore( "SCP is not part of Maven3 distribution. Aether handles transport extensions." )
- public void _testBasicDeployWithScpAsProtocol()
+ @Test
+ @InjectMojo( goal = "deploy", pom = "classpath:/unit/basic-deploy/plugin-config.xml" )
+ public void testDeployWithAttachedArtifacts( DeployMojo mojo )
throws Exception
{
- String originalUserHome = System.getProperty( "user.home" );
-
- // FIX THE DAMN user.home BEFORE YOU DELETE IT!!!
- File altHome = new File( getBasedir(), "target/ssh-user-home" );
- altHome.mkdirs();
-
- System.out.println( "Testing user.home value for .ssh dir: " + altHome.getCanonicalPath() );
-
- Properties props = System.getProperties();
- props.setProperty( "user.home", altHome.getCanonicalPath() );
-
- System.setProperties( props );
-
- File testPom = new File( getBasedir(),
- "target/test-classes/unit/basic-deploy-scp/plugin-config.xml" );
-
- mojo = ( DeployMojo ) lookupMojo( "deploy", testPom );
-
assertNotNull( mojo );
-
- ProjectDeployerStub deployer = new ProjectDeployerStub();
-
- setVariableValueToObject( mojo, "projectDeployer", deployer );
-
- File file = new File( getBasedir(),
- "target/test-classes/unit/basic-deploy-scp/target/" +
- "deploy-test-file-1.0-SNAPSHOT.jar" );
-
- assertTrue( file.exists() );
-
- MavenProject project = (MavenProject) getVariableValueFromObject( mojo, "project" );
-
+ Project project = (Project) getVariableValueFromObject( mojo, "project" );
setVariableValueToObject( mojo, "reactorProjects", Collections.singletonList( project ) );
-
- artifact = (DeployArtifactStub) project.getArtifact();
-
- artifact.setFile( file );
-
- String altUserHome = System.getProperty( "user.home" );
-
- if ( altUserHome.equals( originalUserHome ) )
- {
- // this is *very* bad!
- throw new IllegalStateException( "Setting 'user.home' system property to alternate value did NOT work. Aborting test." );
- }
-
- File sshFile = new File( altUserHome, ".ssh" );
-
- System.out.println( "Testing .ssh dir: " + sshFile.getCanonicalPath() );
-
- //delete first the .ssh folder if existing before executing the mojo
- if( sshFile.exists() )
- {
- FileUtils.deleteDirectory( sshFile );
- }
-
- mojo.execute();
-
- assertTrue( sshFile.exists() );
-
- FileUtils.deleteDirectory( sshFile );
+ File file = new File( getBasedir(), "target/test-classes/unit/basic-deploy/deploy-test-file-1.0-SNAPSHOT.jar" );
+ artifactManager.setPath( project.getArtifact(), file.toPath() );
+ projectManager.attachArtifact( project,
+ new ArtifactStub( "org.apache.maven.test", "attached-artifact-test", "", "1.0-SNAPSHOT", "jar" ),
+ Paths.get( getBasedir(), "target/test-classes/unit/basic-deploy/attached-artifacts-test-1.0-SNAPSHOT.jar" ) );
+
+ ArtifactDeployerRequest request = execute( mojo );
+
+ assertNotNull( request );
+ Set<Artifact> artifacts = new HashSet<>( request.getArtifacts() );
+ assertEquals( new HashSet<>( Arrays.asList(
+ new ArtifactStub( "org.apache.maven.test", "maven-deploy-test", "", "1.0-SNAPSHOT", "jar"),
+ new ArtifactStub( "org.apache.maven.test", "maven-deploy-test", "", "1.0-SNAPSHOT", "pom"),
+ new ArtifactStub( "org.apache.maven.test", "attached-artifact-test", "", "1.0-SNAPSHOT", "jar")
+ ) ), artifacts );
+ assertEquals( getBasedir(), request.getRepository().getUrl() );
}
+ @Test
public void testLegacyAltDeploymentRepositoryWithDefaultLayout()
- throws Exception
{
- DeployMojo mojo = spy( new DeployMojo() );
-
+ DeployMojo mojo = spy( new TestDeployMojo() );
RemoteRepository repository = mock( RemoteRepository.class );
- when( mojo.createDeploymentArtifactRepository( "altDeploymentRepository", "http://localhost"
- ) ).thenReturn( repository );
-
+ when( mojo.createDeploymentArtifactRepository( "altDeploymentRepository", "http://localhost" ) )
+ .thenReturn( repository );
mojo.altDeploymentRepository = "altDeploymentRepository::default::http://localhost";
- assertEquals( repository,
- mojo.getDeploymentRepository( true ) );
+ assertEquals( repository, mojo.getDeploymentRepository( true ) );
}
+ @Test
public void testLegacyAltDeploymentRepositoryWithLegacyLayout()
- throws Exception
{
- DeployMojo mojo = spy( new DeployMojo() );
-
+ DeployMojo mojo = spy( new TestDeployMojo() );
RemoteRepository repository = mock( RemoteRepository.class );
- when( mojo.createDeploymentArtifactRepository( "altDeploymentRepository", "http://localhost"
- ) ).thenReturn( repository );
-
+ when( mojo.createDeploymentArtifactRepository( "altDeploymentRepository", "http://localhost" ) )
+ .thenReturn( repository );
mojo.altDeploymentRepository = "altDeploymentRepository::legacy::http://localhost";
- try
- {
- mojo.getDeploymentRepository( true );
- fail( "Should throw: Invalid legacy syntax and layout for repository." );
- }
- catch( MojoException e )
- {
- assertEquals( e.getMessage(), "Invalid legacy syntax and layout for repository.");
- assertEquals( e.getLongMessage(), "Invalid legacy syntax and layout for alternative repository. Use \"altDeploymentRepository::http://localhost\" instead, and only default layout is supported.");
- }
+ MojoException e = assertThrows( MojoException.class, () -> mojo.getDeploymentRepository( true ), "Should throw: Invalid legacy syntax and layout for repository." );
+ assertEquals( e.getMessage(), "Invalid legacy syntax and layout for repository.");
+ assertEquals( e.getLongMessage(), "Invalid legacy syntax and layout for alternative repository. Use \"altDeploymentRepository::http://localhost\" instead, and only default layout is supported.");
}
+ @Test
public void testInsaneAltDeploymentRepository()
- throws Exception
{
- DeployMojo mojo = spy( new DeployMojo() );
-
+ DeployMojo mojo = spy( new TestDeployMojo() );
RemoteRepository repository = mock( RemoteRepository.class );
- when( mojo.createDeploymentArtifactRepository( "altDeploymentRepository", "http://localhost"
- ) ).thenReturn( repository );
-
+ when( mojo.createDeploymentArtifactRepository( "altDeploymentRepository", "http://localhost" ) )
+ .thenReturn( repository );
mojo.altDeploymentRepository = "altDeploymentRepository::hey::wow::foo::http://localhost";
- try
- {
- mojo.getDeploymentRepository( true );
- fail( "Should throw: Invalid legacy syntax and layout for repository." );
- }
- catch( MojoException e )
- {
- assertEquals( e.getMessage(), "Invalid legacy syntax and layout for repository.");
- assertEquals( e.getLongMessage(), "Invalid legacy syntax and layout for alternative repository. Use \"altDeploymentRepository::wow::foo::http://localhost\" instead, and only default layout is supported.");
- }
+ MojoException e = assertThrows( MojoException.class, () -> mojo.getDeploymentRepository( true ), "Should throw: Invalid legacy syntax and layout for repository." );
+ assertEquals( e.getMessage(), "Invalid legacy syntax and layout for repository.");
+ assertEquals( e.getLongMessage(), "Invalid legacy syntax and layout for alternative repository. Use \"altDeploymentRepository::wow::foo::http://localhost\" instead, and only default layout is supported.");
}
+ @Test
public void testDefaultScmSvnAltDeploymentRepository()
- throws Exception
{
- DeployMojo mojo = spy( new DeployMojo() );
-
+ DeployMojo mojo = spy( new TestDeployMojo() );
RemoteRepository repository = mock( RemoteRepository.class );
- when( mojo.createDeploymentArtifactRepository( "altDeploymentRepository", "scm:svn:http://localhost"
- ) ).thenReturn( repository );
-
+ when( mojo.createDeploymentArtifactRepository( "altDeploymentRepository", "scm:svn:http://localhost" ) )
+ .thenReturn( repository );
mojo.altDeploymentRepository = "altDeploymentRepository::default::scm:svn:http://localhost";
- assertEquals( repository,
- mojo.getDeploymentRepository( true ) );
+ assertEquals( repository, mojo.getDeploymentRepository( true ) );
}
+
+ @Test
public void testLegacyScmSvnAltDeploymentRepository()
- throws Exception
{
- DeployMojo mojo = spy( new DeployMojo() );
-
+ DeployMojo mojo = spy( new TestDeployMojo() );
RemoteRepository repository = mock( RemoteRepository.class );
- when( mojo.createDeploymentArtifactRepository( "altDeploymentRepository", "http://localhost"
- ) ).thenReturn( repository );
-
+ when( mojo.createDeploymentArtifactRepository( "altDeploymentRepository", "http://localhost" ) )
+ .thenReturn( repository );
mojo.altDeploymentRepository = "altDeploymentRepository::legacy::scm:svn:http://localhost";
- try
- {
- mojo.getDeploymentRepository( true );
- fail( "Should throw: Invalid legacy syntax and layout for repository." );
- }
- catch( MojoException e )
- {
- assertEquals( e.getMessage(), "Invalid legacy syntax and layout for repository.");
- assertEquals( e.getLongMessage(), "Invalid legacy syntax and layout for alternative repository. Use \"altDeploymentRepository::scm:svn:http://localhost\" instead, and only default layout is supported.");
- }
+ MojoException e = assertThrows( MojoException.class, () -> mojo.getDeploymentRepository( true ), "Should throw: Invalid legacy syntax and layout for repository." );
+ assertEquals( e.getMessage(), "Invalid legacy syntax and layout for repository.");
+ assertEquals( e.getLongMessage(), "Invalid legacy syntax and layout for alternative repository. Use \"altDeploymentRepository::scm:svn:http://localhost\" instead, and only default layout is supported.");
}
+ @Test
public void testAltSnapshotDeploymentRepository()
- throws Exception
{
- DeployMojo mojo = spy( new DeployMojo() );
-
+ DeployMojo mojo = spy( new TestDeployMojo() );
RemoteRepository repository = mock( RemoteRepository.class );
- when( mojo.createDeploymentArtifactRepository( "altSnapshotDeploymentRepository", "http://localhost"
- ) ).thenReturn( repository );
+ when( mojo.createDeploymentArtifactRepository( "altSnapshotDeploymentRepository", "http://localhost" ) )
+ .thenReturn( repository );
mojo.altDeploymentRepository = "altSnapshotDeploymentRepository::http://localhost";
- assertEquals( repository,
- mojo.getDeploymentRepository( true ));
+ assertEquals( repository, mojo.getDeploymentRepository( true ));
}
+ @Test
public void testAltReleaseDeploymentRepository()
- throws Exception
{
- DeployMojo mojo = spy( new DeployMojo() );
-
+ DeployMojo mojo = spy( new TestDeployMojo() );
RemoteRepository repository = mock( RemoteRepository.class );
when( mojo.createDeploymentArtifactRepository( "altReleaseDeploymentRepository", "http://localhost" ) ).thenReturn( repository );
-
mojo.altDeploymentRepository = "altReleaseDeploymentRepository::http://localhost";
- assertEquals( repository,
- mojo.getDeploymentRepository( false ));
+ assertEquals( repository, mojo.getDeploymentRepository( false ));
}
- private void addFileToList( File file, List<String> fileList )
+
+ private ArtifactDeployerRequest execute( DeployMojo mojo )
{
- if( !file.isDirectory() )
- {
- fileList.add( file.getName() );
- }
- else
- {
- fileList.add( file.getName() );
+ ArgumentCaptor<ArtifactDeployerRequest> requestCaptor = ArgumentCaptor.forClass( ArtifactDeployerRequest.class );
+ doNothing().when( artifactDeployer ).deploy( requestCaptor.capture() );
+
+ mojo.execute();
- File[] files = file.listFiles();
+ List<ArtifactDeployerRequest> requests = requestCaptor.getAllValues();
+ assertNotNull( requests );
+ return requests.isEmpty() ? null : requests.get( requests.size() - 1 );
+ }
- for (File file1 : files) {
- addFileToList(file1, fileList);
- }
- }
- }
-
- private int getSizeOfExpectedFiles( List<String> fileList, List<String> expectedFiles )
+ class TestDeployMojo extends DeployMojo
{
- for( String fileName : fileList )
+ TestDeployMojo( )
{
- // translate uniqueVersion to -SNAPSHOT
- fileName = fileName.replaceFirst( "-\\d{8}\\.\\d{6}-\\d+", "-SNAPSHOT" );
-
- if( !expectedFiles.remove( fileName ) )
+ super();
+ try
+ {
+ setVariableValueToObject( this, "session", session );
+ }
+ catch ( IllegalAccessException e )
{
- fail( fileName + " is not included in the expected files" );
+ throw new IllegalStateException( "Unable to inject session", e );
}
}
- return expectedFiles.size();
- }
+ }
- private ArtifactRepositoryStub getRepoStub( Object mojo )
- throws Exception
+ @Provides @Singleton @SuppressWarnings( "unused" )
+ private Session getMockSession()
+ {
+ return SessionStub.getMockSession( LOCAL_REPO );
+ }
+
+ @Provides @SuppressWarnings( "unused" )
+ private ArtifactDeployer getMockArtifactDeployer( Session session )
+ {
+ return session.getService( ArtifactDeployer.class );
+ }
+
+ @Provides @SuppressWarnings( "unused" )
+ private ArtifactManager getMockArtifactManager( Session session )
+ {
+ return session.getService( ArtifactManager.class );
+ }
+
+ @Provides @SuppressWarnings( "unused" )
+ private ProjectManager getMockProjectManager( Session session )
+ {
+ return session.getService( ProjectManager.class );
+ }
+
+ @Provides @SuppressWarnings( "unused" )
+ private ProjectBuilder getMockProjectBuilder( Session session )
{
- MavenProject project = (MavenProject) getVariableValueFromObject( mojo, "project" );
- return (ArtifactRepositoryStub) project.getDistributionManagementArtifactRepository();
+ return session.getService( ProjectBuilder.class );
}
}
diff --git a/src/test/java/org/apache/maven/plugins/deploy/Utils.java b/src/test/java/org/apache/maven/plugins/deploy/Utils.java
index 4df7442..f4acbc9 100644
--- a/src/test/java/org/apache/maven/plugins/deploy/Utils.java
+++ b/src/test/java/org/apache/maven/plugins/deploy/Utils.java
@@ -26,7 +26,7 @@ import java.util.List;
import java.util.Map;
import org.apache.maven.plugin.MojoExecutionException;
-import org.sonatype.aether.util.ChecksumUtils;
+import org.eclipse.aether.util.ChecksumUtils;
/**
* A utility class to assist testing.
diff --git a/src/test/java/org/apache/maven/plugins/deploy/stubs/ArtifactRepositoryStub.java b/src/test/java/org/apache/maven/plugins/deploy/stubs/ArtifactRepositoryStub.java
deleted file mode 100644
index 0b94ebe..0000000
--- a/src/test/java/org/apache/maven/plugins/deploy/stubs/ArtifactRepositoryStub.java
+++ /dev/null
@@ -1,134 +0,0 @@
-package org.apache.maven.plugins.deploy.stubs;
-
-/*
- * 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.artifact.Artifact;
-import org.apache.maven.artifact.metadata.ArtifactMetadata;
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
-import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
-import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
-import org.apache.maven.plugin.testing.stubs.StubArtifactRepository;
-
-public class ArtifactRepositoryStub
- extends StubArtifactRepository
-{
- private boolean blacklisted;
-
- private ArtifactRepositoryLayout layout;
-
- private String url;
-
- private String basedir = System.getProperty( "basedir" );
-
- public ArtifactRepositoryStub()
- {
- super( null );
- }
-
- public ArtifactRepositoryStub( String dir )
- {
- super( dir );
- }
-
- public String pathOf( Artifact artifact )
- {
- return getLayout().pathOf( artifact );
- }
-
- public String pathOfRemoteRepositoryMetadata( ArtifactMetadata artifactMetadata )
- {
- return getLayout().pathOfRemoteRepositoryMetadata( artifactMetadata );
- }
-
- public String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata, ArtifactRepository repository )
- {
- return getLayout().pathOfLocalRepositoryMetadata( metadata, repository );
- }
-
- public String getUrl()
- {
- return url;
- }
-
- public void setAppendToUrl( String dir )
- {
- this.url = "file://" + basedir + "/target/remote-repo/" + dir;
- }
-
- public String getBasedir()
- {
- return basedir;
- }
-
- public String getProtocol()
- {
- return "file";
- }
-
- public String getId()
- {
- return "deploy-test";
- }
-
- public ArtifactRepositoryPolicy getSnapshots()
- {
- return new ArtifactRepositoryPolicy( true, ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS,
- ArtifactRepositoryPolicy.CHECKSUM_POLICY_IGNORE );
- }
-
- public ArtifactRepositoryPolicy getReleases()
- {
- return new ArtifactRepositoryPolicy( true, ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS,
- ArtifactRepositoryPolicy.CHECKSUM_POLICY_IGNORE );
- }
-
- public ArtifactRepositoryLayout getLayout()
- {
- if( layout != null )
- {
- return layout;
- }
- else
- {
- return new DefaultRepositoryLayout();
- }
- }
-
- public String getKey()
- {
- return getId();
- }
-
- public boolean isUniqueVersion()
- {
- return false;
- }
-
- public void setBlacklisted( boolean blackListed )
- {
- this.blacklisted = blackListed;
- }
-
- public boolean isBlacklisted()
- {
- return blacklisted;
- }
-}
diff --git a/src/test/java/org/apache/maven/plugins/deploy/stubs/ArtifactRepositoryStub2.java b/src/test/java/org/apache/maven/plugins/deploy/stubs/ArtifactRepositoryStub2.java
deleted file mode 100644
index 0e3338f..0000000
--- a/src/test/java/org/apache/maven/plugins/deploy/stubs/ArtifactRepositoryStub2.java
+++ /dev/null
@@ -1,60 +0,0 @@
-package org.apache.maven.plugins.deploy.stubs;
-
-/*
- * 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.
- */
-
-public class ArtifactRepositoryStub2
- extends ArtifactRepositoryStub
-{
- private String protocol;
-
- public ArtifactRepositoryStub2()
- {
- super();
- }
-
- public ArtifactRepositoryStub2( String dir )
- {
- super( dir );
- }
-
- public String getUrl()
- {
- return "file://" + System.getProperty( "basedir" ) + "/target/remote-repo/basic-deploy-scp";
- }
-
- public String getBasedir()
- {
- return System.getProperty( "basedir" );
- }
-
- public String getProtocol()
- {
- if( this.protocol == null || this.protocol.equals("") )
- {
- this.protocol = "scp";
- }
- return this.protocol;
- }
-
- public void setProtocol( String protocol )
- {
- this.protocol = protocol;
- }
-}
diff --git a/src/test/java/org/apache/maven/plugins/deploy/stubs/ArtifactStub.java b/src/test/java/org/apache/maven/plugins/deploy/stubs/ArtifactStub.java
new file mode 100644
index 0000000..f17dcd2
--- /dev/null
+++ b/src/test/java/org/apache/maven/plugins/deploy/stubs/ArtifactStub.java
@@ -0,0 +1,189 @@
+package org.apache.maven.plugins.deploy.stubs;
+
+/*
+ * 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 javax.annotation.Nonnull;
+
+import java.nio.file.Path;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.regex.Pattern;
+
+import org.apache.maven.api.Artifact;
+
+public class ArtifactStub implements Artifact
+{
+ private static final String SNAPSHOT = "SNAPSHOT";
+
+ private static final Pattern SNAPSHOT_TIMESTAMP = Pattern.compile( "^(.*-)?([0-9]{8}\\.[0-9]{6}-[0-9]+)$" );
+
+ private String groupId;
+ private String artifactId;
+ private String classifier = "";
+ private String version;
+ private String extension;
+ private String baseVersion;
+ private Path path;
+
+ public ArtifactStub()
+ {
+ }
+
+ public ArtifactStub( String groupId, String artifactId, String classifier, String version, String extension )
+ {
+ this.groupId = groupId;
+ this.artifactId = artifactId;
+ this.classifier = classifier;
+ this.version = version;
+ this.extension = extension;
+ }
+
+ @Nonnull
+ @Override
+ public String getGroupId()
+ {
+ return groupId;
+ }
+
+ public void setGroupId( String groupId )
+ {
+ this.groupId = groupId;
+ }
+
+ @Nonnull
+ @Override
+ public String getArtifactId()
+ {
+ return artifactId;
+ }
+
+ public void setArtifactId( String artifactId )
+ {
+ this.artifactId = artifactId;
+ }
+
+ @Nonnull
+ @Override
+ public String getClassifier()
+ {
+ return classifier;
+ }
+
+ public void setClassifier( String classifier )
+ {
+ this.classifier = classifier;
+ }
+
+ @Nonnull
+ @Override
+ public String getVersion()
+ {
+ return version;
+ }
+
+ public void setVersion( String version )
+ {
+ this.version = version;
+ }
+
+ @Nonnull
+ @Override
+ public String getExtension()
+ {
+ return extension;
+ }
+
+ public void setExtension( String extension )
+ {
+ this.extension = extension;
+ }
+
+ @Nonnull
+ @Override
+ public String getBaseVersion()
+ {
+ if ( baseVersion == null && version != null )
+ {
+ baseVersion = version;
+ }
+ return baseVersion;
+ }
+
+ public void setBaseVersion( String baseVersion )
+ {
+ this.baseVersion = baseVersion;
+ }
+
+ @Nonnull
+ @Override
+ public Optional<Path> getPath()
+ {
+ return Optional.ofNullable( path );
+ }
+
+ public void setPath( Path path )
+ {
+ this.path = path;
+ }
+
+ @Override
+ public boolean isSnapshot()
+ {
+ return version.endsWith( SNAPSHOT ) || SNAPSHOT_TIMESTAMP.matcher( version ).matches();
+ }
+
+ @Override
+ public boolean equals( Object o )
+ {
+ if ( this == o )
+ {
+ return true;
+ }
+ if ( o == null || getClass() != o.getClass() )
+ {
+ return false;
+ }
+ ArtifactStub that = (ArtifactStub) o;
+ return Objects.equals( groupId, that.groupId ) && Objects.equals( artifactId, that.artifactId )
+ && Objects.equals( classifier, that.classifier ) && Objects.equals( version,
+ that.version ) && Objects.equals( extension, that.extension ) && Objects.equals(
+ baseVersion, that.baseVersion ) && Objects.equals( path, that.path );
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return Objects.hash( groupId, artifactId, classifier, version, extension, baseVersion, path );
+ }
+
+ @Override
+ public String toString()
+ {
+ return "ArtifactStub{" +
+ "groupId='" + groupId + '\'' +
+ ", artifactId='" + artifactId + '\'' +
+ ", classifier='" + classifier + '\'' +
+ ", version='" + version + '\'' +
+ ", extension='" + extension + '\'' +
+ ", baseVersion='" + baseVersion + '\'' +
+ ", path=" + path +
+ '}';
+ }
+}
diff --git a/src/test/java/org/apache/maven/plugins/deploy/stubs/AttachedArtifactStub.java b/src/test/java/org/apache/maven/plugins/deploy/stubs/AttachedArtifactStub.java
deleted file mode 100644
index 0419a85..0000000
--- a/src/test/java/org/apache/maven/plugins/deploy/stubs/AttachedArtifactStub.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package org.apache.maven.plugins.deploy.stubs;
-
-/*
- * 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 java.io.File;
-
-public class AttachedArtifactStub
- extends DeployArtifactStub
-{
- public String getArtifactId()
- {
- return "attached-artifact-test-0";
- }
-
- public File getFile()
- {
- return new File( System.getProperty( "basedir" ),
- "target/test-classes/unit/basic-deploy-with-attached-artifacts/" +
- "target/deploy-test-file-1.0-SNAPSHOT.jar" );
- }
-}
diff --git a/src/test/java/org/apache/maven/plugins/deploy/stubs/DeployArtifactStub.java b/src/test/java/org/apache/maven/plugins/deploy/stubs/DeployArtifactStub.java
deleted file mode 100644
index 24f31d5..0000000
--- a/src/test/java/org/apache/maven/plugins/deploy/stubs/DeployArtifactStub.java
+++ /dev/null
@@ -1,139 +0,0 @@
-package org.apache.maven.plugins.deploy.stubs;
-
-/*
- * 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 java.io.File;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.maven.artifact.handler.ArtifactHandler;
-import org.apache.maven.artifact.handler.DefaultArtifactHandler;
-import org.apache.maven.artifact.metadata.ArtifactMetadata;
-import org.apache.maven.plugin.testing.stubs.ArtifactStub;
-
-public class DeployArtifactStub
- extends ArtifactStub
-{
- private Map<Object, ArtifactMetadata> metadataMap;
-
- private File file;
-
- private boolean release;
-
- private String extension;
-
- public String getArtifactId()
- {
- return "maven-deploy-test";
- }
-
- public String getGroupId()
- {
- return "org.apache.maven.test";
- }
-
- public String getVersion()
- {
- return "1.0-SNAPSHOT";
- }
-
- public String getBaseVersion()
- {
- return getVersion();
- }
-
- @Override
- public String getType()
- {
- return "jar";
- }
-
- public void setFile( File file )
- {
- this.file = file;
- }
-
- public File getFile()
- {
- return file;
- }
-
- public ArtifactHandler getArtifactHandler()
- {
- return new DefaultArtifactHandler()
- {
- public String getExtension()
- {
- if( extension == null )
- {
- extension = "jar";
- }
- return extension;
- }
- };
- }
-
- public void setArtifactHandlerExtension( String extension )
- {
- this.extension = extension;
- }
-
- public void addMetadata( ArtifactMetadata metadata )
- {
- if ( metadataMap == null )
- {
- metadataMap = new HashMap<Object, ArtifactMetadata>();
- }
-
- ArtifactMetadata m = metadataMap.get( metadata.getKey() );
- if ( m != null )
- {
- m.merge( metadata );
- }
- else
- {
- metadataMap.put( metadata.getKey(), metadata );
- }
- }
-
- public Collection<ArtifactMetadata> getMetadataList()
- {
- return metadataMap == null ? Collections.<ArtifactMetadata>emptyList() : metadataMap.values();
- }
-
- public boolean isRelease()
- {
- return release;
- }
-
- public void setRelease( boolean release )
- {
- this.release = release;
- }
-
- /*
- public boolean isSnapshot()
- {
- return false;
- }
- */
-}
diff --git a/src/test/java/org/apache/maven/plugins/deploy/stubs/MavenProjectStub.java b/src/test/java/org/apache/maven/plugins/deploy/stubs/MavenProjectStub.java
deleted file mode 100644
index 91709a3..0000000
--- a/src/test/java/org/apache/maven/plugins/deploy/stubs/MavenProjectStub.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package org.apache.maven.plugins.deploy.stubs;
-
-/*
- * 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.artifact.repository.ArtifactRepository;
-
-public class MavenProjectStub
- extends org.apache.maven.plugin.testing.stubs.MavenProjectStub
-{
-
- private ArtifactRepositoryStub deploymentRepository;
-
- public ArtifactRepository getDistributionManagementArtifactRepository()
- {
- return deploymentRepository;
- }
-
-}
diff --git a/src/test/java/org/apache/maven/plugins/deploy/stubs/ProjectDeployerStub.java b/src/test/java/org/apache/maven/plugins/deploy/stubs/ProjectDeployerStub.java
deleted file mode 100644
index f7be122..0000000
--- a/src/test/java/org/apache/maven/plugins/deploy/stubs/ProjectDeployerStub.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package org.apache.maven.plugins.deploy.stubs;
-
-/*
- * 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.api.services.ProjectDeployer;
-import org.apache.maven.api.services.ProjectDeployerException;
-import org.apache.maven.api.services.ProjectDeployerRequest;
-
-public class ProjectDeployerStub
- implements ProjectDeployer
-{
- @Override
- public void deploy( ProjectDeployerRequest request ) throws ProjectDeployerException, IllegalArgumentException
- {
-
- }
-}
diff --git a/src/test/java/org/apache/maven/plugins/deploy/stubs/ProjectStub.java b/src/test/java/org/apache/maven/plugins/deploy/stubs/ProjectStub.java
index 12df4a8..4d4563d 100644
--- a/src/test/java/org/apache/maven/plugins/deploy/stubs/ProjectStub.java
+++ b/src/test/java/org/apache/maven/plugins/deploy/stubs/ProjectStub.java
@@ -21,6 +21,7 @@ package org.apache.maven.plugins.deploy.stubs;
import javax.annotation.Nonnull;
+import java.io.File;
import java.nio.file.Path;
import java.util.List;
@@ -34,6 +35,11 @@ public class ProjectStub implements Project
private String groupId;
private String artifactId;
private String version;
+ private String packaging;
+ private Artifact artifact;
+ private Model model;
+ private File pomPath;
+ private boolean executionRoot;
@Nonnull
@Override
@@ -60,28 +66,28 @@ public class ProjectStub implements Project
@Override
public String getPackaging()
{
- return null;
+ return packaging;
}
@Nonnull
@Override
public Artifact getArtifact()
{
- return null;
+ return artifact;
}
@Nonnull
@Override
public Model getModel()
{
- return null;
+ return model;
}
@Nonnull
@Override
public Path getPomPath()
{
- return null;
+ return pomPath.toPath();
}
@Nonnull
@@ -98,6 +104,12 @@ public class ProjectStub implements Project
return null;
}
+ @Override
+ public boolean isExecutionRoot()
+ {
+ return executionRoot;
+ }
+
public void setGroupId( String groupId )
{
this.groupId = groupId;
@@ -112,4 +124,29 @@ public class ProjectStub implements Project
{
this.version = version;
}
+
+ public void setPackaging( String packaging )
+ {
+ this.packaging = packaging;
+ }
+
+ public void setArtifact( Artifact artifact )
+ {
+ this.artifact = artifact;
+ }
+
+ public void setModel( Model model )
+ {
+ this.model = model;
+ }
+
+ public void setPomPath( File pomPath )
+ {
+ this.pomPath = pomPath;
+ }
+
+ public void setExecutionRoot( boolean executionRoot )
+ {
+ this.executionRoot = executionRoot;
+ }
}
diff --git a/src/test/java/org/apache/maven/plugins/deploy/stubs/SessionStub.java b/src/test/java/org/apache/maven/plugins/deploy/stubs/SessionStub.java
new file mode 100644
index 0000000..c14a673
--- /dev/null
+++ b/src/test/java/org/apache/maven/plugins/deploy/stubs/SessionStub.java
@@ -0,0 +1,217 @@
+package org.apache.maven.plugins.deploy.stubs;
+
+/*
+ * 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 java.net.URI;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+
+import org.apache.maven.api.Artifact;
+import org.apache.maven.api.LocalRepository;
+import org.apache.maven.api.Project;
+import org.apache.maven.api.RemoteRepository;
+import org.apache.maven.api.Session;
+import org.apache.maven.api.services.ArtifactDeployer;
+import org.apache.maven.api.services.ArtifactDeployerRequest;
+import org.apache.maven.api.services.ArtifactFactory;
+import org.apache.maven.api.services.ArtifactFactoryRequest;
+import org.apache.maven.api.services.ArtifactInstaller;
+import org.apache.maven.api.services.ArtifactInstallerRequest;
+import org.apache.maven.api.services.ArtifactManager;
+import org.apache.maven.api.services.LocalRepositoryManager;
+import org.apache.maven.api.services.ProjectBuilder;
+import org.apache.maven.api.services.ProjectBuilderRequest;
+import org.apache.maven.api.services.ProjectBuilderResult;
+import org.apache.maven.api.services.ProjectManager;
+import org.apache.maven.api.services.RepositoryFactory;
+import org.apache.maven.model.Model;
+import org.apache.maven.model.Repository;
+import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
+import org.mockito.ArgumentMatchers;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.same;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.mockito.Mockito.withSettings;
+
+public class SessionStub
+{
+
+ public static Session getMockSession( String localRepo )
+ {
+ Session session = mock( Session.class );
+
+ RepositoryFactory repositoryFactory = mock( RepositoryFactory.class );
+ when( repositoryFactory.createRemote( any( Repository.class ) ) )
+ .thenAnswer( iom -> {
+ Repository repository = iom.getArgument( 0, Repository.class );
+ return repositoryFactory.createRemote( repository.getId(), repository.getUrl() );
+ } );
+ when( repositoryFactory.createRemote( anyString(), anyString() ) )
+ .thenAnswer( iom -> {
+ String id = iom.getArgument( 0, String.class );
+ String url = iom.getArgument( 1, String.class );
+ RemoteRepository remoteRepository = mock( RemoteRepository.class, withSettings().lenient() );
+ when( remoteRepository.getId() ).thenReturn( id );
+ when( remoteRepository.getUrl() ).thenReturn( url );
+ when( remoteRepository.getProtocol() ).thenReturn( URI.create( url ).getScheme() );
+ return remoteRepository;
+ } );
+
+ LocalRepositoryManager localRepositoryManager = mock( LocalRepositoryManager.class );
+ when( localRepositoryManager.getPathForLocalArtifact( any(), any(), any() ) )
+ .thenAnswer( iom -> {
+ LocalRepository localRepository = iom.getArgument( 1, LocalRepository.class );
+ Artifact artifact = iom.getArgument( 2, Artifact.class );
+ return localRepository.getPath().resolve( getPathForArtifact( artifact, true ) );
+ } );
+
+ ArtifactInstaller artifactInstaller = mock( ArtifactInstaller.class );
+ doAnswer( iom -> {
+ artifactInstaller.install( ArtifactInstallerRequest.build(
+ iom.getArgument( 0, Session.class ),
+ iom.getArgument( 1, Collection.class ) ) );
+ return null;
+ } ).when( artifactInstaller ).install( any( Session.class ), ArgumentMatchers.<Collection<Artifact>>any() );
+
+ ArtifactDeployer artifactDeployer = mock( ArtifactDeployer.class );
+ doAnswer( iom -> {
+ artifactDeployer.deploy( ArtifactDeployerRequest.build(
+ iom.getArgument( 0, Session.class ),
+ iom.getArgument( 1, RemoteRepository.class ),
+ iom.getArgument( 2, Collection.class ) ) );
+ return null;
+ } ).when( artifactDeployer ).deploy( any(), any(), any() );
+
+ ArtifactManager artifactManager = mock( ArtifactManager.class );
+ Map<Artifact, Path> paths = new HashMap<>();
+ doAnswer( iom -> { paths.put( iom.getArgument( 0 ), iom.getArgument( 1 ) ); return null; } )
+ .when( artifactManager ).setPath( any(), any() );
+ doAnswer( iom -> Optional.ofNullable( paths.get( iom.getArgument( 0, Artifact.class ) ) ) )
+ .when( artifactManager ).getPath( any() );
+
+ LocalRepository localRepository = mock( LocalRepository.class );
+ when( localRepository.getId() ).thenReturn( "local" );
+ when( localRepository.getPath() ).thenReturn( Paths.get( localRepo ) );
+
+ ProjectManager projectManager = mock( ProjectManager.class );
+ Map<Project, Collection<Artifact>> attachedArtifacts = new HashMap<>();
+ doAnswer( iom -> {
+ Project project = iom.getArgument( 1, Project.class );
+ String type = iom.getArgument( 2, String.class );
+ String classifier = iom.getArgument( 3, String.class );
+ Path path = iom.getArgument( 4, Path.class );
+ Artifact artifact = session.createArtifact( project.getGroupId(), project.getArtifactId(), classifier, project.getVersion(), type );
+ artifactManager.setPath( artifact, path );
+ attachedArtifacts.computeIfAbsent( project, p -> new ArrayList<>() )
+ .add( artifact );
+ return null;
+ } ).when( projectManager ).attachArtifact( same( session ), any( Project.class ), any(), any(), any() );
+ doAnswer( iom -> {
+ Project project = iom.getArgument( 0, Project.class );
+ Artifact artifact = iom.getArgument( 1, Artifact.class );
+ Path path = iom.getArgument( 2, Path.class );
+ artifactManager.setPath( artifact, path );
+ attachedArtifacts.computeIfAbsent( project, p -> new ArrayList<>() )
+ .add( artifact );
+ return null;
+ } ).when( projectManager ).attachArtifact( any( Project.class ), any( Artifact.class ), any( Path.class ) );
+ when( projectManager.getAttachedArtifacts( any() ) )
+ .then( iom -> attachedArtifacts.computeIfAbsent( iom.getArgument( 0, Project.class ), p -> new ArrayList<>() ) );
+
+ ArtifactFactory artifactFactory = mock( ArtifactFactory.class );
+ when( artifactFactory.create( any() ) )
+ .then( iom -> {
+ ArtifactFactoryRequest request = iom.getArgument( 0, ArtifactFactoryRequest.class );
+ return new ArtifactStub( request.getGroupId(), request.getArtifactId(),
+ request.getClassifier() != null ? request.getClassifier() : "",
+ request.getVersion(), request.getType() );
+ } );
+
+ ProjectBuilder projectBuilder = mock( ProjectBuilder.class );
+ when( projectBuilder.build( any( ProjectBuilderRequest.class ) ) ).then( iom -> {
+ ProjectBuilderRequest request = iom.getArgument( 0, ProjectBuilderRequest.class );
+ ProjectBuilderResult result = mock( ProjectBuilderResult.class );
+ Model model = new MavenXpp3Reader().read( request.getSource().get().getInputStream() );
+ ProjectStub projectStub = new ProjectStub();
+ projectStub.setModel( model );
+ projectStub.setGroupId( model.getGroupId() );
+ projectStub.setArtifactId( model.getArtifactId() );
+ projectStub.setVersion( model.getVersion() );
+ projectStub.setPackaging( model.getPackaging() );
+ ArtifactStub artifactStub = new ArtifactStub( model.getGroupId(), model.getArtifactId(), "", model.getVersion(), model.getPackaging() );
+ projectStub.setArtifact( artifactStub );
+ when( result.getProject() ).thenReturn( Optional.of( projectStub ) );
+ return result;
+ } );
+
+ when( session.getLocalRepository() ).thenReturn( localRepository );
+ when( session.getService( RepositoryFactory.class ) ).thenReturn( repositoryFactory );
+ when( session.getService( ProjectBuilder.class ) ).thenReturn( projectBuilder );
+ when( session.getService( LocalRepositoryManager.class ) ).thenReturn( localRepositoryManager );
+ when( session.getService( ProjectManager.class ) ).thenReturn( projectManager );
+ when( session.getService( ArtifactManager.class ) ).thenReturn( artifactManager );
+ when( session.getService( ArtifactInstaller.class ) ).thenReturn( artifactInstaller );
+ when( session.getService( ArtifactDeployer.class ) ).thenReturn( artifactDeployer );
+ when( session.getService( ArtifactFactory.class ) ).thenReturn( artifactFactory );
+
+ when( session.getPathForLocalArtifact( any( Artifact.class ) ) )
+ .then( iom -> localRepositoryManager.getPathForLocalArtifact( session, session.getLocalRepository(), iom.getArgument( 0, Artifact.class ) ) );
+ when( session.createArtifact( any(), any(), any(), any(), any() ) )
+ .thenAnswer( iom ->
+ session.getService( ArtifactFactory.class ).create( ArtifactFactoryRequest.builder()
+ .session( session )
+ .groupId( iom.getArgument( 0, String.class ) )
+ .artifactId( iom.getArgument( 1, String.class ) )
+ .classifier( iom.getArgument( 2, String.class ) )
+ .version( iom.getArgument( 3, String.class ) )
+ .type( iom.getArgument( 4, String.class ) )
+ .build() ) );
+ return session;
+ }
+
+ static String getPathForArtifact( Artifact artifact, boolean local )
+ {
+ StringBuilder path = new StringBuilder( 128 );
+ path.append( artifact.getGroupId().replace( '.', '/' ) ).append( '/' );
+ path.append( artifact.getArtifactId() ).append( '/' );
+ path.append( artifact.getBaseVersion() ).append( '/' );
+ path.append( artifact.getArtifactId() ).append( '-' );
+ path.append( local ? artifact.getBaseVersion() : artifact.getVersion() );
+ if ( artifact.getClassifier().length() > 0 )
+ {
+ path.append( '-' ).append( artifact.getClassifier() );
+ }
+ if ( artifact.getExtension().length() > 0 )
+ {
+ path.append( '.' ).append( artifact.getExtension() );
+ }
+ return path.toString();
+ }
+
+}
diff --git a/src/test/resources/unit/basic-deploy-pom/plugin-config.xml b/src/test/resources/unit/basic-deploy-pom/plugin-config.xml
deleted file mode 100644
index 8cf373c..0000000
--- a/src/test/resources/unit/basic-deploy-pom/plugin-config.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-<!--
-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.
--->
-
-<project>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-deploy-plugin</artifactId>
- <configuration>
- <project implementation="org.apache.maven.plugins.deploy.stubs.MavenProjectStub">
- <file>${basedir}/src/test/resources/unit/basic-deploy-pom/plugin-config.xml</file>
- <packaging>pom</packaging>
- <artifact implementation="org.apache.maven.plugins.deploy.stubs.DeployArtifactStub" />
- <attachedArtifacts />
- <deploymentRepository implementation="org.apache.maven.plugins.deploy.stubs.ArtifactRepositoryStub">
- <basedir>${basedir}</basedir>
- </deploymentRepository>
- </project>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/src/test/resources/unit/basic-deploy-scp/plugin-config.xml b/src/test/resources/unit/basic-deploy-scp/plugin-config.xml
deleted file mode 100644
index 4b3a9bf..0000000
--- a/src/test/resources/unit/basic-deploy-scp/plugin-config.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-<!--
-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.
--->
-
-<project>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-deploy-plugin</artifactId>
- <configuration>
- <project implementation="org.apache.maven.plugins.deploy.stubs.MavenProjectStub">
- <file>${basedir}/src/test/resources/unit/basic-deploy-scp/plugin-config.xml</file>
- <packaging>jar</packaging>
- <artifact implementation="org.apache.maven.plugins.deploy.stubs.DeployArtifactStub" />
- <attachedArtifacts />
- <deploymentRepository implementation="org.apache.maven.plugins.deploy.stubs.ArtifactRepositoryStub2" />
- </project>
- <deployer implementation="org.apache.maven.plugins.deploy.stubs.ArtifactDeployerStub" />
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/src/test/resources/unit/basic-deploy-scp/target/deploy-test-file-1.0-SNAPSHOT.jar b/src/test/resources/unit/basic-deploy-scp/target/deploy-test-file-1.0-SNAPSHOT.jar
deleted file mode 100644
index 6f5f2f8..0000000
--- a/src/test/resources/unit/basic-deploy-scp/target/deploy-test-file-1.0-SNAPSHOT.jar
+++ /dev/null
@@ -1 +0,0 @@
-This is not an actual jar
\ No newline at end of file
diff --git a/src/test/resources/unit/basic-deploy-test/target/deploy-test-file-1.0-SNAPSHOT.jar b/src/test/resources/unit/basic-deploy-test/target/deploy-test-file-1.0-SNAPSHOT.jar
deleted file mode 100644
index 6f5f2f8..0000000
--- a/src/test/resources/unit/basic-deploy-test/target/deploy-test-file-1.0-SNAPSHOT.jar
+++ /dev/null
@@ -1 +0,0 @@
-This is not an actual jar
\ No newline at end of file
diff --git a/src/test/resources/unit/basic-deploy-with-attached-artifacts/plugin-config.xml b/src/test/resources/unit/basic-deploy-with-attached-artifacts/plugin-config.xml
deleted file mode 100644
index 417c54e..0000000
--- a/src/test/resources/unit/basic-deploy-with-attached-artifacts/plugin-config.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-<!--
-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.
--->
-
-<project>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-deploy-plugin</artifactId>
- <configuration>
- <project implementation="org.apache.maven.plugins.deploy.stubs.MavenProjectStub">
- <file>${basedir}/src/test/resources/unit/basic-deploy-with-attached-artifacts/plugin-config.xml</file>
- <packaging>jar</packaging>
- <artifact implementation="org.apache.maven.plugins.deploy.stubs.DeployArtifactStub" />
- <attachedArtifacts>
- <attachedArtifact implementation="org.apache.maven.plugins.deploy.stubs.AttachedArtifactStub" />
- </attachedArtifacts>
- <deploymentRepository implementation="org.apache.maven.plugins.deploy.stubs.ArtifactRepositoryStub">
- <basedir>${basedir}</basedir>
- </deploymentRepository>
- </project>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/src/test/resources/unit/basic-deploy-with-attached-artifacts/target/deploy-test-file-1.0-SNAPSHOT.jar b/src/test/resources/unit/basic-deploy-with-attached-artifacts/target/deploy-test-file-1.0-SNAPSHOT.jar
deleted file mode 100644
index 6f5f2f8..0000000
--- a/src/test/resources/unit/basic-deploy-with-attached-artifacts/target/deploy-test-file-1.0-SNAPSHOT.jar
+++ /dev/null
@@ -1 +0,0 @@
-This is not an actual jar
\ No newline at end of file
diff --git a/src/test/resources/unit/deploy-file-test/target/deploy-test-file-1.0-SNAPSHOT.jar b/src/test/resources/unit/basic-deploy/attached-artifact-test-1.0-SNAPSHOT.jar
similarity index 100%
rename from src/test/resources/unit/deploy-file-test/target/deploy-test-file-1.0-SNAPSHOT.jar
rename to src/test/resources/unit/basic-deploy/attached-artifact-test-1.0-SNAPSHOT.jar
diff --git a/src/test/resources/unit/deploy-file-pom-file/target/deploy-test-file-1.0-SNAPSHOT.jar b/src/test/resources/unit/basic-deploy/deploy-test-file-1.0-SNAPSHOT.jar
similarity index 100%
rename from src/test/resources/unit/deploy-file-pom-file/target/deploy-test-file-1.0-SNAPSHOT.jar
rename to src/test/resources/unit/basic-deploy/deploy-test-file-1.0-SNAPSHOT.jar
diff --git a/src/test/resources/unit/basic-deploy-pom/target/deploy-test-file-1.0-SNAPSHOT.pom b/src/test/resources/unit/basic-deploy/deploy-test-file-1.0-SNAPSHOT.pom
similarity index 100%
rename from src/test/resources/unit/basic-deploy-pom/target/deploy-test-file-1.0-SNAPSHOT.pom
rename to src/test/resources/unit/basic-deploy/deploy-test-file-1.0-SNAPSHOT.pom
diff --git a/src/test/resources/unit/basic-deploy-test/plugin-config.xml b/src/test/resources/unit/basic-deploy/plugin-config.xml
similarity index 55%
rename from src/test/resources/unit/basic-deploy-test/plugin-config.xml
rename to src/test/resources/unit/basic-deploy/plugin-config.xml
index a98749b..cafe9b2 100644
Binary files a/src/test/resources/unit/basic-deploy-test/plugin-config.xml and b/src/test/resources/unit/basic-deploy/plugin-config.xml differ
diff --git a/src/test/resources/unit/deploy-file-classifier/target/deploy-test-file-1.0-SNAPSHOT.jar b/src/test/resources/unit/deploy-file/deploy-test-file-1.0-SNAPSHOT.jar
similarity index 100%
rename from src/test/resources/unit/deploy-file-classifier/target/deploy-test-file-1.0-SNAPSHOT.jar
rename to src/test/resources/unit/deploy-file/deploy-test-file-1.0-SNAPSHOT.jar
diff --git a/src/test/resources/unit/deploy-file-artifact-not-jar/target/deploy-test-file.zip b/src/test/resources/unit/deploy-file/deploy-test-file.zip
similarity index 100%
rename from src/test/resources/unit/deploy-file-artifact-not-jar/target/deploy-test-file.zip
rename to src/test/resources/unit/deploy-file/deploy-test-file.zip
diff --git a/src/test/resources/unit/deploy-file-artifact-not-jar/plugin-config.xml b/src/test/resources/unit/deploy-file/plugin-config-artifact-not-jar.xml
similarity index 85%
rename from src/test/resources/unit/deploy-file-artifact-not-jar/plugin-config.xml
rename to src/test/resources/unit/deploy-file/plugin-config-artifact-not-jar.xml
index 7db42a3..5db56b5 100644
--- a/src/test/resources/unit/deploy-file-artifact-not-jar/plugin-config.xml
+++ b/src/test/resources/unit/deploy-file/plugin-config-artifact-not-jar.xml
@@ -26,9 +26,9 @@ under the License.
<groupId>org.apache.maven.test</groupId>
<artifactId>maven-deploy-file-test</artifactId>
<version>1.0</version>
- <file>${basedir}/src/test/resources/unit/deploy-file-artifact-not-jar/target/deploy-test-file.zip</file>
+ <file>${basedir}/src/test/resources/unit/deploy-file/deploy-test-file.zip</file>
<repositoryId>deploy-test</repositoryId>
- <url>file://${basedir}/target/remote-repo/deploy-file-artifact-not-jar</url>
+ <url>file://${basedir}/target/remote-repo/deploy-file</url>
<generatePom>true</generatePom>
</configuration>
</plugin>
diff --git a/src/test/resources/unit/deploy-file-classifier/plugin-config.xml b/src/test/resources/unit/deploy-file/plugin-config-classifier.xml
similarity index 86%
rename from src/test/resources/unit/deploy-file-classifier/plugin-config.xml
rename to src/test/resources/unit/deploy-file/plugin-config-classifier.xml
index b77961b..2ec0268 100644
--- a/src/test/resources/unit/deploy-file-classifier/plugin-config.xml
+++ b/src/test/resources/unit/deploy-file/plugin-config-classifier.xml
@@ -27,9 +27,9 @@ under the License.
<artifactId>maven-deploy-file-test</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
- <file>${basedir}/src/test/resources/unit/deploy-file-classifier/target/deploy-test-file-1.0-SNAPSHOT.jar</file>
+ <file>${basedir}/src/test/resources/unit/deploy-file/deploy-test-file-1.0-SNAPSHOT.jar</file>
<repositoryId>deploy-test</repositoryId>
- <url>file://${basedir}/target/remote-repo/deploy-file-classifier</url>
+ <url>file://${basedir}/target/remote-repo/deploy-file</url>
<classifier>bin</classifier>
<generatePom>true</generatePom>
</configuration>
diff --git a/src/test/resources/unit/deploy-file-pom-file/plugin-config.xml b/src/test/resources/unit/deploy-file/plugin-config-pom-file.xml
similarity index 89%
rename from src/test/resources/unit/deploy-file-pom-file/plugin-config.xml
rename to src/test/resources/unit/deploy-file/plugin-config-pom-file.xml
index 3a4e2ce..42b15e1 100644
Binary files a/src/test/resources/unit/deploy-file-pom-file/plugin-config.xml and b/src/test/resources/unit/deploy-file/plugin-config-pom-file.xml differ
diff --git a/src/test/resources/unit/deploy-file-test/plugin-config.xml b/src/test/resources/unit/deploy-file/plugin-config-test.xml
similarity index 92%
rename from src/test/resources/unit/deploy-file-test/plugin-config.xml
rename to src/test/resources/unit/deploy-file/plugin-config-test.xml
index 67b98a1..6ab5d91 100644
--- a/src/test/resources/unit/deploy-file-test/plugin-config.xml
+++ b/src/test/resources/unit/deploy-file/plugin-config-test.xml
@@ -27,7 +27,7 @@ under the License.
<artifactId>maven-deploy-file-test</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
- <file>${basedir}/src/test/resources/unit/deploy-file-test/target/deploy-test-file-1.0-SNAPSHOT.jar</file>
+ <file>${basedir}/src/test/resources/unit/deploy-file/deploy-test-file-1.0-SNAPSHOT.jar</file>
<repositoryId>deploy-test</repositoryId>
<url>file://${basedir}/target/remote-repo/deploy-file-test</url>
<description>POM was created from deploy:deploy-file</description>