This is an automated email from the ASF dual-hosted git repository.

cstamas pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-deploy-plugin.git


The following commit(s) were added to refs/heads/master by this push:
     new 390e610  [MDEPLOY-313] Update to parent 41, cleanup (#47)
390e610 is described below

commit 390e610c65ef0ec2ec0e4851d7e1eaf53e7787f3
Author: Tamas Cservenak <[email protected]>
AuthorDate: Fri Jan 12 21:03:02 2024 +0100

    [MDEPLOY-313] Update to parent 41, cleanup (#47)
    
    In general perform a cleanup of plugin, apply updates where needed. The 
plugin now builds against 3.9.x latest, and minimum is left as is (3.2.5).
    
    A notable change along that above is removal of "baked in" packaging, now 
plugin relies completely and only on what project and artifact tells, there is 
no "if this is POM" check anymore. The new "BOM UT" shows this in action. Has 
to be noted though, that the UT tests ONLY the plugin, to use BOM packaging you 
need Maven that knows what it is (Maven 3 w/ extension or Maven 4 that has it 
OOTB).
    
    ---
    
    https://issues.apache.org/jira/browse/MDEPLOY-313
---
 pom.xml                                            |  72 +++++----
 .../verify.groovy                                  |   4 +-
 .../maven/plugins/deploy/DeployFileMojo.java       |  27 +---
 .../apache/maven/plugins/deploy/DeployMojo.java    |  32 +++-
 .../maven/plugins/deploy/DeployFileMojoTest.java   |  16 +-
 .../maven/plugins/deploy/DeployMojoTest.java       | 166 +++++++++++----------
 .../deploy/stubs/DeployBomArtifactStub.java}       |  66 ++++----
 .../deploy/stubs/DeployPomArtifactStub.java}       |  66 ++++----
 .../plugin-config.xml                              |   6 +-
 .../target/deploy-test-file-1.0-SNAPSHOT.pom}      |  67 ++++-----
 .../unit/basic-deploy-pom/plugin-config.xml        |   2 +-
 11 files changed, 285 insertions(+), 239 deletions(-)

diff --git a/pom.xml b/pom.xml
index fc75b7c..0340c38 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@ under the License.
   <parent>
     <groupId>org.apache.maven.plugins</groupId>
     <artifactId>maven-plugins</artifactId>
-    <version>39</version>
+    <version>41</version>
     <relativePath />
   </parent>
 
@@ -43,7 +43,7 @@ under the License.
   </contributors>
 
   <prerequisites>
-    <maven>${mavenVersion}</maven>
+    <maven>3.2.5</maven>
   </prerequisites>
 
   <scm>
@@ -69,24 +69,24 @@ under the License.
 
   <properties>
     <javaVersion>8</javaVersion>
-    <mavenVersion>3.2.5</mavenVersion>
+    <mavenVersion>3.9.6</mavenVersion>
     <!-- Keep in sync with resolver used in maven above -->
-    <slf4jVersion>1.7.5</slf4jVersion>
+    <slf4jVersion>1.7.36</slf4jVersion>
     <!-- Keep in sync with resolver used in maven above -->
-    <resolverVersion>1.0.0.v20140518</resolverVersion>
+    <resolverVersion>1.9.18</resolverVersion>
 
     <!-- plugins version used in IT tests -->
