Skip to content

Commit

Permalink
Merge branch 'master' into m-api
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet authored Mar 24, 2023
2 parents 7c591ad + 23943e0 commit 82831f3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
<mavenSourcePluginVersion>3.2.1</mavenSourcePluginVersion>
<mavenSurefirePluginVersion>3.0.0-M7</mavenSurefirePluginVersion>

<project.build.outputTimestamp>2022-11-13T22:12:20Z</project.build.outputTimestamp>
<project.build.outputTimestamp>2023-03-21T14:31:18Z</project.build.outputTimestamp>
</properties>

<dependencies>
Expand Down
32 changes: 29 additions & 3 deletions src/main/java/org/apache/maven/plugins/install/InstallMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,18 @@ public class InstallMojo implements org.apache.maven.api.plugin.Mojo {
@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(property = "allowIncompleteProjects", defaultValue = "false")
private boolean allowIncompleteProjects;

private enum State {
SKIPPED,
INSTALLED,
Expand Down Expand Up @@ -187,9 +199,23 @@ private ArtifactInstallerRequest processProject(Project project) {
artifactManager.setPath(pomArtifact, pomPath);
installables.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)) {
request.addArtifact(RepositoryUtils.toArtifact(mavenMainArtifact));
} else 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 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");
}
installables.add(artifact);
} else {
Expand Down

0 comments on commit 82831f3

Please sign in to comment.