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
This commit is contained in:
Brett Leslie Porter 2005-11-03 00:23:03 +00:00
parent 2ed5c152fb
commit fc3646e539
1 changed files with 12 additions and 1 deletions

View File

@ -77,6 +77,7 @@ public class LicenseReport
/** /**
* Whether the system is currently offline. * Whether the system is currently offline.
*
* @parameter expression="${settings.offline}" * @parameter expression="${settings.offline}"
*/ */
private boolean offline; private boolean offline;
@ -218,7 +219,11 @@ public class LicenseReport
URL licenseUrl = null; URL licenseUrl = null;
UrlValidator urlValidator = new UrlValidator( UrlValidator.ALLOW_ALL_SCHEMES ); 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 try
{ {
@ -234,6 +239,12 @@ public class LicenseReport
{ {
File licenseFile = new File( project.getBasedir(), url ); File licenseFile = new File( project.getBasedir(), url );
if ( !licenseFile.exists() ) 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( throw new MissingResourceException(
"Maven can't find the file " + licenseFile + " on the system.", null, null ); "Maven can't find the file " + licenseFile + " on the system.", null, null );