-    <mavenAntrunPluginVersion>3.1.0</mavenAntrunPluginVersion>
-    <mavenCompilerPluginVersion>3.10.1</mavenCompilerPluginVersion>
-    <mavenEnforcerPluginVersion>3.1.0</mavenEnforcerPluginVersion>
-    <mavenInstallPluginVersion>3.1.0</mavenInstallPluginVersion>
-    <mavenJarPluginVersion>3.3.0</mavenJarPluginVersion>
-    <mavenJavadocPluginVersion>3.4.1</mavenJavadocPluginVersion>
-    
<mavenPluginToolsVersion>${maven.plugin.tools.version}</mavenPluginToolsVersion>
-    <mavenResourcesPluginVersion>3.3.0</mavenResourcesPluginVersion>
-    <mavenSourcePluginVersion>3.2.1</mavenSourcePluginVersion>
-    
<mavenSurefirePluginVersion>${surefire.version}</mavenSurefirePluginVersion>
-    <mavenWarPluginVersion>3.3.2</mavenWarPluginVersion>
+    
<mavenAntrunPluginVersion>${version.maven-antrun-plugin}</mavenAntrunPluginVersion>
+    
<mavenCompilerPluginVersion>${version.maven-compiler-plugin}</mavenCompilerPluginVersion>
+    
<mavenEnforcerPluginVersion>${version.maven-enforcer-plugin}</mavenEnforcerPluginVersion>
+    
<mavenInstallPluginVersion>${version.maven-install-plugin}</mavenInstallPluginVersion>
+    <mavenJarPluginVersion>${version.maven-jar-plugin}</mavenJarPluginVersion>
+    
<mavenJavadocPluginVersion>${version.maven-javadoc-plugin}</mavenJavadocPluginVersion>
+    
<mavenPluginToolsVersion>${version.maven-plugin-tools}</mavenPluginToolsVersion>
+    
<mavenResourcesPluginVersion>${version.maven-resources-plugin}</mavenResourcesPluginVersion>
+    
<mavenSourcePluginVersion>${version.maven-source-plugin}</mavenSourcePluginVersion>
+    
<mavenSurefirePluginVersion>${version.maven-surefire}</mavenSurefirePluginVersion>
+    <mavenWarPluginVersion>${version.maven-war-plugin}</mavenWarPluginVersion>
 
     
<project.build.outputTimestamp>2023-03-21T14:38:01Z</project.build.outputTimestamp>
   </properties>
@@ -128,14 +128,18 @@ under the License.
       <artifactId>plexus-utils</artifactId>
     </dependency>
     <dependency>
-      <groupId>org.eclipse.aether</groupId>
-      <artifactId>aether-api</artifactId>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-xml</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven.resolver</groupId>
+      <artifactId>maven-resolver-api</artifactId>
       <version>${resolverVersion}</version>
       <scope>provided</scope>
     </dependency>
     <dependency>
-      <groupId>org.eclipse.aether</groupId>
-      <artifactId>aether-util</artifactId>
+      <groupId>org.apache.maven.resolver</groupId>
+      <artifactId>maven-resolver-util</artifactId>
       <version>${resolverVersion}</version>
       <!-- To work in Maven versions older than 3.9.0 -->
       <scope>compile</scope>
@@ -164,25 +168,25 @@ under the License.
     </dependency>
     <dependency>
       <groupId>org.apache.maven</groupId>
-      <artifactId>maven-aether-provider</artifactId>
+      <artifactId>maven-resolver-provider</artifactId>
       <version>${mavenVersion}</version>
       <scope>test</scope>
     </dependency>
     <dependency>
-      <groupId>org.eclipse.aether</groupId>
-      <artifactId>aether-connector-basic</artifactId>
+      <groupId>org.apache.maven.resolver</groupId>
+      <artifactId>maven-resolver-connector-basic</artifactId>
       <version>${resolverVersion}</version>
       <scope>test</scope>
     </dependency>
     <dependency>
-      <groupId>org.eclipse.aether</groupId>
-      <artifactId>aether-transport-file</artifactId>
+      <groupId>org.apache.maven.resolver</groupId>
+      <artifactId>maven-resolver-transport-file</artifactId>
       <version>${resolverVersion}</version>
       <scope>test</scope>
     </dependency>
     <dependency>
-      <groupId>org.eclipse.aether</groupId>
-      <artifactId>aether-transport-http</artifactId>
+      <groupId>org.apache.maven.resolver</groupId>
+      <artifactId>maven-resolver-transport-http</artifactId>
       <version>${resolverVersion}</version>
       <scope>test</scope>
     </dependency>
@@ -204,9 +208,21 @@ under the License.
       <version>${slf4jVersion}</version>
       <scope>test</scope>
     </dependency>
-
   </dependencies>
 
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <configuration>
+          <proc>none</proc>
+          <showDeprecation>true</showDeprecation>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
   <profiles>
     <profile>
       <id>run-its</id>
