Author: gboue
Date: Sun Aug  7 14:14:46 2016
New Revision: 1755441

URL: http://svn.apache.org/viewvc?rev=1755441&view=rev
Log:
[MDEPLOY-212] deploy-file incorrectly deploys attached artifacts
[MDEPLOY-213] deploy-file replaces main artifact of a project

The deploy-file Mojo now creates a new MavenProject and attaches to this 
project all artifacts to deploy. This also fixes the use of deprecated code 
from ArtifactFactory.

Added:
    maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-pom-with-extras/
    
maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-pom-with-extras/invoker.properties
   (with props)
    
maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-pom-with-extras/pom.xml
   (with props)
    
maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-pom-with-extras/test-0.1-src.tar.gz
   (with props)
    
maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-pom-with-extras/test-0.1.pom
   (with props)
    
maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-pom-with-extras/test-0.1.tar.gz
   (with props)
    
maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-pom-with-extras/test-0.1.zip
   (with props)
    
maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-pom-with-extras/test.properties
   (with props)
    
maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-pom-with-extras/verify.bsh
   (with props)
    maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-212/
    
maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-212/invoker.properties   
(with props)
    maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-212/pom.xml   (with 
props)
    maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-212/src/
    maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-212/src/main/
    maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-212/src/main/java/
    
maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-212/src/main/java/org/
    
maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-212/src/main/java/org/apache/
    
maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-212/src/main/java/org/apache/maven/
    
maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-212/src/main/java/org/apache/maven/test/
    
maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-212/src/main/java/org/apache/maven/test/HelloWorld.java
   (with props)
    maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-212/test-1.0.tar.gz  
 (with props)
    maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-212/test-1.0.zip   
(with props)
    maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-212/verify.bsh   
(with props)
    maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-213/
    
maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-213/invoker.properties   
(with props)
    maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-213/pom.xml   (with 
props)
    maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-213/src/
    maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-213/src/main/
    maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-213/src/main/java/
    
maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-213/src/main/java/org/
    
maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-213/src/main/java/org/apache/
    
maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-213/src/main/java/org/apache/maven/
    
maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-213/src/main/java/org/apache/maven/test/
    
maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-213/src/main/java/org/apache/maven/test/HelloWorld.java
   (with props)
    maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-213/test-1.0.tar.gz  
 (with props)
    maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-213/test-1.0.zip   
(with props)
    maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-213/verify.bsh   
(with props)
Modified:
    
maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java
    
maven/plugins/trunk/maven-deploy-plugin/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoTest.java

Added: 
maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-pom-with-extras/invoker.properties
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-pom-with-extras/invoker.properties?rev=1755441&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-pom-with-extras/invoker.properties
 (added)
+++ 
maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-pom-with-extras/invoker.properties
 Sun Aug  7 14:14:46 2016
@@ -0,0 +1,18 @@
+# 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.
+
+invoker.goals = 
org.apache.maven.plugins:maven-deploy-plugin:${project.version}:deploy-file

Propchange: 
maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-pom-with-extras/invoker.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-pom-with-extras/invoker.properties
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: 
maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-pom-with-extras/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-pom-with-extras/pom.xml?rev=1755441&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-pom-with-extras/pom.xml
 (added)
+++ 
maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-pom-with-extras/pom.xml
 Sun Aug  7 14:14:46 2016
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+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 xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.its.deploy.tppwoc</groupId>
+  <artifactId>test</artifactId>
+  <version>1.0</version>
+  <packaging>jar</packaging>
+
+  <description>
+    Tests the manual deployment of a simple POM along with extra files.
+  </description>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-deploy-plugin</artifactId>
+        <version>@project.version@</version>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>

Propchange: 
maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-pom-with-extras/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-pom-with-extras/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: 
maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-pom-with-extras/test-0.1-src.tar.gz
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-pom-with-extras/test-0.1-src.tar.gz?rev=1755441&view=auto
==============================================================================
Binary file - no diff available.

