Skip to content

Commit 04f5e88

Browse files
authored
[MDEPLOY-308] Add parameter to lax project validation (#39)
* [MDEPLOY-308] Add parameter to lax project validation --- https://issues.apache.org/jira/browse/MDEPLOY-308 * Reformat
1 parent 2de56bd commit 04f5e88

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,18 @@ public class DeployMojo extends AbstractDeployMojo {
126126
@Parameter(property = "maven.deploy.skip", defaultValue = "false")
127127
private String skip = Boolean.FALSE.toString();
128128

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+
129141
private enum State {
130142
SKIPPED,
131143
DEPLOYED,
@@ -285,8 +297,17 @@ private void processProject(final MavenProject project, DeployRequest request) t
285297
if (isFile(mavenMainArtifact.getFile())) {
286298
request.addArtifact(RepositoryUtils.toArtifact(mavenMainArtifact));
287299
} else if (!project.getAttachedArtifacts().isEmpty()) {
288-
throw new MojoExecutionException("The packaging plugin for this project did not assign "
289-
+ "a main file to the project but it has attachments. Change packaging to 'pom'.");
300+
if (allowIncompleteProjects) {
301+
getLog().warn("");
302+
getLog().warn("The packaging plugin for this project did not assign");
303+
getLog().warn("a main file to the project but it has attachments. Change packaging to 'pom'.");
304+
getLog().warn("");
305+
getLog().warn("Incomplete projects like this will fail in future Maven versions!");
306+
getLog().warn("");
307+
} else {
308+
throw new MojoExecutionException("The packaging plugin for this project did not assign "
309+
+ "a main file to the project but it has attachments. Change packaging to 'pom'.");
310+
}
290311
} else {
291312
throw new MojoExecutionException(
292313
"The packaging for this project did not assign a file to the build artifact");

0 commit comments

Comments
 (0)