allquixotic
allquixotic

Reputation: 1559

Annotate a class at compile-time if it belongs to a package

I like the @Log family of annotations in groovy.util.logging and want to use them, but it's awfully tedious to have to remember to add that annotation to every class.

Is there a way to use Groovy's AST Transformation feature to do something like this:

The goal is to not have to manually put @Log in front of every class declaration within my package hierarchy so I can just use log.info() etc. from everywhere without thinking about it.

Upvotes: 0

Views: 41

Answers (1)

virtualdogbert
virtualdogbert

Reputation: 481

I'm not sure how to do it by package, but you might want to look at Groovy's compilation customizers: http://docs.groovy-lang.org/next/html/documentation/#compilation-customizers

Upvotes: 1

Related Questions