[GRADLE-1406] MissingMethodException: static org.gradle.ap i.internal.file.pattern.PatternMatcherFactory.getPatternMatcher() Created: 28/Feb/11  Updated: 10/Apr/14  Resolved: 10/Apr/14

Status: Resolved
Project: Gradle
Affects Version/s: 0.9.1
Fix Version/s: 1.0-milestone-6

Type: Bug
Reporter: Remon Sinnema Assignee: Unassigned
Resolution: Fixed Votes: 0


 Description   

I have a project with a 3rd party jar and some Java files that are meant to override the files in the jar:

jar {
from(zipTree('foo.jar'))

{ exclude sourceSets.main.classes }

}

This gives me the internal error below. If I remove the line containing "exclude", the build succeeeds, but the jar contains certain .class files twice.

groovy.lang.MissingMethodException: No signature of method: static org.gradle.ap
i.internal.file.pattern.PatternMatcherFactory.getPatternMatcher() is applicable
for argument types: (java.lang.Boolean, java.lang.Boolean, java.io.File) values:
[false, true, C:\Users\sinner\Perforce\sinner_NESASINNERL1C\depot\Platform\XACM
L\Main\org.openliberty.openaz\build\classes\main]
Possible solutions: getPatternMatcher(boolean, boolean, java.lang.String)
at groovy.lang.MetaClassImpl.invokeStaticMissingMethod(MetaClassImpl.jav
a:1357)
at groovy.lang.MetaClassImpl.invokeStaticMethod(MetaClassImpl.java:1343)

at org.codehaus.groovy.runtime.callsite.StaticMetaClassSite.call(StaticM
etaClassSite.java:50)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSi
teArray.java:40)
at org.gradle.api.internal.file.pattern.PatternMatcherFactory$getPattern
Matcher.call(Unknown Source)
at org.gradle.api.tasks.util.PatternSet.getAsSpec(PatternSet.groovy:112)

at org.gradle.api.internal.file.AbstractFileTree.matching(AbstractFileTr
ee.java:65)
at org.gradle.api.internal.file.CompositeFileTree$FilteredFileTree.addSo
urceCollections(CompositeFileTree.java:94)
at org.gradle.api.internal.file.CompositeFileCollection.getSourceCollect
ions(CompositeFileCollection.java:144)
at org.gradle.api.internal.file.CompositeFileTree.getSourceCollections(C
ompositeFileTree.java:30)
at org.gradle.api.internal.file.CompositeFileCollection.getFiles(Composi
teFileCollection.java:36)
at org.gradle.api.internal.file.CompositeFileCollection.getFiles(Composi
teFileCollection.java:37)
at org.gradle.api.internal.file.CompositeFileCollection.getFiles(Composi
teFileCollection.java:37)
at org.gradle.api.internal.file.AbstractFileCollection.iterator(Abstract
FileCollection.java:60)
at org.gradle.api.internal.changedetection.DefaultFileSnapshotter.snapsh
ot(DefaultFileSnapshotter.java:42)
at org.gradle.api.internal.changedetection.DefaultTaskArtifactStateRepos
itory$HistoricExecution.calcCurrentState(DefaultTaskArtifactStateRepository.java
:143)
at org.gradle.api.internal.changedetection.DefaultTaskArtifactStateRepos
itory$HistoricExecution.isUpToDate(DefaultTaskArtifactStateRepository.java:153)
at org.gradle.api.internal.changedetection.DefaultTaskArtifactStateRepos
itory$TaskArtifactStateImpl.isUpToDate(DefaultTaskArtifactStateRepository.java:2
92)
at org.gradle.api.internal.changedetection.ShortCircuitTaskArtifactState
Repository$1.isUpToDate(ShortCircuitTaskArtifactStateRepository.java:35)
at org.gradle.api.internal.project.taskfactory.ExecutionShortCircuitTask
Executer.execute(ExecutionShortCircuitTaskExecuter.java:40)
at org.gradle.api.internal.tasks.SkipTaskExecuter.doExecute(SkipTaskExec
uter.java:57)
at org.gradle.api.internal.tasks.SkipTaskExecuter.execute(SkipTaskExecut
er.java:35)
at org.gradle.api.internal.tasks.ExecuteAtMostOnceTaskExecuter.execute(E
xecuteAtMostOnceTaskExecuter.java:32)
at org.gradle.api.internal.AbstractTask.execute(AbstractTask.java:231)
at org.gradle.execution.DefaultTaskGraphExecuter.executeTask(DefaultTask
GraphExecuter.java:167)
at org.gradle.execution.DefaultTaskGraphExecuter.doExecute(DefaultTaskGr
aphExecuter.java:160)
at org.gradle.execution.DefaultTaskGraphExecuter.execute(DefaultTaskGrap
hExecuter.java:78)
at org.gradle.execution.TaskNameResolvingBuildExecuter.execute(TaskNameR
esolvingBuildExecuter.java:113)
at org.gradle.execution.DelegatingBuildExecuter.execute(DelegatingBuildE
xecuter.java:54)
at org.gradle.execution.DelegatingBuildExecuter.execute(DelegatingBuildE
xecuter.java:54)
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(Default
GradleLauncher.java:153)
at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradle
Launcher.java:107)
at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLaun
cher.java:75)
at org.gradle.launcher.RunBuildAction.execute(RunBuildAction.java:41)
at org.gradle.launcher.RunBuildAction.execute(RunBuildAction.java:27)
at org.gradle.launcher.CommandLineActionFactory$WithLoggingAction.execut
e(CommandLineActionFactory.java:209)
at org.gradle.launcher.CommandLineActionFactory$WithLoggingAction.execut
e(CommandLineActionFactory.java:193)
at org.gradle.launcher.Main.execute(Main.java:55)
at org.gradle.launcher.Main.main(Main.java:40)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.gradle.launcher.ProcessBootstrap.runNoExit(ProcessBootstrap.java:
46)
at org.gradle.launcher.ProcessBootstrap.run(ProcessBootstrap.java:28)
at org.gradle.launcher.GradleMain.main(GradleMain.java:24)



 Comments   
Comment by Peter Niederwieser [ 28/Feb/11 ]

There is no exclude that takes a FileCollection. The following should work:

jar {
  from(zipTree('foo.jar') - fileTree(sourceSets.main.classesDir))
}
Comment by Remon Sinnema [ 01/Mar/11 ]

Thanks, Peter. The solution in Gradle is always more elegant than I suspect at first

However, the documentation wasn't clear on what kind of items can be iterated to be excluded.

Comment by Remon Sinnema [ 01/Mar/11 ]

Cheered too soon: Your solution gives me a jar with all the classes from foo.jar in the root, without the directory structure required for their packages.

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