哪里可以获得gmaven-plugin中预定义变量的完整列表?

时间:2011-03-06 19:14:37

标签: groovy maven gmaven-plugin

从何处获取在Maven中gmaven-plugin下执行的Groovy脚本中可用变量的完整列表?除此之外,也许有人知道在哪里可以找到Gmaven文档?

我知道projectsettings。我假设还有其他一些......

2 个答案:

答案 0 :(得分:4)

页面http://docs.codehaus.org/display/GMAVEN/Executing+Groovy+Code列出:

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

答案 1 :(得分:1)

pom中的这个片段可以让您更好地了解运行脚本时可用的内容。大多数有趣的位可能都在binding.project中,是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>