Propchange: 
maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-pom-with-extras/test-0.1-src.tar.gz
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: 
maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-pom-with-extras/test-0.1.pom
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-pom-with-extras/test-0.1.pom?rev=1755441&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-pom-with-extras/test-0.1.pom
 (added)
+++ 
maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-pom-with-extras/test-0.1.pom
 Sun Aug  7 14:14:46 2016
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+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 xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.maven.its.deploy.tppwoc</groupId>
+  <artifactId>test</artifactId>
+  <version>1.0</version>
+  <packaging>pom</packaging>
+</project>
\ No newline at end of file

Propchange: 
maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-pom-with-extras/test-0.1.pom
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-pom-with-extras/test-0.1.pom
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: 
maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-pom-with-extras/test-0.1.tar.gz
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-pom-with-extras/test-0.1.tar.gz?rev=1755441&view=auto
==============================================================================
Binary file - no diff available.

Propchange: 
maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-pom-with-extras/test-0.1.tar.gz
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: 
maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-pom-with-extras/test-0.1.zip
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-pom-with-extras/test-0.1.zip?rev=1755441&view=auto
==============================================================================
Binary file - no diff available.

Propchange: 
maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-pom-with-extras/test-0.1.zip
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: 
maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-pom-with-extras/test.properties
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-pom-with-extras/test.properties?rev=1755441&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-pom-with-extras/test.properties
 (added)
+++ 
maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-pom-with-extras/test.properties
 Sun Aug  7 14:14:46 2016
@@ -0,0 +1,27 @@
+# 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.
+
+file = test-0.1.pom
+url = file:target/repo
+updateReleaseInfo = true
+groupId = org.apache.maven.its.deploy.tppwoc
+artifactId = test
+version = 1.0
+packaging = pom
+files = test-0.1.zip,test-0.1-src.tar.gz,test-0.1.tar.gz
+types = zip,tar.gz,tar.gz
+classifiers = ,src,

Propchange: 
maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-pom-with-extras/test.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-pom-with-extras/test.properties
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: 
maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-pom-with-extras/verify.bsh
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-pom-with-extras/verify.bsh?rev=1755441&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-pom-with-extras/verify.bsh
 (added)
+++ 
maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-pom-with-extras/verify.bsh
 Sun Aug  7 14:14:46 2016
