Skip to content

Commit 730e77d

Browse files
committed
ID-19: fix NullPointerException on missing <build>
1 parent 29ebde7 commit 730e77d

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

CHANGELOG.adoc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ The "info" section is no longer created or updated for "update" certificates.
5252

5353

5454
NOTE: To enable the previous behavior, use the `--cert-config-update` parameter of the configuration tool or the `axway.tools.cfg.cert.updateConfigured` property of the plugin.
55+
56+
|https://github.com/Axway-API-Management-Plus/apigw-maven-plugin/issues/19[#19]
57+
|Fix
58+
|On flattening the resulting POM a NullPointerException occurred if the `pom.xml` has no <build> element (e.g. in case of the <build> element is defined in the parent POM).
59+
60+
The issue occurred for server and deployment projects.
5561
|===
5662

5763
== Version 0.6.0

src/main/java/com/axway/maven/apigw/AbstractFlattendProjectArchiveMojo.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
package com.axway.maven.apigw;
22

3+
import java.util.List;
4+
5+
import org.apache.maven.model.Build;
6+
import org.apache.maven.model.Dependency;
37
import org.apache.maven.model.Model;
8+
import org.apache.maven.model.Plugin;
49

510
public abstract class AbstractFlattendProjectArchiveMojo extends AbstractProjectArchiveMojo {
611

@@ -10,10 +15,19 @@ protected Model generateResultPom() {
1015
Model reducedModel = model.clone();
1116

1217
// Remove all dependences
13-
reducedModel.getDependencies().clear();
18+
List<Dependency> deps = reducedModel.getDependencies();
19+
if (deps != null) {
20+
deps.clear();
21+
}
1422

1523
// Remove all plugins
16-
reducedModel.getBuild().getPlugins().clear();
24+
Build build = reducedModel.getBuild();
25+
if (build != null) {
26+
List<Plugin> plugins = build.getPlugins();
27+
if (plugins != null) {
28+
plugins.clear();
29+
}
30+
}
1731

1832
return reducedModel;
1933
}

0 commit comments

Comments
 (0)