unsupported operation when adding to project archive

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

unsupported operation when adding to project archive

jaco.uys
Hi,

I get an unsupported operation exception when trying to include some files to the project archive. It seems that underlying an Collections.singletonList is used and hence no adding is allowed after creation of the collection.
eg:

    task('archive_jar').zipFileSet(dir: file('etc/schemas')) {
        include('*.xsd')
    }

here is the stack trace.

java.lang.UnsupportedOperationException
        at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:469)
        at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:36)
        at org.gradle.configuration.BuildConfigurer$_closure1.doCall(BuildConfigurer.groovy:44)
        at $Proxy0.execute(Unknown Source)
        at org.gradle.api.internal.project.AbstractProject.applyActions(AbstractProject.java:437)
        at org.gradle.api.internal.project.AbstractProject.allprojects(AbstractProject.java:432)
        at org.gradle.configuration.BuildConfigurer.process(BuildConfigurer.groovy:51)
        at org.gradle.Build.runInternal(Build.java:87)
        at org.gradle.Build.run(Build.java:72)
        at org.gradle.Main.main(Main.java:247)
        at org.gradle.BootstrapMain.main(BootstrapMain.java:70)
Caused by: java.lang.UnsupportedOperationException
        at org.gradle.util.GUtil.flatten(GUtil.java:42)
        at org.gradle.api.tasks.bundling.AbstractArchiveTask.resourceCollections(AbstractArchiveTask.groovy:258)
        at org.gradle.api.tasks.bundling.AbstractArchiveTask.addFileSetInternal(AbstractArchiveTask.groovy:202)
        at org.gradle.api.tasks.bundling.Zip.zipFileSet(Zip.groovy:46)
        at build_gradle$_run_closure9.doCall(build_gradle:455)
        at build_gradle$_run_closure9.doCall(build_gradle)
        at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:42)
        at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:33)
        at org.gradle.api.internal.project.DefaultProject.project(DefaultProject.groovy:145)
        at org.gradle.api.internal.project.DefaultProject.invokeMethod(DefaultProject.groovy)
        at org.gradle.groovy.scripts.DefaultProjectScriptMetaData$_applyMetaData_closure1.doCall(DefaultProjectScriptMetaData.groovy:34)
        at build_gradle.run(build_gradle:443)
        at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:464)


I could fix the issue by changing the default 'resourceCollections' that is assigned in the JavaPlugin on line 112 in current trunk.

from:

jar.conventionMapping(GUtil.map("resourceCollections",
                GroovyJavaHelper.createConventionClosure(Collections.singletonList(new FileSet(javaConvention.getClassesDir())))));

to:
        ArrayList list = new ArrayList();
        list.add(new FileSet(javaConvention.getClassesDir()));

        jar.conventionMapping(GUtil.map("resourceCollections",
                GroovyJavaHelper.createConventionClosure(list)));

http://jira.codehaus.org/browse/GRADLE-187

Regards Jaco

Reply | Threaded
Open this post in threaded view
|

Re: unsupported operation when adding to project archive

hans_d
Administrator
Hi Jaco,

thanks for reporting this. This is fixed now in branch and trunk.

- Hans

On Aug 21, 2008, at 8:02 AM, jaco.uys wrote:

>
> Hi,
>
> I get an unsupported operation exception when trying to include  
> some files
> to the project archive. It seems that underlying an
> Collections.singletonList is used and hence no adding is allowed after
> creation of the collection.
> eg:
>
>     task('archive_jar').zipFileSet(dir: file('etc/schemas')) {
>         include('*.xsd')
>     }
>
> here is the stack trace.
>
> java.lang.UnsupportedOperationException
> at
> org.gradle.api.internal.project.AbstractProject.evaluate
> (AbstractProject.java:469)
> at
> org.gradle.api.internal.project.AbstractProject.evaluate
> (AbstractProject.java:36)
> at
> org.gradle.configuration.BuildConfigurer$_closure1.doCall
> (BuildConfigurer.groovy:44)
> at $Proxy0.execute(Unknown Source)
> at
> org.gradle.api.internal.project.AbstractProject.applyActions
> (AbstractProject.java:437)
> at
> org.gradle.api.internal.project.AbstractProject.allprojects
> (AbstractProject.java:432)
> at
> org.gradle.configuration.BuildConfigurer.process
> (BuildConfigurer.groovy:51)
> at org.gradle.Build.runInternal(Build.java:87)
> at org.gradle.Build.run(Build.java:72)
> at org.gradle.Main.main(Main.java:247)
> at org.gradle.BootstrapMain.main(BootstrapMain.java:70)
> Caused by: java.lang.UnsupportedOperationException
> at org.gradle.util.GUtil.flatten(GUtil.java:42)
> at
> org.gradle.api.tasks.bundling.AbstractArchiveTask.resourceCollections(
> AbstractArchiveTask.groovy:258)
> at
> org.gradle.api.tasks.bundling.AbstractArchiveTask.addFileSetInternal
> (AbstractArchiveTask.groovy:202)
> at org.gradle.api.tasks.bundling.Zip.zipFileSet(Zip.groovy:46)
> at build_gradle$_run_closure9.doCall(build_gradle:455)
> at build_gradle$_run_closure9.doCall(build_gradle)
> at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:42)
> at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:33)
> at
> org.gradle.api.internal.project.DefaultProject.project
> (DefaultProject.groovy:145)
> at
> org.gradle.api.internal.project.DefaultProject.invokeMethod
> (DefaultProject.groovy)
> at
> org.gradle.groovy.scripts.DefaultProjectScriptMetaData
> $_applyMetaData_closure1.doCall(DefaultProjectScriptMetaData.groovy:
> 34)
> at build_gradle.run(build_gradle:443)
> at
> org.gradle.api.internal.project.AbstractProject.evaluate
> (AbstractProject.java:464)
>
>
> I could fix the issue by changing the default 'resourceCollections'  
> that is
> assigned in the JavaPlugin on line 112 in current trunk.
>
> from:
>
> jar.conventionMapping(GUtil.map("resourceCollections",
>
> GroovyJavaHelper.createConventionClosure(Collections.singletonList(new
> FileSet(javaConvention.getClassesDir())))));
>
> to:
>         ArrayList list = new ArrayList();
>         list.add(new FileSet(javaConvention.getClassesDir()));
>
>         jar.conventionMapping(GUtil.map("resourceCollections",
>                 GroovyJavaHelper.createConventionClosure(list)));
>
> http://jira.codehaus.org/browse/GRADLE-187
>
> Regards Jaco
>
>
> --
> View this message in context: http://www.nabble.com/unsupported- 
> operation-when-adding-to-project-archive-tp19082821p19082821.html
> Sent from the gradle-user mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>

--
Hans Dockter
Gradle Project lead
http://www.gradle.org





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

    http://xircles.codehaus.org/manage_email