I've done some very minimal doco already but have more to do.

On Sun., 27 May 2018, 8:47 pm mg, <mgbiz@arscreat.com> wrote:
I saw that, but assertScript is used for many tests, outside of the special requirements of @Macro...

I'll test the documentation, once you get round to doing that :-)

-------- Urspr√ľngliche Nachricht --------
Von: Paul King <paulk@asert.com.au>
Datum: 27.05.18 04:20 (GMT+01:00)
An: dev@groovy.apache.org
Betreff: Re: Groovy 2.5 @Macro ?

Actually, if you look at src/test in groovy-macro, you'll see that the
macro methods and META-INF file are there. The deferred compilation
is achieved using assertScript.

On Sun, May 27, 2018 at 11:21 AM, Paul King <paulk@asert.com.au> wrote:

Macro expansion is done early (CONVERSION) and it expects to find the method it
will be expanding into available on the classpath at that point.

It is pretty much the same reasons as for extension modules:

On Sun, May 27, 2018 at 10:02 AM, mg <mgbiz@arscreat.com> wrote:
Hi Paul,

why this restriction ? I thought this feature was here to e.g. simply support logging of the form "$variableExpression.name=$variableExpression.value", etc:



-------- Urspr√ľngliche Nachricht --------
Von: Paul King <paulk@asert.com.au>
Datum: 27.05.18 01:50 (GMT+01:00)
Betreff: Re: Groovy 2.5 @Macro ?

Your best bet is to have the macro class and META-INF/services file under src/main and your usage under src/test.
If you want to do it all in one file, you can create a temp directory, stuff the META-INF/services file in it, add that directory
to the classpath dynamically and then run your code using the macro with a new GroovyShell().

On Sun, May 27, 2018 at 1:15 AM, MG <mgbiz@arscreat.com> wrote:
I would have expected a quick "you can't use it like that / you just have to / here is some documentation" reply...
Then let me rephrase my question: Why are these Groovy 2.5 tests green:

On 26.05.2018 00:00, MG wrote:
Hi guys,

giving the new Groovy 2.5 macro functionality a spin, and would have expected the code below to replace the "call" to nv(x) with the AST expression created in the method, i.e. returning the name of the "passed" variable. Instead no macro magic happens, and the compilation accordingly fails with "groovy.lang.MissingMethodException: No signature of method: groovy.GroovyMacroSpike.nv() is applicable for argument types: (Integer) values: [123]":
import org.codehaus.groovy.ast.expr.Expression
import org.codehaus.groovy.ast.expr.VariableExpression
import org.codehaus.groovy.macro.runtime.Macro
import org.codehaus.groovy.macro.runtime.MacroContext
import org.junit.Ignore
import org.junit.Test

import static org.codehaus.groovy.ast.tools.GeneralUtils.constX

class GroovyMacroSpike {
  void nvTest() {
    final x = 123
    assert x == 123
    assert nv(x) == "x"

  Expression nv(MacroContext ctx, VariableExpression variable) {
    return constX(variable.getName());
What is missing to make this work ?