从何处获取在Maven中gmaven-plugin下执行的Groovy脚本中可用变量的完整列表?除此之外,也许有人知道在哪里可以找到Gmaven文档?
我知道project
和settings
。我假设还有其他一些......
答案 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>