@@ -0,0 +1,57 @@
+/*
+ * 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.*;
+import java.util.*;
+
+String[] paths =
+{
+    "org/apache/maven/its/deploy/tppwoc/test/maven-metadata.xml",
+    "org/apache/maven/its/deploy/tppwoc/test/1.0/test-1.0.pom",
+    "org/apache/maven/its/deploy/tppwoc/test/1.0/test-1.0.zip",
+    "org/apache/maven/its/deploy/tppwoc/test/1.0/test-1.0-src.tar.gz",
+    "org/apache/maven/its/deploy/tppwoc/test/1.0/test-1.0.tar.gz",
+};
+
+for ( String path : paths )
+{
+    File file = new File( new File( basedir, "target/repo" ), path );
+    System.out.println( "Checking for existence of " + file );
+    if ( !file.isFile() )
+    {
+        throw new FileNotFoundException( "Missing: " + file.getAbsolutePath() 
);
+    }
+}
+
+String[] missing =
+{
+    "org/apache/maven/its/deploy/tppwoc/test/1.0/test-1.0.jar",
+};
+
+for ( String path : missing )
+{
+    File file = new File( new File( basedir, "target/repo" ), path );
+    System.out.println( "Checking for absence of " + file );
+    if ( file.exists() )
+    {
+        throw new FileNotFoundException( "Existent: " + file.getAbsolutePath() 
);
+    }
+}
+
+return true;

Propchange: 
maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-pom-with-extras/verify.bsh
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/trunk/maven-deploy-plugin/src/it/3rd-party-pom-with-extras/verify.bsh
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: 
maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-212/invoker.properties
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-212/invoker.properties?rev=1755441&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-212/invoker.properties 
(added)
+++ 
maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-212/invoker.properties 
Sun Aug  7 14:14:46 2016
@@ -0,0 +1,18 @@
+# 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.
+
+invoker.goals = clean package

Propchange: 
maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-212/invoker.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-212/invoker.properties
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-212/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-212/pom.xml?rev=1755441&view=auto
==============================================================================
--- maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-212/pom.xml (added)
+++ maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-212/pom.xml Sun Aug  
7 14:14:46 2016
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+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 xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.its.mdeploy-212</groupId>
+  <artifactId>test</artifactId>
+  <version>1.0</version>
+  <packaging>jar</packaging>
+
+  <description>
+    Tests that deploy-file only deploys the configured files when run in an 
existing project with attached artifacts
+  </description>
+  
+  <url>https://issues.apache.org/jira/browse/MDEPLOY-212</url>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-javadoc-plugin</artifactId>
+        <version>2.7</version>
+        <executions>
+          <execution>
+            <id>attach-javadoc</id>
+            <goals>
+              <goal>jar</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-deploy-plugin</artifactId>
+        <version>@project.version@</version>
+        <executions>
+          <execution>
+            <id>test-deploy</id>
+            <goals>
+              <goal>deploy-file</goal>
+            </goals>
+            <phase>package</phase>
+            <configuration>
+              <groupId>org.apache.maven.its.mdeploy-212</groupId>
+              <artifactId>test</artifactId>
+              <version>1.0</version>
+              <file>test-1.0.tar.gz</file>
+              <packaging>tar.gz</packaging>
+              <url>file://${basedir}/target/repo</url>
+              <files>test-1.0.zip</files>
+              <types>zip</types>
+              <classifiers>it</classifiers>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>

Propchange: maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-212/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-212/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: 
maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-212/src/main/java/org/apache/maven/test/HelloWorld.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-212/src/main/java/org/apache/maven/test/HelloWorld.java?rev=1755441&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-212/src/main/java/org/apache/maven/test/HelloWorld.java
 (added)
+++ 
maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-212/src/main/java/org/apache/maven/test/HelloWorld.java
 Sun Aug  7 14:14:46 2016
@@ -0,0 +1,37 @@
+package org.apache.maven.test;
+
+/*
+ * 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.
+ */
+
+/**
+ * Hello World class
+ */
+public class HelloWorld
+{
+
+    /**
+     * Main method
+     * @param args Arguments
+     */
+    public static void main( String[] args )
+    {
+        System.out.println( "Hello world" );
+    }
+
+}

Propchange: 
maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-212/src/main/java/org/apache/maven/test/HelloWorld.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-212/src/main/java/org/apache/maven/test/HelloWorld.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: 
maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-212/test-1.0.tar.gz
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-212/test-1.0.tar.gz?rev=1755441&view=auto
==============================================================================
Binary file - no diff available.

Propchange: 
maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-212/test-1.0.tar.gz
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-212/test-1.0.zip
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-212/test-1.0.zip?rev=1755441&view=auto
==============================================================================
Binary file - no diff available.

