Skip to content

Commit

Permalink
Enhance exception handling for license execution when the URL tag of …
Browse files Browse the repository at this point in the history
…the license is empty.
  • Loading branch information
djjeon authored and slawekjaranowski committed Sep 11, 2024
1 parent 9ad7c7a commit a331569
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
Expand Down Expand Up @@ -1276,11 +1277,11 @@ private void downloadLicenses(

int licenseIndex = 0;
for (ProjectLicense license : licenses) {
if (matchingUrlsOnly && license.getUrl() == null) {
if (matchingUrlsOnly && StringUtils.isBlank(license.getUrl())) {
handleError(
depProject,
"No URL for license at index " + licenseIndex + " in dependency " + depProject.toGavString());
} else if (license.getUrl() != null) {
} else if (StringUtils.isNotBlank(license.getUrl())) {
final String licenseUrl = urlReplacements.rewriteIfNecessary(license.getUrl());

final LicenseDownloadResult cachedResult = cache.get(licenseUrl);
Expand Down

0 comments on commit a331569

Please sign in to comment.