首页 文章

将ant目标生成的工件集成到maven构建中

提问于
浏览
1

我正在尝试使用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目录中的一些jar来编译webapp代码 .

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

任何帮助将非常感激

1 回答

  • 1

    我想你可以使用maven ant tasks将dist中的jar安装到本地存储库中 . 然后你可以在pom中使用这些jar用于你的webapp .

    你会做类似的事情:

    <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>
    

    理想情况下,我认为你可以触发你的依赖 Ant 构建,所以你只需要一步 . 为此你应该能够使用maven-antrun-plugin .

    我没有尝试过这些步骤,但希望它会指出你正确的方向 .

相关问题