【问题标题】:Integrating artifacts generated by an ant target into maven build将 ant 目标生成的工件集成到 maven 构建中
【发布时间】:2011-01-10 01:16:21
【问题描述】:

我正在尝试使用 maven 构建 apache-solr webapp(不是整个项目)。还想重用build.xml ant文件。

目录结构为:

+build
+client
+contrib
.....
+src
 +webapp/src --webapp code
+dist --generated artifacts by the ant script
      --must be copied to the webapp WEB-INF/lib
      --some of them are also needed for webapp code compilation

我已经成功调用了编译和填充 dist 目录的 ant 目标。

我需要的是:

1) 包含一些位于 dist 目录中的 jars 以编译 webapp 代码。

2) 打包战争神器maven构建中的一些jar。

任何帮助将不胜感激

【问题讨论】:

  • maven 正在构建 webapp 吗?谁为 webapp 提供 pom.xml? PS:你为什么不直接用蚂蚁?
  • Maven 构建 webapp。由于项目要求,我必须使用 maven。
  • 为 webapp 提供 pom.xml 是我的职责 ;-)

标签: maven-2 ant


【解决方案1】:

我认为您可以使用maven ant tasks 将 dist 中的 jar 安装到本地存储库中。然后,您可以将 pom 中的这些 jar 用于您的 web 应用程序。

你会做这样的事情:

<artifact:install file="dist/myjar-1.0.jar">
  <pom refid="myjar-pom"/>
</artifact:install>

myjar-pom 定义了如何在 webapp 的 pom 中引用 myjar。

然后在你的 webapp pom 中声明依赖:

<dependency>
  <groupId>myGroup</groupId>
  <artifactId>myjar</artifactId>
  <version>1.0</version>
</dependency>

理想情况下,我认为您希望您的 webapp 的 pom 为您触发您的依赖 ant 构建,这样您只需一步。为此,您应该可以使用maven-antrun-plugin

我没有尝试过这些步骤,但希望它能为您指明正确的方向。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-01-25
    • 2010-12-05
    • 1970-01-01
    • 2010-11-30
    • 1970-01-01
    • 2023-03-07
    • 1970-01-01
    • 2020-08-19
    相关资源
    最近更新 更多