This message was deleted.
# community-support
s
This message was deleted.
v
Probably something like
fileTree("/x/x").matching { include("*.jar"); exclude("foo.jar") }
.
d
it did not worked..
My example: implementation fileTree("/Users/*.jar") .matching { exclude(group: "oabc", module: "xyz") }
Could not find method exclude() for arguments [{group=oabc, module=xyz}] on object of type org.gradle.api.tasks.util.internal.PatternSets$InternalPatternSet.
v
Of course this does not work, it is not at all what I showed
And you cannot exclude something by group and module, because you do not use proper artifact dependencies, but just a "depend on all these jars", so you also have to exclude the jar by name just like I showed.
Actually, I majorly dislike using
files
or
fileTree
for dependencies at all. It is a "bit" unclean and also is missing from things like
dependencies
, build scan, and so on. If really local files are needed as dependency - which is questionable per-se - then at least use a
flatDir
repository and then normal dependency declarations. 🙂
d
ok..let me try that..Actually I have to try out locally hence looking for this solution.
I have two jars having same class path. How to ignore a class file from a jar in gradle.
v
Depends on what you mean. I guess with "jar has class path" you mean the class files included.
Either just make sure they are ordered the way that the one you want used is used first. Or otherwise you could for example use an artifact transform to remote the unwanted classes on the fly, I did similar things with artifact transforms in the past
d
Jar 1 : com.test.Client, Jar 2: com.test.Client. I need to ignore the class in second jar. Can you please provide an example of artifact transform that will be helpful.
v
No, what I did was in a closed source proprietary build, sorry
But as I said, you can also just make sure jar 1 comes first in the classpath if that is easier for you and safe enough