我使用的是一个库(RootBeer),它需要一个额外的构建步骤:在创建JAR之后,我必须以JAR作为参数运行RootBeer JAR,以创建最终启用RootBeer的JAR。
例如,如果我的jar是myjar.jar,那么我必须使用RootBeer创建最终的伪制品myjar-final.jar:
java -jar rootbeer.jar myjar.jar myjar-final.jar我想知道Maven中是否有一种机制,它使我能够以这种方式构建工件。
现在,我使用的是带有Groovy脚本的gmaven-plugin,但这感觉太麻烦了,而且我很确定我不能在其他项目中使用产生的伪像作为Maven依赖项:
<plugin>
<groupId>org.codehaus.groovy.maven</groupId>
<artifactId>gmaven-plugin</artifactId>
<executions>
<execution>
<id>groovy-magic</id>
<phase>package</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<source>
println """java -jar target/rootbeer-1.2.0.jar target/myjar.jar target/myjar-final.jar"""
.execute().in.eachLine {
line -> println line
}
</source>
</configuration>
</execution>
</executions>
</plugin>有什么建议吗?
发布于 2014-09-04 14:04:28
您可以使用插件执行您在Groovy中实现的最后一步,此外,还需要添加构建-助手-maven-插件以将补充工件添加到Maven中,以便将其与其他工件一起部署。
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.3.2</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- The main class of rootbeer.jar -->
<mainClass>org.trifort.rootbeer.entry.Main</mainClass>
<!-- by setting equal source and target jar names, the main artefact is
replaced with the one built in the final step, which is exactly what I need. -->
<arguments>
<argument>${project.build.directory}/${project.artifactId}.jar</argument>
<argument>${project.build.directory}/${project.artifactId}.jar</argument>
<argument>-nodoubles</argument>
</arguments>
</configuration>
</plugin>https://stackoverflow.com/questions/25666182
复制相似问题