From 13c9303cb4d201b2409f739f48e13c5dcafb2631 Mon Sep 17 00:00:00 2001 From: Alessandro Ballarin Date: Thu, 21 Feb 2019 16:10:29 +0100 Subject: [PATCH] Fix #277 aggregate-add-third-party does not use missingFileUrl parameter --- .../license/AbstractAddThirdPartyMojo.java | 31 +++++++++++-------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/src/main/java/org/codehaus/mojo/license/AbstractAddThirdPartyMojo.java b/src/main/java/org/codehaus/mojo/license/AbstractAddThirdPartyMojo.java index bb71d1c0b..b84c5b5bc 100644 --- a/src/main/java/org/codehaus/mojo/license/AbstractAddThirdPartyMojo.java +++ b/src/main/java/org/codehaus/mojo/license/AbstractAddThirdPartyMojo.java @@ -862,22 +862,27 @@ void resolveUnsafeDependenciesFromArtifact( String groupId, String artifactId, S void resolveUnsafeDependenciesFromFile( File missingLicenses ) throws IOException, MojoExecutionException { - if ( missingLicenses != null && missingLicenses.exists() && missingLicenses.length() > 0 ) + if ( missingLicenses == null ) { - // there are missing licenses available from the artifact - SortedProperties unsafeMappings = new SortedProperties( getEncoding() ); + return; + } - if ( missingLicenses.exists() ) - { - // load the missing file - unsafeMappings.load( missingLicenses ); - } - if ( UrlRequester.isStringUrl( missingFileUrl ) ) - { - String httpRequestResult = UrlRequester.getFromUrl( missingFileUrl ); - unsafeMappings.load( new ByteArrayInputStream( httpRequestResult.getBytes() ) ); - } + // there are missing licenses available from the artifact + SortedProperties unsafeMappings = new SortedProperties( getEncoding() ); + if ( missingLicenses.exists() && missingLicenses.length() > 0 ) + { + // load the missing file + unsafeMappings.load( missingLicenses ); + } + if ( useMissingFile && UrlRequester.isStringUrl( missingFileUrl ) ) + { + String httpRequestResult = UrlRequester.getFromUrl( missingFileUrl ); + unsafeMappings.load( new ByteArrayInputStream( httpRequestResult.getBytes() ) ); + } + + if ( !unsafeMappings.isEmpty() ) + { Set resolvedDependencies = new HashSet<>(); for ( MavenProject unsafeDependency : unsafeDependencies ) {