Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/it/projects/effective-pom-packaging/invoker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# 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.goals = ${project.groupId}:${project.artifactId}:${project.version}:effective-pom
29 changes: 29 additions & 0 deletions src/it/projects/effective-pom-packaging/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?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>
<modelVersion>4.0.0</modelVersion>

<groupId>org.apache.maven.its.help</groupId>
<artifactId>mph-217</artifactId>
<version>1.0-SNAPSHOT</version>
<!-- no packaging set, should default to "jar" -->
</project>
25 changes: 25 additions & 0 deletions src/it/projects/effective-pom-packaging/verify.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* 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 buildLog = new File(basedir, 'build.log');
assert buildLog.exists()

def LS = System.getProperty("line.separator")
assert buildLog.text.find(
'(?s)' +
' <packaging>jar</packaging>') != null
10 changes: 10 additions & 0 deletions src/main/java/org/apache/maven/plugins/help/EffectivePomMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,16 @@ private void writeEffectivePom(MavenProject project, XMLWriter writer) throws Mo
// This removes the XML declaration written by MavenXpp3Writer
String effectivePom = prettyFormat(sWriter.toString(), null, true);

// MavenXpp3Writer omits packaging when it is null or "jar" (the default).
// Ensure it is always present so users can see the effective packaging value.
if (pom.getPackaging() == null || "jar".equals(pom.getPackaging())) {
String packaging = pom.getPackaging() != null ? pom.getPackaging() : project.getPackaging();
String packagingTag = " <packaging>" + packaging + "</packaging>";
if (!effectivePom.contains(packagingTag)) {
effectivePom = effectivePom.replace("</version>" + LS, "</version>" + LS + packagingTag + LS);
}
}

writeComment(writer, "Effective POM for project '" + project.getId() + "'");

writer.writeMarkup(effectivePom);
Expand Down
Loading