From fc3646e5395eb92c8cf08c8ab4750b68fcb78acc Mon Sep 17 00:00:00 2001 From: Brett Leslie Porter Date: Thu, 3 Nov 2005 00:23:03 +0000 Subject: [PATCH] PR: MNG-1321 Submitted by: Bruno Essmann recognise file:// url's without a hostname for the license git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@330394 13f79535-47bb-0310-9956-ffa450edef68 --- .../maven/report/projectinfo/LicenseReport.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/maven-plugins/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/LicenseReport.java b/maven-plugins/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/LicenseReport.java index 72b5521602..2df6014475 100644 --- a/maven-plugins/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/LicenseReport.java +++ b/maven-plugins/maven-project-info-reports-plugin/src/main/java/org/apache/maven/report/projectinfo/LicenseReport.java @@ -77,6 +77,7 @@ public class LicenseReport /** * Whether the system is currently offline. + * * @parameter expression="${settings.offline}" */ private boolean offline; @@ -218,7 +219,11 @@ public class LicenseReport URL licenseUrl = null; UrlValidator urlValidator = new UrlValidator( UrlValidator.ALLOW_ALL_SCHEMES ); - if ( urlValidator.isValid( url ) ) + // UrlValidator does not accept file URLs because the file + // URLs do not contain a valid authority (no hostname). + // As a workaround accept license URLs that start with the + // file scheme. + if ( urlValidator.isValid( url ) || url.startsWith( "file://" ) ) { try { @@ -234,6 +239,12 @@ public class LicenseReport { File licenseFile = new File( project.getBasedir(), url ); if ( !licenseFile.exists() ) + { + // Workaround to allow absolute path names while + // staying compatible with the way it was... + licenseFile = new File( url ); + } + if ( !licenseFile.exists() ) { throw new MissingResourceException( "Maven can't find the file " + licenseFile + " on the system.", null, null );