Order of arguments in Copy.filter

Hi,

I’m learning the basics of gradle and groovy and I’m a bit confused about the documentation for the filter method for the Copy task. I hope someone can explain!

For the method overload:

AbstractCopyTask filter(Map<String, ?> properties, Class<? extends FilterReader> filterType)

It has an example:

filter(ReplaceTokens, tokens:[copyright:'2009', version:'2.3.1'])

But from the signature I would have expected the “tokens” map to be the first argument and the filterType ReplaceTokens to be the second argument.

This order seems to work though, so I’m wondering if I’m missing something in the Groovy syntax?

That’s a question for a Groovy community, it has nothing to do with Gradle.

But you could also just read the Groovy documentation: The Apache Groovy programming language - Object orientation :slight_smile:

Besides that, I highly recommend you use Kotlin DSL, not Groovy DSL. It is the default DSL for a long time already, you immediately get type-safe build scripts, actually helpful error messages if you mess up the syntax, and amazingly better IDE support when using a good IDE like IntelliJ IDEA or Android Studio.

Thank you for the help!

Still green on groovy so it’s difficult to find these features, so the link to the specific documentation is very appreciated!

That explains it even if I find the groovy feature a bit confusing… Will definitely be looking into Kotlin, but the guide I’m following at the moment uses Groovy DSL and the code I work with still uses it so I need to learn it as well.