This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a commit to branch maven-deploy-plugin-4.x
in repository https://gitbox.apache.org/repos/asf/maven-deploy-plugin.git
The following commit(s) were added to refs/heads/maven-deploy-plugin-4.x by
this push:
new 75c90a7 Deploy the POM, not the JAR, for pom-packaged projects after
jar:jar
75c90a7 is described below
commit 75c90a705a4e8dffa226aa2aed674b86c9acd68e
Author: Sylwester Lachiewicz <[email protected]>
AuthorDate: Sat Nov 21 17:49:57 2026 +0100
Deploy the POM, not the JAR, for pom-packaged projects after jar:jar
Keep the setPath of the POM artifact unconditional, as InstallMojo does:
after jar:jar the artifact manager already returns the JAR for the POM
artifact, so a 'set only if empty' guard deploys the JAR as the build POM.
---
src/it/deploy-pom-after-jar/invoker.properties | 19 ++++++++
src/it/deploy-pom-after-jar/pom.xml | 51 ++++++++++++++++++++++
src/it/deploy-pom-after-jar/setup.groovy | 22 ++++++++++
src/it/deploy-pom-after-jar/verify.groovy | 30 +++++++++++++
.../apache/maven/plugins/deploy/DeployMojo.java | 6 +--
5 files changed, 125 insertions(+), 3 deletions(-)
diff --git a/src/it/deploy-pom-after-jar/invoker.properties
b/src/it/deploy-pom-after-jar/invoker.properties
new file mode 100644
index 0000000..5ca85e3
--- /dev/null
+++ b/src/it/deploy-pom-after-jar/invoker.properties
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+invoker.maven.version=4+
+invoker.goals = jar:jar deploy:deploy
diff --git a/src/it/deploy-pom-after-jar/pom.xml
b/src/it/deploy-pom-after-jar/pom.xml
new file mode 100644
index 0000000..6fcb8a2
--- /dev/null
+++ b/src/it/deploy-pom-after-jar/pom.xml
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.maven.its.deploy.pomafterjar</groupId>
+ <artifactId>test</artifactId>
+ <version>1.0</version>
+ <packaging>pom</packaging>
+
+ <description>Tests that deploy:deploy deploys the POM, not the JAR, after
jar:jar on a pom-packaged project.</description>
+
+ <distributionManagement>
+ <repository>
+ <id>it</id>
+ <url>file:///${basedir}/target/repo</url>
+ </repository>
+ </distributionManagement>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>3.5.1</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-deploy-plugin</artifactId>
+ <version>@project.version@</version>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/src/it/deploy-pom-after-jar/setup.groovy
b/src/it/deploy-pom-after-jar/setup.groovy
new file mode 100644
index 0000000..1a831bc
--- /dev/null
+++ b/src/it/deploy-pom-after-jar/setup.groovy
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+assert new File(localRepositoryPath,
'org/apache/maven/its/deploy/pomafterjar').deleteDir()
+
diff --git a/src/it/deploy-pom-after-jar/verify.groovy
b/src/it/deploy-pom-after-jar/verify.groovy
new file mode 100644
index 0000000..9d61a79
--- /dev/null
+++ b/src/it/deploy-pom-after-jar/verify.groovy
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+def versionDir = new File(basedir,
'target/repo/org/apache/maven/its/deploy/pomafterjar/test/1.0')
+
+// Maven 4 deploys the consumer POM as test-1.0.pom and the build POM as
test-1.0-build.pom; neither may be the JAR
+def poms = versionDir.listFiles().findAll { it.name.endsWith('.pom') }
+assert poms*.name.contains('test-1.0.pom')
+poms.each { pom ->
+ // a JAR deployed under a .pom name starts with the ZIP signature "PK"
+ assert !(pom.bytes[0] == 0x50 && pom.bytes[1] == 0x4B) : "${pom.name} is a
ZIP, not a POM"
+ assert pom.text.contains('<artifactId>test</artifactId>') : "${pom.name}
is not this project's POM"
+}
+assert !new File(versionDir, 'test-1.0.jar').exists()
diff --git a/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java
b/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java
index 113b145..92e1203 100644
--- a/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java
+++ b/src/main/java/org/apache/maven/plugins/deploy/DeployMojo.java
@@ -426,9 +426,9 @@ public class DeployMojo extends AbstractDeployMojo {
List<ProducedArtifact> toDeploy = new ArrayList<>(deployables);
ArtifactManager artifactManager = getArtifactManager();
- if (artifactManager.getPath(project.getPomArtifact()).isEmpty()) {
- artifactManager.setPath(project.getPomArtifact(),
project.getPomPath());
- }
+ // Always point the POM artifact at the project's POM: on a
pom-packaged project, jar:jar may already have set
+ // the JAR as the file of the artifact with the POM's coordinates.
+ artifactManager.setPath(project.getPomArtifact(),
project.getPomPath());
if (!isValidId(project.getGroupId())
|| !isValidId(project.getArtifactId())