gpt4 book ai didi

maven - 包阶段 "copying webapp resources"后 "building war"步前如何调用ant任务处理webapp文件?

转载 作者:行者123 更新时间:2023-12-01 13:16:21 25 4
gpt4 key购买 nike

我正在从 ant 迁移到 maven。但是,我有一个用于流程 Web 资源的自定义构建功能,我还不想适应 Maven(成本非常高),所以我正在使用 ant run 插件。

我想处理一些调用ant任务的资源文件。这需要发生在阶段包中的“复制 webapp 资源”步骤之后和“构建 war ”步骤之前。

当我运行我的 ant 任务时,阶段是“package”

        <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<ant antfile="${basedir}/build-resources.xml">
<property name="runtime-classpath" refid="maven.runtime.classpath"/>
</ant>
</tasks>
</configuration>
</execution>
</executions>
</plugin>

我可以完成对 target/myapp-webapp 文件夹下文件的更改。然而,由于myapp-webapp.war 是在ant任务运行之前构建的,这些改动不是成为那个 war 文件的一部分。

有没有办法做到这一点?

最佳答案

看看 maven-lifecycle !如果您将 ant-task 绑定(bind)到 prepare-package 阶段或 process-resources 阶段,您应该能够完成您的任务。

如果您在执行中添加一个 id,您可以在控制台上更轻松地进行操作:

...
<executions>
<execution>
<id>my-ant-processed-files</id>
<phase>prepare-package</phase>
...

您对哪些文件进行了什么样的处理?

关于maven - 包阶段 "copying webapp resources"后 "building war"步前如何调用ant任务处理webapp文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5975465/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com