3

Where to get a complete list of variables available in Groovy scripts executed under gmaven-plugin in Maven? Besides that, maybe someone knows where to find Gmaven documentation?

I'm aware about project and settings. I assume there are some others..

yegor256
  • 102,010
  • 123
  • 446
  • 597

2 Answers2

4

The page http://docs.codehaus.org/display/GMAVEN/Executing+Groovy+Code lists:

Default Variables
By default a few variables are bound into the scripts environment:

project  The maven project, with auto-resolving properties
pom  Alias for project
session  The executing MavenSession
settings     The executing Settings
log  A SLF4J Logger instance
ant  An AntBuilder instance for easy access to Ant tasks
fail()   A helper to throw MojoExecutionException
Emil Sit
  • 22,894
  • 7
  • 53
  • 75
1

This snippet in your pom should give you a better idea of what's available while running the script. Most of the interesting bits are probably in the binding.project, an instance of MavenProject.

    <build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.groovy.maven</groupId>
            <artifactId>gmaven-plugin</artifactId>
            <executions>
                <execution>
                    <phase>generate-resources</phase>
                    <goals>
                        <goal>execute</goal>
                    </goals>
                    <configuration>
                        <properties>
                            <hello>world</hello>
                        </properties>
                        <source>
                            println this.binding.variables
                            println project.properties
                            println settings.properties
                        </source>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
TheKaptain
  • 1,011
  • 9
  • 10
  • This is what I'm already aware of (see the question). Do you know how I can get a list of dependencies of current plugin, for example? – yegor256 Mar 06 '11 at 19:41
  • Examine the 'project' object in the script, which is an instance of MavenProject, http://maven.apache.org/ref/2.0.4/maven-project/apidocs/org/apache/maven/project/MavenProject.html – TheKaptain Mar 06 '11 at 19:57