Details

    • Type: Improvement Improvement
    • Status: Closed Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.9
    • Labels:
      None
    • Number of attachments :
      2

      Description

      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.

      1. antPlugin2.patch
        0.9 kB
        Phil Steitz
      2. antPluginPatch
        1 kB
        Phil Steitz

        Activity

        Hide
        dion gillard added a comment -

        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?

        Show
        dion gillard added a comment - 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?
        Hide
        Phil Steitz added a comment -

        Defintely looks better. I did not know of maven.license.licenseFile and was incorrectly thinking that it was related to the licenses element in the POM.

        Show
        Phil Steitz added a comment - Defintely looks better. I did not know of maven.license.licenseFile and was incorrectly thinking that it was related to the licenses element in the POM.
        Hide
        Phil Steitz added a comment -

        This patch use maven.license.licenseFile to locate the license file. It should be improved to somehow handle the case where there is no license file, since if nothing is specified it will default to $

        {basedir}

        /LICENSE.txt and add a copy directive for that, which will cause the ant build to fail.

        Show
        Phil Steitz added a comment - This patch use maven.license.licenseFile to locate the license file. It should be improved to somehow handle the case where there is no license file, since if nothing is specified it will default to $ {basedir} /LICENSE.txt and add a copy directive for that, which will cause the ant build to fail.
        Hide
        Arnaud Heritier added a comment -

        Applied. thanks

        Show
        Arnaud Heritier added a comment - Applied. thanks

          People

          • Assignee:
            Arnaud Heritier
            Reporter:
            Phil Steitz
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: