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

发布于 2024-10-20 07:38:23 字数 220 浏览 7 评论 0原文

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

我了解项目设置。我猜还有其他一些..

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..

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

乖不如嘢 2024-10-27 07:38:23

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

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

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
小兔几 2024-10-27 07:38:23

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>

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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文