Did you ever wonder why the gradle-wrapper jar went from 10k in version 0.5 to 1,140k in version 0.6. It's because the jar task has been broken :(

The convention resouceCollection is always added to the jar even if you specify another fileset. This results in strange behavior, such as:

task wrapperJar(type: Jar) {
    appendix = 'wrapper'
    fileSet(dir: classesDir) {
        include 'org/gradle/wrapper/'
    }
}

For the previous task, it will end up with the fileset from the convention (fileSet(dir:classesDir)) in addition to the one you specified above. This means that files which meet both specs will actually end up in the jar twice! I didn't even know you could do that, but you can see the duplicates of Wrapper.class in gradle-wrapper-0.6.jar (and later).

I think the problem is introduced in AbstractArchiveTask.resourceCollections (AbstractArchiveTask.java line 229): resourceCollections = GUtil.chooseCollection(resourceCollections, getResourceCollections())

If you are setting up a new resourceCollections, you probably don't need to add the convention one first.

I think the following may fix it, but I haven't been around the archive code enough to know if there are other problems with this approach.

Index: src/main/groovy/org/gradle/api/tasks/bundling/AbstractArchiveTask.groovy
===================================================================
--- src/main/groovy/org/gradle/api/tasks/bundling/AbstractArchiveTask.groovy (revision 1649) +++ src/main/groovy/org/gradle/api/tasks/bundling/AbstractArchiveTask.groovy (working copy)
@@ -226,7 +226,9 @@
     }

     public AbstractArchiveTask resourceCollections(Object ... elements) {
- resourceCollections = GUtil.chooseCollection(resourceCollections, getResourceCollections())
+        if (resourceCollections == null) {
+            resourceCollections = new ArrayList();
+        }
         GUtil.flatten(Arrays.asList(elements), resourceCollections);
         return this;
     }



I think this would be a good candidate for a new unit test!

You will need to release a new gradle wrapper with a fix for this before you build 0.7.
--
Steve Appling
Automated Logic Research Team

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email


Reply via email to