@@ -82,6 +82,18 @@ public class InstallMojo extends AbstractMojo {
8282 @ Parameter (property = "maven.install.skip" , defaultValue = "false" )
8383 private boolean skip ;
8484
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+
8597 private enum State {
8698 SKIPPED ,
8799 INSTALLED ,
@@ -193,11 +205,20 @@ private void processProject(MavenProject project, InstallRequest request) throws
193205 if (isFile (mavenMainArtifact .getFile ())) {
194206 request .addArtifact (RepositoryUtils .toArtifact (mavenMainArtifact ));
195207 } 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+ }
198219 } else {
199220 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" );
201222 }
202223 }
203224
0 commit comments