dje*_*lin 5 maven-plugin maven
我想知道是否存在一个运行bash脚本并将其结果保存到属性中的Maven插件。
我的实际用例是获取git源版本。我发现一个插件可以在网上找到,但是它没有经过很好的测试,我想到一个插件,就像这篇文章标题中的那个插件一样简单。插件看起来像:
<plugin>maven-run-script-plugin>
<phase>process-resources</phase> <!-- not sure where most intelligent -->
<configuration>
<script>"git rev-parse HEAD"</script> <!-- must run from build directory -->
<targetProperty>"properties.gitVersion"</targetProperty>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
当然必须确保在需要该属性之前发生这种情况,在我的情况下,我想使用此属性来处理源文件。
我认为您可以使用gmaven插件来完成此任务:
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<properties>
<script>git rev-parse HEAD</script>
</properties>
<source>
def command = project.properties.script
def process = command.execute()
process.waitFor()
project.properties.gitVersion = process.in.text
</source>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
执行此脚本后,您应该能够引用${gitVersion}属性。
| 归档时间: |
|
| 查看次数: |
1550 次 |
| 最近记录: |