Skip to content

Commit a22006d

Browse files
authored
Prevent NPE (#1623)
1 parent 9bb5af7 commit a22006d

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -269,13 +269,15 @@ protected void attachFile(String cpString) throws MojoExecutionException {
269269

270270
/**
271271
* Appends the artifact path to the specified StringBuilder.
272-
*
273-
* @param art {@link Artifact}
274-
* @param sb {@link StringBuilder}
275272
*/
276-
protected void appendArtifactPath(Artifact art, StringBuilder sb) {
273+
protected void appendArtifactPath(Artifact artifact, StringBuilder sb) {
277274
if (prefix == null) {
278-
String file = art.getFile().getPath();
275+
File artifactFile = artifact.getFile();
276+
if (artifactFile == null) {
277+
this.getLog().warn(artifact + " file is null.");
278+
return;
279+
}
280+
String file = artifactFile.getPath();
279281
// substitute the property for the local repo path to make the classpath file portable.
280282
if (localRepoProperty != null && !localRepoProperty.isEmpty()) {
281283
File localBasedir =
@@ -287,7 +289,7 @@ protected void appendArtifactPath(Artifact art, StringBuilder sb) {
287289
sb.append(prefix);
288290
sb.append(File.separator);
289291
sb.append(DependencyUtil.getFormattedFileName(
290-
art, this.stripVersion, this.prependGroupId, this.useBaseVersion, this.stripClassifier));
292+
artifact, this.stripVersion, this.prependGroupId, this.useBaseVersion, this.stripClassifier));
291293
}
292294
}
293295

0 commit comments

Comments
 (0)