将exec maven插件的输出分配给变量
我想使用exec maven插件获取git“修订版”,因此我使用以下配置:将exec maven插件的输出分配给变量,maven,exec-maven-plugin,Maven,Exec Maven Plugin,我想使用exec maven插件获取git“修订版”,因此我使用以下配置: <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>1.2.1</version> <executions> <execution
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<id>gitVersion</id>
<phase>validate</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>git</executable>
<workingDirectory>./</workingDirectory>
<arguments>
<argument>rev-list</argument>
<argument>master</argument>
<argument>--count</argument>
</arguments>
</configuration>
</plugin>
org.codehaus.mojo
execmaven插件
1.2.1
吉特版本
验证
执行官
吉特
./
修订列表
主人
--计数
但我遇到了一个问题——如何将输出分配给其他插件/生命周期中可用的任何变量
(我能够使用gmaven插件并执行groovy脚本完成它,但我发现它有点过分/不够优雅)
编辑:
供参考,groovy中的工作解决方案:
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<providerSelection>2.0</providerSelection>
<properties>
<script>git rev-list master --count</script>
</properties>
<source>
def command = project.properties.script
def process = command.execute()
process.waitFor()
def describe = process.in.text.trim()
println "setting revision to: " + describe
project.properties.setProperty('gitVersion',describe)
</source>
</configuration>
</execution>
</executions>
</plugin>
org.codehaus.gmaven
gmaven插件
1.5
验证
执行
2
git版本列表主目录--计数
def命令=project.properties.script
def process=command.execute()
process.waitFor()
def descripe=process.in.text.trim()
println“将修订设置为:”+描述
project.properties.setProperty('gitVersion',description)
仅为清晰起见,使用groovy的解决方案:
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<providerSelection>2.0</providerSelection>
<properties>
<script>git rev-list master --count</script>
</properties>
<source>
def command = project.properties.script
def process = command.execute()
process.waitFor()
def describe = process.in.text.trim()
println "setting revision to: " + describe
project.properties.setProperty('gitVersion',describe)
</source>
</configuration>
</execution>
</executions>
</plugin>
org.codehaus.gmaven
gmaven插件
1.5
验证
执行
2
git版本列表主目录--计数
def命令=project.properties.script
def process=command.execute()
process.waitFor()
def descripe=process.in.text.trim()
println“将修订设置为:”+描述
project.properties.setProperty('gitVersion',description)
你为什么不咬紧牙关,编写一个简单的插件来完成这项工作?您应该能够从BuildHelperMaven插件中的一个属性设置目标开始。它可能只是一个35行的类文件(包括导入),然后每个人都会有这个!好吧,我已经有了一个可行的解决方案(将其添加到主帖子中),编写maven插件需要更多地挖掘maven,这将花费更多的时间……git commit插件可能会有所帮助:基于这些特定的需求,您的解决方案简单而快速。不需要编写插件