Uploaded image for project: 'Gradle'
  1. Gradle
  2. GRADLE-1050

Jar task should merge entries, not create duplicates, at least by default.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Resolution: Fixed
    • Affects Version/s: 0.9
    • Fix Version/s: None

      Description

      For a mystery project, I preferred to take jars from a few upstream java projects and combine them into a single jar for convenient distribution. Following hints on the Gradle Wiki, I created a fourth java project and create a trivial build.gradle consisting essentially of this:

      jar {
      project.rootProject.subprojects.each( {aproject ->
      if ( project != aproject ) { // avoid recursion
      aproject.tasks.withType(Jar).each

      {archiveTask -> from zipTree( archiveTask.archivePath ) }

      }
      }
      }

      This almost works. It does not work in that the resulting jar has 3 or 4 manifests and multiple entries for some directories. Zip allows entries with duplicate names, little did I know.

      I suspect this is just an unintended consquence of the recent refactoring of Archive tasks. In any case, I expect, at a minimum, that there would be an easy setting to make "from zipTree" act more like the old Jar merge method. (I couldn't find anything promising in 30 minutes of api/code browsing.) What I really expect is that this would be the default behavior; it must be the 99% case for adding files to jars.

      Thanks for your consideration!

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned
              Reporter:
              jroth John Roth
              Votes:
              31 Vote for this issue
              Watchers:
              26 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: