I have a java project that needs to support both java11 and java21 jars. Not all classes are java11 compatible so I have an excludes file. Ant uses javac and the excludesfile tag to exclude any of those directories in the file, in gradle I use exclude. However, when I exclude a file that is used by a file included in ant it still includes that file. In gradle however, it just throws an error because that file was excluded. Is there a way to do that dependency resolution in my gradle build task?
To be honest, it sounds like a bug to me when you explicitly say “exclude this file from compilation” and it is nevertheless compiled.
I don’t think that you can or should be able to replicate this in Gradle.
But maybe your use-case can anyway be solved in a more idiomatic way?