Propchange: 
maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-212/test-1.0.zip
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-212/verify.bsh
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-212/verify.bsh?rev=1755441&view=auto
==============================================================================
--- maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-212/verify.bsh 
(added)
+++ maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-212/verify.bsh Sun 
Aug  7 14:14:46 2016
@@ -0,0 +1,56 @@
+/*
+ * 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.*;
+import java.util.*;
+
+String[] paths =
+{
+    "org/apache/maven/its/mdeploy-212/test/1.0/test-1.0.pom",
+    "org/apache/maven/its/mdeploy-212/test/1.0/test-1.0.tar.gz",
+    "org/apache/maven/its/mdeploy-212/test/1.0/test-1.0-it.zip",
+};
+
+for ( String path : paths )
+{
+    File file = new File( new File( basedir, "target/repo" ), path );
+    System.out.println( "Checking for existence of " + file );
+    if ( !file.isFile() )
+    {
+        throw new FileNotFoundException( "Missing: " + file.getAbsolutePath() 
);
+    }
+}
+
+String[] missing =
+{
+    "org/apache/maven/its/mdeploy-212/test/1.0/test-1.0.jar",
+    "org/apache/maven/its/mdeploy-212/test/1.0/test-1.0-javadoc.jar",
+};
+
+for ( String path : missing )
+{
+    File file = new File( new File( basedir, "target/repo" ), path );
+    System.out.println( "Checking for absence of " + file );
+    if ( file.exists() )
+    {
+        throw new FileNotFoundException( "Existent: " + file.getAbsolutePath() 
);
+    }
+}
+
+return true;

Propchange: 
maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-212/verify.bsh
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-212/verify.bsh
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: 
maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-213/invoker.properties
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-213/invoker.properties?rev=1755441&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-213/invoker.properties 
(added)
+++ 
maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-213/invoker.properties 
Sun Aug  7 14:14:46 2016
@@ -0,0 +1,18 @@
+# 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.
+
+invoker.goals = clean package deploy

Propchange: 
maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-213/invoker.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-213/invoker.properties
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-213/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-213/pom.xml?rev=1755441&view=auto
==============================================================================
--- maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-213/pom.xml (added)
+++ maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-213/pom.xml Sun Aug  
7 14:14:46 2016
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+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 xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.its.mdeploy-213</groupId>
+  <artifactId>test</artifactId>
+  <version>1.0</version>
+  <packaging>jar</packaging>
+
+  <description>
+    Tests that deploy-file does not change the main artifact of the project 
being built
+  </description>
+  
+  <url>https://issues.apache.org/jira/browse/MDEPLOY-213</url>
+  
+  <distributionManagement>
+    <repository>
+      <id>it</id>
+      <url>file://${basedir}/target/repo</url>
+      <uniqueVersion>false</uniqueVersion>
+    </repository>
+  </distributionManagement>
+  
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-javadoc-plugin</artifactId>
+        <version>2.7</version>
+        <executions>
+          <execution>
+            <id>attach-javadoc</id>
+            <goals>
+              <goal>jar</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-deploy-plugin</artifactId>
+        <version>@project.version@</version>
+        <executions>
+          <execution>
+            <id>test-deploy</id>
+            <goals>
+              <goal>deploy-file</goal>
+            </goals>
+            <phase>package</phase>
+            <configuration>
+              <groupId>org.apache.maven.its.mdeploy-213</groupId>
+              <artifactId>test</artifactId>
+              <version>1.0</version>
+              <file>test-1.0.tar.gz</file>
+              <packaging>tar.gz</packaging>
+              <url>file://${basedir}/target/repo</url>
+              <files>test-1.0.zip</files>
+              <types>zip</types>
+              <classifiers>it</classifiers>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>

Propchange: maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-213/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-213/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: 
maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-213/src/main/java/org/apache/maven/test/HelloWorld.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-213/src/main/java/org/apache/maven/test/HelloWorld.java?rev=1755441&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-213/src/main/java/org/apache/maven/test/HelloWorld.java
 (added)
+++ 
maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-213/src/main/java/org/apache/maven/test/HelloWorld.java
 Sun Aug  7 14:14:46 2016
@@ -0,0 +1,37 @@
+package org.apache.maven.test;
+
+/*
+ * 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.
+ */
+
+/**
+ * Hello World class
+ */
+public class HelloWorld
+{
+
+    /**
+     * Main method
+     * @param args Arguments
+     */
+    public static void main( String[] args )
+    {
+        System.out.println( "Hello world" );
+    }
+
+}

Propchange: 
maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-213/src/main/java/org/apache/maven/test/HelloWorld.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-213/src/main/java/org/apache/maven/test/HelloWorld.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: 
maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-213/test-1.0.tar.gz
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-213/test-1.0.tar.gz?rev=1755441&view=auto
==============================================================================
Binary file - no diff available.

Propchange: 
maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-213/test-1.0.tar.gz
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-213/test-1.0.zip
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-213/test-1.0.zip?rev=1755441&view=auto
==============================================================================
Binary file - no diff available.

