在Maven中,我们可以使用exec-maven-plugin
在构建中执行bash命令。
中央存储库的哪个插件可以执行相同的任务?
我问它是因为我必须在另一个插件之后执行bash命令,而这个插件需要在exec-maven插件之后才能在同一阶段执行,所以我不能直接在exec-maven-plugin内部执行。
我想在Maven构建中执行的bash命令如下:
cat file1 >> file2
提前谢谢。
我设法用<concat>
任务解决了maven-antrun-plugin
的问题:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>final step</id>
<phase>install</phase>
<configuration>
<target>
<concat destfile="${project.build.directory}/${project.artifactId}-${project.version}.sh" binary="yes">
<fileset file="${project.build.directory}/script/self-installer.sh" />
<fileset file="${project.build.directory}/${project.artifactId}-${project.version}.tar.gz" />
</concat>
<chmod file="${project.build.directory}/${project.artifactId}-${project.version}.sh" perm="+x"/>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
这相当于bash-cat命令。
请记住,如果连接二进制文件,则必须设置binary="yes"
,否则Ant任务将损坏最终文件。
无论如何,这仍然不是一个基于bash的解决方案,它只是一个使用Ant例程的技巧,因此它不是exec-maven-plugin
的真正等价物