This is something we want for every multi-valued property in the DSL, so you can add values using varargs or an Iterable, and you can set values using varargs or an Iterable. Probably remove too.
We will probably just mix these in dynamically, so they’ll be usable from Groovy, but not Java.
I had tried to use “includes” the same way “include” is used in the documentation ie: includes [a,b]
Which documentation are you referring to? “include [a, b]” would never work here because it would be considered a subscript operation by Groovy.
This is a bit of a tangent for this post, but why does “include ‘a’, ‘b’” work but not “includes ‘a’, ‘b’”?
Because PatternFilterable has an include() method but no includes() method.
To sum up, PatternFilterable has a getIncludes() method, a setIncludes() method, and several include() convenience methods. I don’t see how adding an includes() method would help.
Which documentation are you referring to? “include [a, b]” would never work here because it would be considered a subscript operation by Groovy.
Ah, sorry Pater, that was my mistake when I typed it in. I meant to type “include ‘a’, ‘b’” which was taken from the samples that came with the gradle milestone 3 zip.
Because PatternFilterable has an include() method but no includes() method.
Again, my mistake, I was thinking bean accessors and I did not read the source code well enough.
My original premise was that by having the convenience methods for includes, was based on the fact that I ended up using new HashSet to make use of the setIncludes method.
However, as you pointed out there is a shorter form:
includes = [‘fred.java’, ‘bob.java’]
But by having the convenience method for includes you could shorten this to:
includes ‘fred.java’, ‘bob.java’
It makes the resulting build file a little more consistent when mixed along side code that uses exclude in same PatternFilterable definition.
Hmm, after looking at the documentation and the source code for the TestTask I noticed this:
if (patterns.getIncludes().isEmpty()) {
patterns.include("/*Tests.class", "/*Test.class"); } if (patterns.getExcludes().isEmpty()) {
patterns.exclude("**/Abstract*.class"); }
This means that there is a default pattern ONLY if no other include or excludes are added manually.
I originally looked at this and thought that by default there were ALREADY the two patterns included. So my assumption was that you would need to use setIncludes to clear those default patterns when they were not suitable.