mojohaus / license-maven-plugin

Maven plugin to download and collect license files from project dependencies.
https://www.mojohaus.org/license-maven-plugin/
GNU Lesser General Public License v3.0
107 stars 127 forks source link

overrideUrl doesn't work #331

Closed digulla closed 5 years ago

digulla commented 5 years ago

There is a bug in the code which processes the overrideUrl in org.codehaus.mojo.license.LicenseMojoUtils.prepareUrl(String, File, String, File, String):

    final Path basedirPath = basedir.toPath();

    if ( url != null && UrlRequester.isStringUrl( url ) )
    {
        return basedirPath.toUri().toString();
    }

    final Path defaultPath = basedirPath.resolve( defaultFilePath );

should be

    if ( url != null && UrlRequester.isStringUrl( url ) )
    {
        return url;
    }

    final Path basedirPath = basedir.toPath();
    final Path defaultPath = basedirPath.resolve( defaultFilePath );
ppalaga commented 5 years ago

A couple of unit tests under https://github.com/mojohaus/license-maven-plugin/tree/master/src/test/java/org/codehaus/mojo/license would be highly welcome that would cover not only this broken case but also the cases that work properly now.

digulla commented 5 years ago

Can you please include the fix in 1.21? I tested it locally and without the fix, the functionality is completely broken for us.

You can then leave this issue open to add the unit tests later or create another issue for the tests.

ppalaga commented 5 years ago

Can you please include the fix in 1.21?

I am ready to review a PR from you and I will require the tests to merge it. The tests are for your own safety, so that it cannot happen that somebody breaks your stuff next day after the fix was merged.

Once the PR is merged, I have no problem to release promptly.