Propchange: 
maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-213/test-1.0.zip
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-213/verify.bsh
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-213/verify.bsh?rev=1755441&view=auto
==============================================================================
--- maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-213/verify.bsh 
(added)
+++ maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-213/verify.bsh Sun 
Aug  7 14:14:46 2016
@@ -0,0 +1,42 @@
+/*
+ * 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.*;
+import java.util.*;
+
+String[] paths =
+{
+    "org/apache/maven/its/mdeploy-213/test/1.0/test-1.0.pom",
+    "org/apache/maven/its/mdeploy-213/test/1.0/test-1.0.tar.gz",
+    "org/apache/maven/its/mdeploy-213/test/1.0/test-1.0-it.zip",
+    "org/apache/maven/its/mdeploy-213/test/1.0/test-1.0.jar",
+    "org/apache/maven/its/mdeploy-213/test/1.0/test-1.0-javadoc.jar",
+};
+
+for ( String path : paths )
+{
+    File file = new File( new File( basedir, "target/repo" ), path );
+    System.out.println( "Checking for existence of " + file );
+    if ( !file.isFile() )
+    {
+        throw new FileNotFoundException( "Missing: " + file.getAbsolutePath() 
);
+    }
+}
+
+return true;

Propchange: 
maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-213/verify.bsh
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/plugins/trunk/maven-deploy-plugin/src/it/MDEPLOY-213/verify.bsh
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: 
maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java?rev=1755441&r1=1755440&r2=1755441&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java
 (original)
+++ 
maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java
 Sun Aug  7 14:14:46 2016
@@ -44,6 +44,8 @@ import org.apache.maven.model.building.D
 import org.apache.maven.model.building.ModelBuildingRequest;
 import org.apache.maven.model.building.ModelProblem.Severity;
 import org.apache.maven.model.building.ModelProblemCollector;
+import org.apache.maven.model.building.ModelSource;
+import org.apache.maven.model.building.StringModelSource;
 import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
 import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
 import org.apache.maven.model.validation.ModelValidator;
@@ -52,10 +54,13 @@ import org.apache.maven.plugin.MojoFailu
 import org.apache.maven.plugins.annotations.Component;
 import org.apache.maven.plugins.annotations.Mojo;
 import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.project.DefaultProjectBuildingRequest;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.project.MavenProjectHelper;
-import org.apache.maven.project.ProjectBuildingHelper;
+import org.apache.maven.project.ProjectBuilder;
+import org.apache.maven.project.ProjectBuildingException;
 import org.apache.maven.project.artifact.ProjectArtifactMetadata;
+import org.apache.maven.shared.artifact.DefaultArtifactCoordinate;
 import org.apache.maven.shared.artifact.deploy.ArtifactDeployerException;
 import org.apache.maven.shared.repository.RepositoryManager;
 import org.codehaus.plexus.util.FileUtils;
@@ -74,17 +79,18 @@ import org.codehaus.plexus.util.xml.pull
 public class DeployFileMojo
     extends AbstractDeployMojo
 {
-    /**
-     * The default Maven project created when building the plugin
-     */
-    @Parameter( defaultValue = "${project}", readonly = true, required = true )
-    private MavenProject project;
 
     /**
-     * Used for attaching the source and javadoc jars to the project.
+     * Used for attaching the artifacts to deploy to the project.
      */
     @Component
     private MavenProjectHelper projectHelper;
