diff --git a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java index b1584a70c..5924805ec 100644 --- a/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java +++ b/src/main/java/org/apache/maven/plugins/dependency/fromDependencies/BuildClasspathMojo.java @@ -269,13 +269,15 @@ protected void attachFile(String cpString) throws MojoExecutionException { /** * Appends the artifact path to the specified StringBuilder. - * - * @param art {@link Artifact} - * @param sb {@link StringBuilder} */ - protected void appendArtifactPath(Artifact art, StringBuilder sb) { + protected void appendArtifactPath(Artifact artifact, StringBuilder sb) { if (prefix == null) { - String file = art.getFile().getPath(); + File artifactFile = artifact.getFile(); + if (artifactFile == null) { + this.getLog().warn(artifact + " file is null."); + return; + } + String file = artifactFile.getPath(); // substitute the property for the local repo path to make the classpath file portable. if (localRepoProperty != null && !localRepoProperty.isEmpty()) { File localBasedir = @@ -287,7 +289,7 @@ protected void appendArtifactPath(Artifact art, StringBuilder sb) { sb.append(prefix); sb.append(File.separator); sb.append(DependencyUtil.getFormattedFileName( - art, this.stripVersion, this.prependGroupId, this.useBaseVersion, this.stripClassifier)); + artifact, this.stripVersion, this.prependGroupId, this.useBaseVersion, this.stripClassifier)); } }