mojohaus/license-maven-plugin

FileAlreadyExists exception when organizeLicensesByDependencies is true and a license is cached

Open

#312 opened on Mar 26, 2019

View on GitHub
 (2 comments) (0 reactions) (0 assignees)Java (127 forks)auto 404
bugdownload-licenseshelp wanted

Repository metrics

Stars
 (115 stars)
PR merge metrics
 (PR metrics pending)

Description

Trying to download licenses with organizeLicensesByDependencies set to true.

[WARNING] Unable to retrieve license from URL 'http://www.apache.org/licenses/LICENSE-2.0.txt' for dependency 'org.apache.commons:commons-lang3': /mnt/c/Users/Esran/Documents/NetbeansProjects/storm/target/generated-resources/licenses/org.apache.commons.commons-lang3_the_apache_software_license,_version_2.0
[DEBUG] 
java.nio.file.FileAlreadyExistsException: /mnt/c/Users/Esran/Documents/NetbeansProjects/storm/target/generated-resources/licenses/org.apache.commons.commons-lang3_the_apache_software_license,_version_2.0
    at sun.nio.fs.UnixCopyFile.copy (UnixCopyFile.java:551)
    at sun.nio.fs.UnixFileSystemProvider.copy (UnixFileSystemProvider.java:253)
    at java.nio.file.Files.copy (Files.java:1274)
    at org.codehaus.mojo.license.AbstractDownloadLicensesMojo.downloadLicenses (AbstractDownloadLicensesMojo.java:1082)

The broken code seems to be https://github.com/mojohaus/license-maven-plugin/blob/license-maven-plugin-1.19/src/main/java/org/codehaus/mojo/license/AbstractDownloadLicensesMojo.java#L1082

I'm not sure what that code is supposed to do, but if the target file is supposed to be overwritten, the copy call should set CopyOption.REPLACE_EXISTING.

Contributor guide