Skip to content

Commit f9ccb64

Browse files
authored
Merge branch 'master' into m-api
2 parents 1741d32 + d458eb1 commit f9ccb64

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ under the License.
9090
<mavenSurefirePluginVersion>${surefire.version}</mavenSurefirePluginVersion>
9191
<mavenWarPluginVersion>3.3.2</mavenWarPluginVersion>
9292

93-
<project.build.outputTimestamp>2023-02-06T12:43:51Z</project.build.outputTimestamp>
93+
<project.build.outputTimestamp>2023-03-21T14:38:01Z</project.build.outputTimestamp>
9494
</properties>
9595

9696
<dependencies>

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

+29-3
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,
@@ -254,9 +266,23 @@ private ArtifactDeployerRequest createDeployerRequest() {
254266
artifactManager.setPath(pomArtifact, pomPath);
255267
deployables.add(pomArtifact);
256268
// main artifact
257-
if (!isValidPath.test(artifact) && !attachedArtifacts.isEmpty()) {
258-
throw new MojoException("The packaging plugin for this project did not assign "
259-
+ "a main file to the project but it has attachments. Change packaging to 'pom'.");
269+
if (!isValidPath.test(artifact)) {
270+
if (!attachedArtifacts.isEmpty()) {
271+
if (allowIncompleteProjects) {
272+
getLog().warn("");
273+
getLog().warn("The packaging plugin for this project did not assign");
274+
getLog().warn("a main file to the project but it has attachments. Change packaging to 'pom'.");
275+
getLog().warn("");
276+
getLog().warn("Incomplete projects like this will fail in future Maven versions!");
277+
getLog().warn("");
278+
} else {
279+
throw new MojoExecutionException("The packaging plugin for this project did not assign "
280+
+ "a main file to the project but it has attachments. Change packaging to 'pom'.");
281+
}
282+
} else {
283+
throw new MojoExecutionException(
284+
"The packaging for this project did not assign a file to the build artifact");
285+
}
260286
}
261287
deployables.add(artifact);
262288
} else {

0 commit comments

Comments
 (0)