【问题标题】:exec-maven-plugin equivalent / alternativeexec-maven-plugin 等效/替代
【发布时间】:2020-08-15 03:37:14
【问题描述】:

在 Maven 中,我们可以使用 exec-maven-plugin 在构建中执行 bash 命令。

Central Repository 的哪个插件可以执行相同的任务?

我问它是因为我必须在另一个插件之后执行一个bash命令,该插件需要在exec-maven-plugin之后才能在同一阶段执行,所以我不能直接在exec-maven-plugin内部执行。

我想在 Maven 构建中执行的 bash 命令如下:

cat file1 >> file2 

提前致谢。

【问题讨论】:

  • 我建议写一个更容易和更干净的插件来集成到构建过程中......

标签: bash maven exec-maven-plugin


【解决方案1】:

我设法通过<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 等价物

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-09-24
    • 2014-04-23
    • 2016-12-29
    • 2012-03-13
    • 2011-10-05
    • 2018-07-09
    • 2021-03-31
    • 2014-03-10
    相关资源
    最近更新 更多