[GRADLE-187] unsupported operation when adding to project archive Created: 21/Aug/08  Updated: 04/Jan/13  Resolved: 09/Sep/08

Status: Resolved
Project: Gradle
Affects Version/s: 0.3
Fix Version/s: 0.4

Type: Bug
Reporter: jaco Assignee: Hans Dockter
Resolution: Fixed Votes: 0

Attachments: Text File gradle-issue.patch    

 Description   

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)));


Generated at Wed Jun 30 11:23:51 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.