diff --git a/pom.xml b/pom.xml index 924a4a67..95bb0a19 100644 --- a/pom.xml +++ b/pom.xml @@ -90,7 +90,7 @@ under the License. ${surefire.version} 3.3.2 - 2023-02-06T12:43:51Z + 2023-03-21T14:38:01Z 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 1dfb9127..0b2c47ee 100644 --- a/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java +++ b/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java @@ -126,6 +126,18 @@ public class DeployMojo extends AbstractDeployMojo { @Parameter(property = "maven.deploy.skip", defaultValue = "false") private String skip = Boolean.FALSE.toString(); + /** + * Set this to true to allow incomplete project processing. By default, such projects are forbidden + * and Mojo will fail to process them. Incomplete project is a Maven Project that has any other packaging than + * "pom" and has no main artifact packaged. In the majority of cases, what user really wants here is a project + * with "pom" packaging and some classified artifact attached (typical example is some assembly being packaged + * and attached with classifier). + * + * @since 3.1.1 + */ + @Parameter(defaultValue = "false", property = "allowIncompleteProjects") + private boolean allowIncompleteProjects; + private enum State { SKIPPED, DEPLOYED, @@ -254,9 +266,23 @@ private ArtifactDeployerRequest createDeployerRequest() { artifactManager.setPath(pomArtifact, pomPath); deployables.add(pomArtifact); // main artifact - if (!isValidPath.test(artifact) && !attachedArtifacts.isEmpty()) { - 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'."); + if (!isValidPath.test(artifact)) { + if (!attachedArtifacts.isEmpty()) { + if (allowIncompleteProjects) { + getLog().warn(""); + getLog().warn("The packaging plugin for this project did not assign"); + getLog().warn("a main file to the project but it has attachments. Change packaging to 'pom'."); + getLog().warn(""); + getLog().warn("Incomplete projects like this will fail in future Maven versions!"); + getLog().warn(""); + } else { + 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'."); + } + } else { + throw new MojoException( + "The packaging for this project did not assign a file to the build artifact"); + } } deployables.add(artifact); } else {