+    
+    /**
+     * 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.
@@ -216,9 +222,6 @@ public class DeployFileMojo
     @Component
     private RepositoryManager repoManager;
     
-    @Component
-    private ProjectBuildingHelper projectBuildingHelper;
-    
     void initProperties()
         throws MojoExecutionException
     {
@@ -341,27 +344,46 @@ public class DeployFileMojo
             throw new MojoExecutionException( "No transfer protocol found." );
         }
 
-        // Create the artifact
-        Artifact artifact =
-            artifactFactory.createArtifactWithClassifier( groupId, artifactId, 
version, packaging, classifier );
-
-        if ( file.equals( getLocalRepoFile( artifact ) ) )
+        if ( file.equals( getLocalRepoFile() ) )
         {
             throw new MojoFailureException( "Cannot deploy artifact from the 
local repository: " + file );
         }
 
+        MavenProject project = createMavenProject();
+        Artifact artifact = project.getArtifact();
+
+        List<Artifact> deployableArtifacts = new ArrayList<Artifact>();
+
+        if ( classifier == null )
+        {
+            artifact.setFile( file );
+            deployableArtifacts.add( artifact );
+        }
+        else
+        {
+            projectHelper.attachArtifact( project, packaging, classifier, file 
);
+        }
+
         // Upload the POM if requested, generating one if need be
         if ( !"pom".equals( packaging ) )
         {
-            if ( pomFile != null )
+            File pom = pomFile;
+            if ( pom == null && generatePom )
             {
-                ProjectArtifactMetadata metadata = new 
ProjectArtifactMetadata( artifact, pomFile );
-                artifact.addMetadata( metadata );
+                pom = generatePomFile();
             }
-            else if ( generatePom )
+            if ( pom != null )
             {
-                ProjectArtifactMetadata metadata = new 
ProjectArtifactMetadata( artifact, generatePomFile() );
-                artifact.addMetadata( metadata );
+                if ( classifier == null )
+                {
+                    ProjectArtifactMetadata metadata = new 
ProjectArtifactMetadata( artifact, pom );
+                    artifact.addMetadata( metadata );
+                }
+                else
+                {
+                    artifact.setFile( pom );
+                    deployableArtifacts.add( artifact );
+                }
             }
         }
 
@@ -369,35 +391,16 @@ public class DeployFileMojo
         {
             artifact.setRelease( true );
         }
-
-        project.setArtifact( artifact );
-
-        artifact.setFile( file );
-        
         artifact.setRepository( deploymentRepository );
-        
-        List<Artifact> deployableArtifacts = new ArrayList<Artifact>(); 
-        
-        deployableArtifacts.add( artifact );
 
         if ( sources != null )
         {
-            Artifact sourcesArtifact =
-                artifactFactory.createArtifactWithClassifier( groupId, 
artifactId, version, "jar", "sources" );
-
-            sourcesArtifact.setFile( sources );
-
-            deployableArtifacts.add( sourcesArtifact );
+            projectHelper.attachArtifact( project, "jar", "sources", sources );
         }
 
         if ( javadoc != null )
         {
-            Artifact javadocArtifact =
-                artifactFactory.createArtifactWithClassifier( groupId, 
artifactId, version, "jar", "javadoc" );
-
-            javadocArtifact.setFile( javadoc );
-
-            deployableArtifacts.add( javadocArtifact );
+            projectHelper.attachArtifact( project, "jar", "javadoc", javadoc );
         }
 
         if ( files != null )
@@ -498,17 +501,54 @@ public class DeployFileMojo
             throw new MojoExecutionException( e.getMessage(), e );
         }
     }
-
+    
+    /**
+     * Creates a Maven project in-memory from the user-supplied groupId, 
artifactId and version.
+     * When a classifier is supplied, the packaging must be POM because the 
project with only have attachments.
+     * This project serves as basis to attach the artifacts to deploy to.
+     * 
+     * @return The created Maven project, never <code>null</code>.
+     * @throws MojoFailureException When building the project failed.
+     */
+    private MavenProject createMavenProject()
+        throws MojoFailureException
+    {
+        ModelSource modelSource = new StringModelSource( 
+                "<project>"
+              +   "<modelVersion>4.0.0</modelVersion>"
+              +   "<groupId>" + groupId + "</groupId>"
+              +   "<artifactId>" + artifactId + "</artifactId>"
+              +   "<version>" + version + "</version>"
+              +   "<packaging>" + ( classifier == null ? packaging : "pom" ) + 
"</packaging>"
+              + "</project>" );
+        DefaultProjectBuildingRequest buildingRequest =
+            new DefaultProjectBuildingRequest( 
getSession().getProjectBuildingRequest() );
+        buildingRequest.setProcessPlugins( false );
+        try
+        {
+            return projectBuilder.build( modelSource, buildingRequest 
).getProject();
+        }
+        catch ( ProjectBuildingException e )
+        {
+            throw new MojoFailureException( e.getMessage(), e );
+        }
+    }
+    
     /**
-     * Gets the path of the specified artifact within the local repository. 
Note that the returned path need not exist
-     * (yet).
+     * Gets the path of the artifact constructed from the supplied groupId, 
artifactId, version, classifier
+     * and packaging within the local repository. Note that the returned path 
need not exist (yet).
      * 
-     * @param artifact The artifact whose local repo path should be 
determined, must not be <code>null</code>.
      * @return The absolute path to the artifact when installed, never 
<code>null</code>.
      */
