@@ -126,6 +126,18 @@ public class DeployMojo extends AbstractDeployMojo {
126
126
@ Parameter (property = "maven.deploy.skip" , defaultValue = "false" )
127
127
private String skip = Boolean .FALSE .toString ();
128
128
129
+ /**
130
+ * Set this to <code>true</code> to allow incomplete project processing. By default, such projects are forbidden
131
+ * and Mojo will fail to process them. Incomplete project is a Maven Project that has any other packaging than
132
+ * "pom" and has no main artifact packaged. In the majority of cases, what user really wants here is a project
133
+ * with "pom" packaging and some classified artifact attached (typical example is some assembly being packaged
134
+ * and attached with classifier).
135
+ *
136
+ * @since 3.1.1
137
+ */
138
+ @ Parameter (defaultValue = "false" , property = "allowIncompleteProjects" )
139
+ private boolean allowIncompleteProjects ;
140
+
129
141
private enum State {
130
142
SKIPPED ,
131
143
DEPLOYED ,
@@ -254,9 +266,23 @@ private ArtifactDeployerRequest createDeployerRequest() {
254
266
artifactManager .setPath (pomArtifact , pomPath );
255
267
deployables .add (pomArtifact );
256
268
// main artifact
257
- if (!isValidPath .test (artifact ) && !attachedArtifacts .isEmpty ()) {
258
- throw new MojoException ("The packaging plugin for this project did not assign "
259
- + "a main file to the project but it has attachments. Change packaging to 'pom'." );
269
+ if (!isValidPath .test (artifact )) {
270
+ if (!attachedArtifacts .isEmpty ()) {
271
+ if (allowIncompleteProjects ) {
272
+ getLog ().warn ("" );
273
+ getLog ().warn ("The packaging plugin for this project did not assign" );
274
+ getLog ().warn ("a main file to the project but it has attachments. Change packaging to 'pom'." );
275
+ getLog ().warn ("" );
276
+ getLog ().warn ("Incomplete projects like this will fail in future Maven versions!" );
277
+ getLog ().warn ("" );
278
+ } else {
279
+ throw new MojoExecutionException ("The packaging plugin for this project did not assign "
280
+ + "a main file to the project but it has attachments. Change packaging to 'pom'." );
281
+ }
282
+ } else {
283
+ throw new MojoExecutionException (
284
+ "The packaging for this project did not assign a file to the build artifact" );
285
+ }
260
286
}
261
287
deployables .add (artifact );
262
288
} else {
0 commit comments