“复制webapp资源”后如何调用ant任务处理webapp文件在“构建战争”之前打包阶段的步骤?
我正在从 ant 迁移到 Maven。然而,我有一个用于处理 Web 资源的自定义构建功能,我还不想适应 Maven(成本非常高),所以我使用 ant run 插件。
我想处理一些调用ant任务的资源文件。这需要 发生在阶段包中的“复制 webapp 资源”步骤之后和“构建战争”步骤之前。
当我运行 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 任务运行之前构建的,这些更改不是 成为战争档案的一部分。
有办法做到这一点吗?
I'm migrating from ant to maven. However I have a custom build functionality for process web resources that I don't want to adapt yet to maven (the cost is very high) so I'm using ant run plugin.
I want to process some of the resource files calling the ant task. This needs to
happen after the "copying webapp resources" step and before the "building war" steps within the phase package.
When I run my ant task, with the phase being "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>
I can accomplish mychanges to the files under the target/myapp-webapp
folder. However, sincemyapp-webapp.war
is built before the ant task is run, these changes are not
getting to be a part of that war file.
Is there a way to accomplish this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看看 maven-lifecycle!如果您将 ant-task 绑定到 prepare-package 阶段或 process-resources 阶段,您应该能够完成您的任务。
如果您在执行中添加一个 id,您可以在控制台上更轻松地跟踪它:
您对哪些文件执行什么类型的处理?
Have a look at the maven-lifecycle! If you bind your ant-task to the prepare-package phase or to the process-resources phase you should be able to accomplish your task.
If you add an id to your execution you can follow it easier on the console:
What kind of processing are you doing to which files?