diff --git a/src/it/MDEPLOY-178_deployfile-with-embedded-pom/verify.groovy 
b/src/it/MDEPLOY-178_deployfile-with-embedded-pom/verify.groovy
index 2b197b2..181104a 100644
--- a/src/it/MDEPLOY-178_deployfile-with-embedded-pom/verify.groovy
+++ b/src/it/MDEPLOY-178_deployfile-with-embedded-pom/verify.groovy
@@ -25,5 +25,5 @@ File buildLog = new File( basedir, 'build.log' )
 assert buildLog.exists()
 assert buildLog.text.contains( "[DEBUG] Using 
META-INF/maven/org.apache.maven.plugins.deploy.its/mdeploy178/pom.xml as 
pomFile" )
 
-def pomProject = new XmlSlurper().parse( deployedPom )
-assert "https://issues.apache.org/jira/browse/MDEPLOY-178".equals( 
pomProject.url.text() )
\ No newline at end of file
+def pomProject = new groovy.xml.XmlParser().parse( deployedPom )
+assert "https://issues.apache.org/jira/browse/MDEPLOY-178".equals( 
pomProject.get("url").text() )
\ No newline at end of file
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 aeaf5f7..7e6536f 100644
--- a/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java
+++ b/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java
@@ -43,9 +43,9 @@ import org.apache.maven.plugins.annotations.Mojo;
 import org.apache.maven.plugins.annotations.Parameter;
 import org.codehaus.plexus.util.FileUtils;
 import org.codehaus.plexus.util.IOUtil;
-import org.codehaus.plexus.util.ReaderFactory;
 import org.codehaus.plexus.util.StringUtils;
-import org.codehaus.plexus.util.WriterFactory;
+import org.codehaus.plexus.util.xml.ReaderFactory;
+import org.codehaus.plexus.util.xml.WriterFactory;
 import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
 import org.eclipse.aether.RepositorySystemSession;
 import org.eclipse.aether.artifact.Artifact;
@@ -429,21 +429,14 @@ public class DeployFileMojo extends AbstractDeployMojo {
      * @throws MojoExecutionException If the file doesn't exist or cannot be 
read.
      */
     Model readModel(File pomFile) throws MojoExecutionException {
-        Reader reader = null;
-        try {
-            reader = ReaderFactory.newXmlReader(pomFile);
-            final Model model = new MavenXpp3Reader().read(reader);
-            reader.close();
-            reader = null;
-            return model;
+        try (Reader reader = ReaderFactory.newXmlReader(pomFile)) {
+            return new MavenXpp3Reader().read(reader);
         } catch (FileNotFoundException e) {
             throw new MojoExecutionException("POM not found " + pomFile, e);
         } catch (IOException e) {
             throw new MojoExecutionException("Error reading POM " + pomFile, 
e);
         } catch (XmlPullParserException e) {
             throw new MojoExecutionException("Error parsing POM " + pomFile, 
e);
-        } finally {
-            IOUtil.close(reader);
         }
     }
 
@@ -456,23 +449,17 @@ public class DeployFileMojo extends AbstractDeployMojo {
     private File generatePomFile() throws MojoExecutionException {
         Model model = generateModel();
 
-        Writer fw = null;
         try {
             File tempFile = File.createTempFile("mvndeploy", ".pom");
             tempFile.deleteOnExit();
 
-            fw = WriterFactory.newXmlWriter(tempFile);
-
-            new MavenXpp3Writer().write(fw, model);
-
-            fw.close();
-            fw = null;
+            try (Writer fw = WriterFactory.newXmlWriter(tempFile)) {
+                new MavenXpp3Writer().write(fw, model);
+            }
 
             return tempFile;
         } catch (IOException e) {
             throw new MojoExecutionException("Error writing temporary pom 
file: " + e.getMessage(), e);
-        } finally {
-            IOUtil.close(fw);
         }
     }
 
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 c9b0d4a..c3ea850 100644
--- a/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java
+++ b/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java
@@ -38,8 +38,10 @@ import org.apache.maven.plugins.annotations.Mojo;
 import org.apache.maven.plugins.annotations.Parameter;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.project.artifact.ProjectArtifact;
+import org.eclipse.aether.artifact.Artifact;
 import org.eclipse.aether.deployment.DeployRequest;
 import org.eclipse.aether.repository.RemoteRepository;
+import org.eclipse.aether.util.artifact.ArtifactIdUtils;
 
 /**
  * Deploys an artifact to remote repository.
@@ -285,17 +287,35 @@ public class DeployMojo extends AbstractDeployMojo {
     }
 
     private void processProject(final MavenProject project, DeployRequest 
request) throws MojoExecutionException {
+        // always exists, as project exists
+        Artifact pomArtifact = RepositoryUtils.toArtifact(new 
ProjectArtifact(project));
+        // always exists, but at "init" is w/o file (packaging plugin assigns 
file to this when packaged)
+        Artifact projectArtifact = 
RepositoryUtils.toArtifact(project.getArtifact());
+
+        // pom project: pomArtifact and projectArtifact are SAME
+        // jar project: pomArtifact and projectArtifact are DIFFERENT
+        // incomplete project: is not pom project and projectArtifact has no 
file
+
+        // we must compare coordinates ONLY (as projectArtifact may not have 
file, and Artifact.equals factors it in)
+        // BUT if projectArtifact has file set, use that one
+        if (ArtifactIdUtils.equalsId(pomArtifact, projectArtifact)) {
+            if (isFile(projectArtifact.getFile())) {
+                pomArtifact = projectArtifact;
+            }
+            projectArtifact = null;
+        }
 
-        if (isFile(project.getFile())) {
-            request.addArtifact(RepositoryUtils.toArtifact(new 
ProjectArtifact(project)));
+        if (isFile(pomArtifact.getFile())) {
+            request.addArtifact(pomArtifact);
         } else {
             throw new MojoExecutionException("The project POM could not be 
attached");
         }
 
-        if (!"pom".equals(project.getPackaging())) {
-            org.apache.maven.artifact.Artifact mavenMainArtifact = 
project.getArtifact();
-            if (isFile(mavenMainArtifact.getFile())) {
-                
request.addArtifact(RepositoryUtils.toArtifact(mavenMainArtifact));
+        // is not packaged, is "incomplete"
+        boolean isIncomplete = projectArtifact != null && 
!isFile(projectArtifact.getFile());
+        if (projectArtifact != null) {
+            if (!isIncomplete) {
+                request.addArtifact(projectArtifact);
             } else if (!project.getAttachedArtifacts().isEmpty()) {
                 if (allowIncompleteProjects) {
                     getLog().warn("");
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 f36e689..572d8e4 100644
--- a/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoTest.java
+++ b/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoTest.java
@@ -28,6 +28,7 @@ import org.apache.maven.model.Model;
 import org.apache.maven.plugin.testing.AbstractMojoTestCase;
 import org.apache.maven.project.ProjectBuildingRequest;
 import org.eclipse.aether.DefaultRepositorySystemSession;
+import org.eclipse.aether.internal.impl.DefaultLocalPathComposer;
 import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory;
 import org.eclipse.aether.repository.LocalRepository;
 import org.mockito.InjectMocks;
@@ -86,8 +87,9 @@ public class DeployFileMojoTest extends AbstractMojoTestCase {
         
when(buildingRequest.getRepositoryMerging()).thenReturn(ProjectBuildingRequest.RepositoryMerging.POM_DOMINANT);
         when(session.getProjectBuildingRequest()).thenReturn(buildingRequest);
         DefaultRepositorySystemSession repositorySession = new 
DefaultRepositorySystemSession();
-        repositorySession.setLocalRepositoryManager(new 
SimpleLocalRepositoryManagerFactory()
-                .newInstance(repositorySession, new 
LocalRepository(LOCAL_REPO)));
+        repositorySession.setLocalRepositoryManager(
+                new SimpleLocalRepositoryManagerFactory(new 
DefaultLocalPathComposer())
+                        .newInstance(repositorySession, new 
LocalRepository(LOCAL_REPO)));
         
when(buildingRequest.getRepositorySession()).thenReturn(repositorySession);
         when(session.getRepositorySession()).thenReturn(repositorySession);
 
@@ -194,8 +196,9 @@ public class DeployFileMojoTest extends 
AbstractMojoTestCase {
         
when(buildingRequest.getRepositoryMerging()).thenReturn(ProjectBuildingRequest.RepositoryMerging.POM_DOMINANT);
         when(session.getProjectBuildingRequest()).thenReturn(buildingRequest);
         DefaultRepositorySystemSession repositorySession = new 
DefaultRepositorySystemSession();
-        repositorySession.setLocalRepositoryManager(new 
SimpleLocalRepositoryManagerFactory()
-                .newInstance(repositorySession, new 
LocalRepository(LOCAL_REPO)));
+        repositorySession.setLocalRepositoryManager(
+                new SimpleLocalRepositoryManagerFactory(new 
DefaultLocalPathComposer())
+                        .newInstance(repositorySession, new 
LocalRepository(LOCAL_REPO)));
         
when(buildingRequest.getRepositorySession()).thenReturn(repositorySession);
         when(session.getRepositorySession()).thenReturn(repositorySession);
 
@@ -248,8 +251,9 @@ public class DeployFileMojoTest extends 
AbstractMojoTestCase {
         
when(buildingRequest.getRepositoryMerging()).thenReturn(ProjectBuildingRequest.RepositoryMerging.POM_DOMINANT);
         when(session.getProjectBuildingRequest()).thenReturn(buildingRequest);
         DefaultRepositorySystemSession repositorySession = new 
DefaultRepositorySystemSession();
-        repositorySession.setLocalRepositoryManager(new 
SimpleLocalRepositoryManagerFactory()
-                .newInstance(repositorySession, new 
LocalRepository(LOCAL_REPO)));
+        repositorySession.setLocalRepositoryManager(
+                new SimpleLocalRepositoryManagerFactory(new 
DefaultLocalPathComposer())
+                        .newInstance(repositorySession, new 
LocalRepository(LOCAL_REPO)));
         
when(buildingRequest.getRepositorySession()).thenReturn(repositorySession);
         when(session.getRepositorySession()).thenReturn(repositorySession);
 
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 c43bdf5..3b0df77 100644
--- a/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java
+++ b/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java
@@ -23,7 +23,6 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 import java.util.Objects;
-import java.util.Properties;
 import java.util.concurrent.ConcurrentHashMap;
 
 import org.apache.maven.execution.MavenSession;
@@ -37,11 +36,10 @@ import org.apache.maven.project.MavenProject;
 import org.apache.maven.project.ProjectBuildingRequest;
 import org.codehaus.plexus.util.FileUtils;
 import org.eclipse.aether.DefaultRepositorySystemSession;
-import org.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.internal.impl.DefaultLocalPathComposer;
 import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory;
 import org.eclipse.aether.repository.LocalRepository;
 import org.eclipse.aether.repository.RemoteRepository;
-import org.junit.Ignore;
 import org.mockito.InjectMocks;
 import org.mockito.MockitoAnnotations;
 
@@ -75,10 +73,11 @@ public class DeployMojoTest extends AbstractMojoTestCase {
 
         session = mock(MavenSession.class);
         when(session.getPluginContext(any(PluginDescriptor.class), 
any(MavenProject.class)))
-                .thenReturn(new ConcurrentHashMap<String, Object>());
+                .thenReturn(new ConcurrentHashMap<>());
         DefaultRepositorySystemSession repositorySession = new 
DefaultRepositorySystemSession();
-        repositorySession.setLocalRepositoryManager(new 
SimpleLocalRepositoryManagerFactory()
-                .newInstance(repositorySession, new 
LocalRepository(LOCAL_REPO)));
+        repositorySession.setLocalRepositoryManager(
+                new SimpleLocalRepositoryManagerFactory(new 
DefaultLocalPathComposer())
+                        .newInstance(repositorySession, new 
LocalRepository(LOCAL_REPO)));
         when(session.getRepositorySession()).thenReturn(repositorySession);
 
         remoteRepo = new File(REMOTE_REPO);
@@ -124,8 +123,9 @@ public class DeployMojoTest extends AbstractMojoTestCase {
         ProjectBuildingRequest buildingRequest = 
mock(ProjectBuildingRequest.class);
         when(session.getProjectBuildingRequest()).thenReturn(buildingRequest);
         DefaultRepositorySystemSession repositorySession = new 
DefaultRepositorySystemSession();
-        repositorySession.setLocalRepositoryManager(new 
SimpleLocalRepositoryManagerFactory()
-                .newInstance(repositorySession, new 
LocalRepository(LOCAL_REPO)));
+        repositorySession.setLocalRepositoryManager(
+                new SimpleLocalRepositoryManagerFactory(new 
DefaultLocalPathComposer())
+                        .newInstance(repositorySession, new 
LocalRepository(LOCAL_REPO)));
         
when(buildingRequest.getRepositorySession()).thenReturn(repositorySession);
         when(session.getRepositorySession()).thenReturn(repositorySession);
 
@@ -300,8 +300,9 @@ public class DeployMojoTest extends AbstractMojoTestCase {
         ProjectBuildingRequest buildingRequest = 
mock(ProjectBuildingRequest.class);
         when(session.getProjectBuildingRequest()).thenReturn(buildingRequest);
         DefaultRepositorySystemSession repositorySession = new 
DefaultRepositorySystemSession();
-        repositorySession.setLocalRepositoryManager(new 
SimpleLocalRepositoryManagerFactory()
-                .newInstance(repositorySession, new 
LocalRepository(LOCAL_REPO)));
+        repositorySession.setLocalRepositoryManager(
+                new SimpleLocalRepositoryManagerFactory(new 
DefaultLocalPathComposer())
+                        .newInstance(repositorySession, new 
LocalRepository(LOCAL_REPO)));
         
when(buildingRequest.getRepositorySession()).thenReturn(repositorySession);
         when(session.getRepositorySession()).thenReturn(repositorySession);
 
@@ -363,6 +364,82 @@ public class DeployMojoTest extends AbstractMojoTestCase {
         assertEquals(0, getSizeOfExpectedFiles(fileList, expectedFiles));
     }
 
+    public void testBasicDeployWithPackagingAsBom() throws Exception {
+        File testPom = new File(getBasedir(), 
"target/test-classes/unit/basic-deploy-bom/plugin-config.xml");
+
+        mojo = (DeployMojo) lookupMojo("deploy", testPom);
+
+        MockitoAnnotations.initMocks(this);
+
+        assertNotNull(mojo);
+
+        ProjectBuildingRequest buildingRequest = 
mock(ProjectBuildingRequest.class);
+        when(session.getProjectBuildingRequest()).thenReturn(buildingRequest);
+        DefaultRepositorySystemSession repositorySession = new 
DefaultRepositorySystemSession();
+        repositorySession.setLocalRepositoryManager(
+                new SimpleLocalRepositoryManagerFactory(new 
DefaultLocalPathComposer())
+                        .newInstance(repositorySession, new 
LocalRepository(LOCAL_REPO)));
+        
when(buildingRequest.getRepositorySession()).thenReturn(repositorySession);
+        when(session.getRepositorySession()).thenReturn(repositorySession);
+
+        File pomFile = new File(
+                getBasedir(),
+                "target/test-classes/unit/basic-deploy-bom/target/" + 
"deploy-test-file-1.0-SNAPSHOT.pom");
+
+        assertTrue(pomFile.exists());
+
+        MavenProject project = (MavenProject) getVariableValueFromObject(mojo, 
"project");
+        project.setGroupId("org.apache.maven.test");
+        project.setArtifactId("maven-deploy-test");
+        project.setVersion("1.0-SNAPSHOT");
+
+        setVariableValueToObject(mojo, "pluginContext", new 
ConcurrentHashMap<>());
+        setVariableValueToObject(mojo, "reactorProjects", 
Collections.singletonList(project));
+
+        artifact = (DeployArtifactStub) project.getArtifact();
+
+        artifact.setArtifactHandlerExtension(project.getPackaging());
+
+        artifact.setFile(pomFile);
+
+        ArtifactRepositoryStub repo = getRepoStub(mojo);
+
+        repo.setAppendToUrl("basic-deploy-bom");
+
+        mojo.execute();
+
+        List<String> expectedFiles = new ArrayList<>();
+        List<String> fileList = new ArrayList<>();
+
+        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-bom");
+
+        File[] files = remoteRepo.listFiles();
+
+        for (File file : Objects.requireNonNull(files)) {
+            addFileToList(file, fileList);
+        }
+
+        assertEquals(expectedFiles.size(), fileList.size());
+
+        assertEquals(0, getSizeOfExpectedFiles(fileList, expectedFiles));
+    }
+
     public void testDeployIfArtifactFileIsNull() throws Exception {
         File testPom = new File(getBasedir(), 
"target/test-classes/unit/basic-deploy-test/plugin-config.xml");
 
@@ -413,8 +490,9 @@ public class DeployMojoTest extends AbstractMojoTestCase {
         ProjectBuildingRequest buildingRequest = 
mock(ProjectBuildingRequest.class);
         when(session.getProjectBuildingRequest()).thenReturn(buildingRequest);
         DefaultRepositorySystemSession repositorySession = new 
DefaultRepositorySystemSession();
-        repositorySession.setLocalRepositoryManager(new 
SimpleLocalRepositoryManagerFactory()
-                .newInstance(repositorySession, new 
LocalRepository(LOCAL_REPO)));
+        repositorySession.setLocalRepositoryManager(
+                new SimpleLocalRepositoryManagerFactory(new 
DefaultLocalPathComposer())
+                        .newInstance(repositorySession, new 
LocalRepository(LOCAL_REPO)));
         
when(buildingRequest.getRepositorySession()).thenReturn(repositorySession);
         when(session.getRepositorySession()).thenReturn(repositorySession);
 
@@ -490,70 +568,6 @@ public class DeployMojoTest extends AbstractMojoTestCase {
         assertEquals(0, getSizeOfExpectedFiles(fileList, expectedFiles));
     }
 
-    @Ignore("SCP is not part of Maven3 distribution. Aether handles transport 
extensions.")
-    public void _testBasicDeployWithScpAsProtocol() 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);
-
-        RepositorySystem repositorySystem = mock(RepositorySystem.class);
-
-        setVariableValueToObject(mojo, "repositorySystem", repositorySystem);
-
-        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");
-
-        setVariableValueToObject(mojo, "pluginContext", new 
ConcurrentHashMap<>());
-        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);
-    }
-
     public void testLegacyAltDeploymentRepositoryWithDefaultLayout() throws 
Exception {
         DeployMojo mojo = new DeployMojo();
 
diff --git a/src/it/MDEPLOY-178_deployfile-with-embedded-pom/verify.groovy 
b/src/test/java/org/apache/maven/plugins/deploy/stubs/DeployBomArtifactStub.java
similarity index 55%
copy from src/it/MDEPLOY-178_deployfile-with-embedded-pom/verify.groovy
copy to 
src/test/java/org/apache/maven/plugins/deploy/stubs/DeployBomArtifactStub.java
index 2b197b2..b5c55a3 100644
--- a/src/it/MDEPLOY-178_deployfile-with-embedded-pom/verify.groovy
+++ 
b/src/test/java/org/apache/maven/plugins/deploy/stubs/DeployBomArtifactStub.java
@@ -1,29 +1,37 @@
-/*
- * 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.
- */
-
-assert new File( basedir, 
"target/repo/org/apache/maven/plugins/deploy/its/mdeploy178/1.0/mdeploy178-1.0.jar"
 ).exists()
-File deployedPom = new File( basedir, 
"target/repo/org/apache/maven/plugins/deploy/its/mdeploy178/1.0/mdeploy178-1.0.pom"
 )
-assert deployedPom.exists()
-
-File buildLog = new File( basedir, 'build.log' )
-assert buildLog.exists()
-assert buildLog.text.contains( "[DEBUG] Using 
META-INF/maven/org.apache.maven.plugins.deploy.its/mdeploy178/pom.xml as 
pomFile" )
-
-def pomProject = new XmlSlurper().parse( deployedPom )
-assert "https://issues.apache.org/jira/browse/MDEPLOY-178".equals( 
pomProject.url.text() )
\ No newline at end of file
+/*
+ * 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.
+ */
+package org.apache.maven.plugins.deploy.stubs;
+
+import org.apache.maven.artifact.handler.ArtifactHandler;
+import org.apache.maven.artifact.handler.DefaultArtifactHandler;
+
+public class DeployBomArtifactStub extends DeployArtifactStub {
+    @Override
+    public String getType() {
+        return "bom";
+    }
+
+    public ArtifactHandler getArtifactHandler() {
+        return new DefaultArtifactHandler() {
+            public String getExtension() {
+                return "pom";
+            }
+        };
+    }
+}
diff --git a/src/it/MDEPLOY-178_deployfile-with-embedded-pom/verify.groovy 
b/src/test/java/org/apache/maven/plugins/deploy/stubs/DeployPomArtifactStub.java
similarity index 55%
copy from src/it/MDEPLOY-178_deployfile-with-embedded-pom/verify.groovy
copy to 
src/test/java/org/apache/maven/plugins/deploy/stubs/DeployPomArtifactStub.java
index 2b197b2..238bb28 100644
--- a/src/it/MDEPLOY-178_deployfile-with-embedded-pom/verify.groovy
+++ 
b/src/test/java/org/apache/maven/plugins/deploy/stubs/DeployPomArtifactStub.java
@@ -1,29 +1,37 @@
-/*
- * 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.
- */
-
-assert new File( basedir, 
"target/repo/org/apache/maven/plugins/deploy/its/mdeploy178/1.0/mdeploy178-1.0.jar"
 ).exists()
-File deployedPom = new File( basedir, 
"target/repo/org/apache/maven/plugins/deploy/its/mdeploy178/1.0/mdeploy178-1.0.pom"
 )
-assert deployedPom.exists()
-
-File buildLog = new File( basedir, 'build.log' )
-assert buildLog.exists()
-assert buildLog.text.contains( "[DEBUG] Using 
META-INF/maven/org.apache.maven.plugins.deploy.its/mdeploy178/pom.xml as 
pomFile" )
-
-def pomProject = new XmlSlurper().parse( deployedPom )
-assert "https://issues.apache.org/jira/browse/MDEPLOY-178".equals( 
pomProject.url.text() )
\ No newline at end of file
+/*
+ * 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.
+ */
+package org.apache.maven.plugins.deploy.stubs;
+
+import org.apache.maven.artifact.handler.ArtifactHandler;
+import org.apache.maven.artifact.handler.DefaultArtifactHandler;
+
+public class DeployPomArtifactStub extends DeployArtifactStub {
+    @Override
+    public String getType() {
+        return "pom";
+    }
+
+    public ArtifactHandler getArtifactHandler() {
+        return new DefaultArtifactHandler() {
+            public String getExtension() {
+                return "pom";
+            }
+        };
+    }
+}
diff --git a/src/test/resources/unit/basic-deploy-pom/plugin-config.xml 
b/src/test/resources/unit/basic-deploy-bom/plugin-config.xml
similarity index 93%
copy from src/test/resources/unit/basic-deploy-pom/plugin-config.xml
copy to src/test/resources/unit/basic-deploy-bom/plugin-config.xml
index 8cf373c..53bb886 100644
--- a/src/test/resources/unit/basic-deploy-pom/plugin-config.xml
+++ b/src/test/resources/unit/basic-deploy-bom/plugin-config.xml
@@ -24,9 +24,9 @@ under the License.
         <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" />
+            
<file>${basedir}/src/test/resources/unit/basic-deploy-bom/plugin-config.xml</file>
+            <packaging>bom</packaging>
+            <artifact 
implementation="org.apache.maven.plugins.deploy.stubs.DeployBomArtifactStub" />
             <attachedArtifacts />
             <deploymentRepository 
implementation="org.apache.maven.plugins.deploy.stubs.ArtifactRepositoryStub">
               <basedir>${basedir}</basedir>
diff --git a/src/test/resources/unit/basic-deploy-pom/plugin-config.xml 
b/src/test/resources/unit/basic-deploy-bom/target/deploy-test-file-1.0-SNAPSHOT.pom
similarity index 50%
copy from src/test/resources/unit/basic-deploy-pom/plugin-config.xml
copy to 
src/test/resources/unit/basic-deploy-bom/target/deploy-test-file-1.0-SNAPSHOT.pom
index 8cf373c..9c7bc40 100644
--- a/src/test/resources/unit/basic-deploy-pom/plugin-config.xml
+++ 
b/src/test/resources/unit/basic-deploy-bom/target/deploy-test-file-1.0-SNAPSHOT.pom
@@ -1,39 +1,28 @@
-<!--
-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>
+<!--
+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>
+
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.maven.test</groupId>
+  <artifactId>maven-deploy-file-test</artifactId>
+  <version>1.0</version>
+  <packaging>bom</packaging>
+  
+</project>
\ No newline at end of file
diff --git a/src/test/resources/unit/basic-deploy-pom/plugin-config.xml 
b/src/test/resources/unit/basic-deploy-pom/plugin-config.xml
index 8cf373c..27d5f25 100644
--- a/src/test/resources/unit/basic-deploy-pom/plugin-config.xml
+++ b/src/test/resources/unit/basic-deploy-pom/plugin-config.xml
@@ -26,7 +26,7 @@ under the License.
           <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" />
+            <artifact 
implementation="org.apache.maven.plugins.deploy.stubs.DeployPomArtifactStub" />
             <attachedArtifacts />
             <deploymentRepository 
implementation="org.apache.maven.plugins.deploy.stubs.ArtifactRepositoryStub">
               <basedir>${basedir}</basedir>


Reply via email to