From f8d1b1ab8600c871eeec6dada55f9656bf768bf9 Mon Sep 17 00:00:00 2001 From: Peter Palaga Date: Wed, 27 Mar 2019 15:35:22 +0100 Subject: [PATCH] Fix #314 ErrorRemedy.xmlOutput should log the issues on error level rather than debug --- .../mojo/license/AbstractDownloadLicensesMojo.java | 12 ++++++------ .../license/download/LicensedArtifactResolver.java | 3 ++- .../mojo/license/download/ProjectLicenseInfo.java | 5 +++++ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/codehaus/mojo/license/AbstractDownloadLicensesMojo.java b/src/main/java/org/codehaus/mojo/license/AbstractDownloadLicensesMojo.java index 5096790fc..2261b8252 100644 --- a/src/main/java/org/codehaus/mojo/license/AbstractDownloadLicensesMojo.java +++ b/src/main/java/org/codehaus/mojo/license/AbstractDownloadLicensesMojo.java @@ -1205,7 +1205,7 @@ private void downloadLicenses( LicenseDownloader licenseDownloader, ProjectLicen if ( matchingUrlsOnly && ( depProject.getLicenses() == null || depProject.getLicenses().isEmpty() ) ) { - handleError( depProject, "No license information available for: " + depProject ); + handleError( depProject, "No license information available for: " + depProject.toGavString() ); return; } @@ -1215,7 +1215,7 @@ private void downloadLicenses( LicenseDownloader licenseDownloader, ProjectLicen if ( matchingUrlsOnly && license.getUrl() == null ) { handleError( depProject, "No URL for license at index " + licenseIndex + " in dependency " - + depProject.toString() ); + + depProject.toGavString() ); } else if ( license.getUrl() != null ) { @@ -1308,20 +1308,20 @@ else if ( licenseOutputFile.exists() ) } catch ( URISyntaxException e ) { - handleError( depProject, "POM for dependency " + depProject.toString() + handleError( depProject, "POM for dependency " + depProject.toGavString() + " has an invalid license URL: " + licenseUrl ); getLog().debug( e ); } catch ( FileNotFoundException e ) { - handleError( depProject, "POM for dependency " + depProject.toString() + handleError( depProject, "POM for dependency " + depProject.toGavString() + " has a license URL that returns file not found: " + licenseUrl ); getLog().debug( e ); } catch ( IOException e ) { handleError( depProject, "Unable to retrieve license from URL '" + licenseUrl + "' for dependency '" - + depProject.toString() + "': " + e.getMessage() ); + + depProject.toGavString() + "': " + e.getMessage() ); getLog().debug( e ); } } @@ -1363,7 +1363,7 @@ private void handleError( ProjectLicenseInfo depProject, String msg ) throws Moj case failFast: throw new MojoFailureException( msg ); case xmlOutput: - getLog().debug( msg ); + getLog().error( msg ); depProject.addDownloaderMessage( msg ); break; default: diff --git a/src/main/java/org/codehaus/mojo/license/download/LicensedArtifactResolver.java b/src/main/java/org/codehaus/mojo/license/download/LicensedArtifactResolver.java index 766fe5622..3c15392e3 100644 --- a/src/main/java/org/codehaus/mojo/license/download/LicensedArtifactResolver.java +++ b/src/main/java/org/codehaus/mojo/license/download/LicensedArtifactResolver.java @@ -169,7 +169,8 @@ public void loadProjectDependencies( ResolvedProjectDependencies artifacts, } catch ( ProjectBuildingException e ) { - laBuilder.errorMessage( e.getClass().getSimpleName() + ": " + e.getMessage() ); + laBuilder.errorMessage( "Could not create effective POM for '" + id + "': " + + e.getClass().getSimpleName() + ": " + e.getMessage() ); } depMavenProject = laBuilder.build(); diff --git a/src/main/java/org/codehaus/mojo/license/download/ProjectLicenseInfo.java b/src/main/java/org/codehaus/mojo/license/download/ProjectLicenseInfo.java index b4ac186cf..c66b686f3 100644 --- a/src/main/java/org/codehaus/mojo/license/download/ProjectLicenseInfo.java +++ b/src/main/java/org/codehaus/mojo/license/download/ProjectLicenseInfo.java @@ -173,6 +173,11 @@ public String toString() return getId(); } + public String toGavString() + { + return groupId + ":" + artifactId + ( version == null ? "" : ( ":" + version ) ); + } + /** * {@inheritDoc} */