This is an automated email from the ASF dual-hosted git repository.

cstamas pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-install-plugin.git


The following commit(s) were added to refs/heads/master by this push:
     new 0d0df35  [MINSTALL-189] Add parameter to lax project validation (#57)
0d0df35 is described below

commit 0d0df3560139841641da3ec6823730f797bd1862
Author: Tamas Cservenak <[email protected]>
AuthorDate: Tue Mar 21 15:23:22 2023 +0100

    [MINSTALL-189] Add parameter to lax project validation (#57)
    
    * [MINSTALL-189] Add parameter to lax project validation
    
    ---
    
    https://issues.apache.org/jira/browse/MINSTALL-189
    
    * Reformat
---
 .../apache/maven/plugins/install/InstallMojo.java  | 27 +++++++++++++++++++---
 1 file changed, 24 insertions(+), 3 deletions(-)

diff --git a/src/main/java/org/apache/maven/plugins/install/InstallMojo.java 
b/src/main/java/org/apache/maven/plugins/install/InstallMojo.java
index 3646de8..26bf4b0 100644
--- a/src/main/java/org/apache/maven/plugins/install/InstallMojo.java
+++ b/src/main/java/org/apache/maven/plugins/install/InstallMojo.java
@@ -82,6 +82,18 @@ public class InstallMojo extends AbstractMojo {
     @Parameter(property = "maven.install.skip", defaultValue = "false")
     private boolean skip;
 
+    /**
+     * Set this to <code>true</code> 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,
         INSTALLED,
@@ -193,11 +205,20 @@ public class InstallMojo extends AbstractMojo {
             if (isFile(mavenMainArtifact.getFile())) {
                 
request.addArtifact(RepositoryUtils.toArtifact(mavenMainArtifact));
             } else if (!project.getAttachedArtifacts().isEmpty()) {
-                throw new MojoExecutionException("The packaging plugin for 
this project did not assign "
-                        + "a main file to the project but it has attachments. 
Change packaging to 'pom'.");
+                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 MojoExecutionException("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 MojoExecutionException(
-                        "The packaging for this project did not assign " + "a 
file to the build artifact");
+                        "The packaging for this project did not assign a file 
to the build artifact");
             }
         }
 

Reply via email to