-    private File getLocalRepoFile( Artifact artifact )
+    private File getLocalRepoFile()
     {
-        String path = repoManager.getPathForLocalArtifact( 
getSession().getProjectBuildingRequest(), artifact );
+        DefaultArtifactCoordinate coordinate = new DefaultArtifactCoordinate();
+        coordinate.setGroupId( groupId );
+        coordinate.setArtifactId( artifactId );
+        coordinate.setVersion( version );
+        coordinate.setClassifier( classifier );
+        coordinate.setExtension( packaging );
+        String path = repoManager.getPathForLocalArtifact( 
getSession().getProjectBuildingRequest(), coordinate );
         return new File( repoManager.getLocalRepositoryBasedir( 
getSession().getProjectBuildingRequest() ), path );
     }
 

Modified: 
maven/plugins/trunk/maven-deploy-plugin/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoTest.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-deploy-plugin/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoTest.java?rev=1755441&r1=1755440&r2=1755441&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-deploy-plugin/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoTest.java
 (original)
+++ 
maven/plugins/trunk/maven-deploy-plugin/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoTest.java
 Sun Aug  7 14:14:46 2016
@@ -26,12 +26,10 @@ import java.io.File;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.maven.artifact.Artifact;
 import org.apache.maven.execution.MavenSession;
 import org.apache.maven.model.Model;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.testing.AbstractMojoTestCase;
-import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
 import org.apache.maven.project.ProjectBuildingRequest;
 import org.apache.maven.repository.internal.MavenRepositorySystemSession;
 import org.mockito.InjectMocks;
@@ -53,8 +51,6 @@ public class DeployFileMojoTest
 
     private File remoteRepo;
 
-    MavenProjectStub projectStub = new MavenProjectStub();
-    
     @Mock
     private MavenSession session;
     
@@ -72,8 +68,6 @@ public class DeployFileMojoTest
         {
             remoteRepo.mkdirs();
         }
-        
-        projectStub.setAttachedArtifacts( new ArrayList<Artifact>() );
     }
 
     public void testDeployTestEnvironment()
@@ -103,8 +97,6 @@ public class DeployFileMojoTest
         repositorySession.setLocalRepositoryManager( new 
SimpleLocalRepositoryManager( LOCAL_REPO ) );
         when( buildingRequest.getRepositorySession() ).thenReturn( 
repositorySession );
         
-        setVariableValueToObject( mojo, "project", projectStub );
-
         String groupId = (String) getVariableValueFromObject( mojo, "groupId" 
);
 
         String artifactId = (String) getVariableValueFromObject( mojo, 
"artifactId" );
@@ -206,8 +198,6 @@ public class DeployFileMojoTest
         repositorySession.setLocalRepositoryManager( new 
SimpleLocalRepositoryManager( LOCAL_REPO ) );
         when( buildingRequest.getRepositorySession() ).thenReturn( 
repositorySession );
 
-        setVariableValueToObject( mojo, "project", projectStub );
-
         String classifier = ( String ) getVariableValueFromObject( mojo, 
"classifier" );
 
         String groupId = ( String ) getVariableValueFromObject( mojo, 
"groupId" );
@@ -256,8 +246,6 @@ public class DeployFileMojoTest
         repositorySession.setLocalRepositoryManager( new 
SimpleLocalRepositoryManager( LOCAL_REPO ) );
         when( buildingRequest.getRepositorySession() ).thenReturn( 
repositorySession );
 
-        setVariableValueToObject( mojo, "project", projectStub );
-
         String groupId = (String) getVariableValueFromObject( mojo, "groupId" 
);
 
         String artifactId = (String) getVariableValueFromObject( mojo, 
"artifactId" );
@@ -288,8 +276,6 @@ public class DeployFileMojoTest
 
         assertNotNull( mojo );
 
-        setVariableValueToObject( mojo, "project", projectStub );
-
         String repositoryLayout = (String) getVariableValueFromObject(  mojo, 
"repositoryLayout" );
 
         assertEquals( "legacy", repositoryLayout );


Reply via email to