The maven jar plugin automatically adds license files to jar META-INF. The Ant plugin can be made to generate a build.xml that does this by including this file as a resource with targetpath META-INF, but this causes the maven jar task to insert two copies of the file.
It would be great if the ant plugin generated a build.xml that does the same thing that the maven jar task does. I am attaching a patch that works if the url property of licenses in the POM is a relative local path reference to the license file. I could not figure out how to canonicalize the file path as the jar plugin appears to do.
Hmmm...
the license/url element is not supposed to be used for a file in this way AFAIK.
The jar plugin does this:
<j:set var="licenseFileName"><license:fileName/></j:set>
<util:file name="${licenseFileName}" var="licenseFile"/>
<ant:metainf dir="${licenseFile.canonicalFile.parent}">
<ant:include name="${licenseFile.canonicalFile.name}"/>
</ant:metainf>
Which uses ${maven.license.licenseFile} and defaults to ${basedir}/LICENSE.txt.
We could use the <license:relativeFileName /> tag to get the license file relative to ${basedir} for the Ant plugin.
Whaddya think?