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