Fix m-deploy-p ITs
diff --git a/pom.xml b/pom.xml
index 81a6d24..a58ad77 100644
--- a/pom.xml
+++ b/pom.xml
@@ -75,6 +75,12 @@
<scope>provided</scope>
</dependency>
<dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-model-builder</artifactId>
+ <version>${mavenVersion}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.5</version>
diff --git a/src/it/attach-jar-checksum-snapshot/verify.groovy b/src/it/attach-jar-checksum-snapshot/verify.groovy
index 0a4a14f..df5425b 100644
--- a/src/it/attach-jar-checksum-snapshot/verify.groovy
+++ b/src/it/attach-jar-checksum-snapshot/verify.groovy
@@ -67,7 +67,7 @@
def result = false
pathsInTargetDirectory.each { searchItem ->
def expected = existingFile ==~ searchItem
- println "existingFile: ${existingFile} ${searchItem} expeced:${expected}"
+ println "existingFile: ${existingFile} ${searchItem} expected:${expected}"
if (expected) {
result = true
}
diff --git a/src/it/deploy-at-end-pass/module1/pom.xml b/src/it/deploy-at-end-pass/module1/pom.xml
index 1a91fc5..03d6c0d 100644
--- a/src/it/deploy-at-end-pass/module1/pom.xml
+++ b/src/it/deploy-at-end-pass/module1/pom.xml
@@ -27,7 +27,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
- <version>1.2</version>
+ <version>3.0.0</version>
<executions>
<execution>
<id>enforce</id>
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 103f550..ea20d53 100644
--- a/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java
+++ b/src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java
@@ -55,8 +55,10 @@
import org.apache.maven.api.services.ProjectManager;
import org.apache.maven.model.Model;
import org.apache.maven.model.Parent;
+import org.apache.maven.model.building.ModelBuildingException;
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
+import org.apache.maven.shared.utils.Os;
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.ReaderFactory;
@@ -422,7 +424,7 @@
if ( !file.isFile() )
{
// try relative to the project basedir just in case
- file = new File( project.getPomPath().getParent().toFile(), files.substring( fi, nfi ) );
+ file = new File( project.getBasedir().toFile(), files.substring( fi, nfi ) );
}
if ( file.isFile() )
{
@@ -502,6 +504,13 @@
}
catch ( ProjectBuilderException e )
{
+ for ( Throwable c = e.getCause(); c != null; c = c.getCause() )
+ {
+ if ( c instanceof ModelBuildingException )
+ {
+ throw new MojoException( "The artifact information is not valid:" + Os.LINE_SEP + c.getMessage() );
+ }
+ }
throw new MojoException( "Unable to create the project.", e );
}
}
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 f0f7a51..d1f09b1 100644
--- a/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java
+++ b/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java
@@ -19,6 +19,7 @@
* under the License.
*/
+import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collections;
@@ -161,17 +162,25 @@
deployables.add( project.getArtifact() );
+ Path pomPath = project.getPomPath();
+
if ( !"pom".equals( project.getPackaging() ) )
{
Artifact pomArtifact = getSession().createArtifact(
project.getGroupId(), project.getArtifactId(), "",
project.getVersion(), "pom" );
- artifactManager.setPath( pomArtifact, project.getPomPath() );
+ if ( pomPath != null )
+ {
+ artifactManager.setPath( pomArtifact, pomPath );
+ }
deployables.add( pomArtifact );
}
else
{
- artifactManager.setPath( project.getArtifact(), project.getPomPath() );
+ if ( pomPath != null )
+ {
+ artifactManager.setPath( project.getArtifact(), pomPath );
+ }
}
ProjectManager projectManager = getSession().getService( ProjectManager.class );
@@ -180,10 +189,10 @@
for ( Artifact artifact : deployables )
{
Path path = artifactManager.getPath( artifact ).orElse( null );
- if ( path == null )
+ if ( path == null || !Files.isRegularFile( path ) )
{
- throw new MojoException( "The packaging for this project did not assign "
- + "a file to the build artifact" );
+ throw new MojoException( "The packaging plugin for this project did not assign "
+ + "a main file to the project but it has attachments. Change packaging to 'pom'." );
}
}
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 cdb4640..ff6e661 100644
--- a/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java
+++ b/src/test/java/org/apache/maven/plugins/deploy/DeployMojoTest.java
@@ -190,7 +190,7 @@
artifactManager.setPath( project.getArtifact(), file.toPath() );
projectManager.attachArtifact( project,
new ArtifactStub( "org.apache.maven.test", "attached-artifact-test", "", "1.0-SNAPSHOT", "jar" ),
- Paths.get( getBasedir(), "target/test-classes/unit/basic-deploy/attached-artifacts-test-1.0-SNAPSHOT.jar" ) );
+ Paths.get( getBasedir(), "target/test-classes/unit/basic-deploy/attached-artifact-test-1.0-SNAPSHOT.jar" ) );
ArtifactDeployerRequest request = execute( mojo );
diff --git a/src/test/resources/unit/basic-deploy/plugin-config.xml b/src/test/resources/unit/basic-deploy/plugin-config.xml
index cafe9b2..66bf199 100644
--- a/src/test/resources/unit/basic-deploy/plugin-config.xml
+++ b/src/test/resources/unit/basic-deploy/plugin-config.xml
Binary files differ