@@ -82,6 +82,18 @@ public class InstallMojo extends AbstractMojo {
82
82
@ Parameter (property = "maven.install.skip" , defaultValue = "false" )
83
83
private boolean skip ;
84
84
85
+ /**
86
+ * Set this to <code>true</code> to allow incomplete project processing. By default, such projects are forbidden
87
+ * and Mojo will fail to process them. Incomplete project is a Maven Project that has any other packaging than
88
+ * "pom" and has no main artifact packaged. In the majority of cases, what user really wants here is a project
89
+ * with "pom" packaging and some classified artifact attached (typical example is some assembly being packaged
90
+ * and attached with classifier).
91
+ *
92
+ * @since 3.1.1
93
+ */
94
+ @ Parameter (defaultValue = "false" , property = "allowIncompleteProjects" )
95
+ private boolean allowIncompleteProjects ;
96
+
85
97
private enum State {
86
98
SKIPPED ,
87
99
INSTALLED ,
@@ -193,11 +205,20 @@ private void processProject(MavenProject project, InstallRequest request) throws
193
205
if (isFile (mavenMainArtifact .getFile ())) {
194
206
request .addArtifact (RepositoryUtils .toArtifact (mavenMainArtifact ));
195
207
} else if (!project .getAttachedArtifacts ().isEmpty ()) {
196
- throw new MojoExecutionException ("The packaging plugin for this project did not assign "
197
- + "a main file to the project but it has attachments. Change packaging to 'pom'." );
208
+ if (allowIncompleteProjects ) {
209
+ getLog ().warn ("" );
210
+ getLog ().warn ("The packaging plugin for this project did not assign" );
211
+ getLog ().warn ("a main file to the project but it has attachments. Change packaging to 'pom'." );
212
+ getLog ().warn ("" );
213
+ getLog ().warn ("Incomplete projects like this will fail in future Maven versions!" );
214
+ getLog ().warn ("" );
215
+ } else {
216
+ throw new MojoExecutionException ("The packaging plugin for this project did not assign "
217
+ + "a main file to the project but it has attachments. Change packaging to 'pom'." );
218
+ }
198
219
} else {
199
220
throw new MojoExecutionException (
200
- "The packaging for this project did not assign " + " a file to the build artifact" );
221
+ "The packaging for this project did not assign a file to the build artifact" );
201
222
}
202
223
}
203
224
0 commit comments