整合Maven&非Maven项目 [英] Integrating Maven & Non-maven projects

查看:90
本文介绍了整合Maven&非Maven项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在同时从事两个项目:

I'm currently working on two projects simultaneously:

  • 我的主要项目(使用Maven构建)
  • 我的主要项目所依赖的开源项目的峰值(不是用maven构建的)

鉴于我经常串联开发两者,我如何设置maven以将OSS项目用作依赖关系且摩擦最小?

How do I set up maven to use the OSS project as a dependency with the least amount of friction, given that I'm often developing the two in tandem?

推荐答案

我可以想到几种解决方案:

I can think of several solutions:

  1. 使现有OSS项目变通.当然,这是理想"的选择,但通常不可行(即使您在与现有系统并行的情况下引入了新的构建系统).该项目可能具有与Maven的标准布局不同的现有项目结构.开发人员可能不希望更改现有的布局和构建脚本,而使Maven构建适应非标准布局可能会很痛苦.在这两种情况下,您都被搞砸了.

  1. Mavenize the existing OSS project. This is of course the "ideal" option but often not feasible (even if you introduce the new build system in parallel of the existing one). The project has likely an existing project structure that differs from Maven's standard layout. Changing the existing layout and build script may not be desired by developers, adapting a Maven build to use a non standard layout can be painful. In both case, you're screwed.

将现有的Ant构建与Maven打包.如果您希望将OSS项目的构建包含在项目的生命周期中,并且将二者都构建在一个项目中,那么这会很好.步.您可以查看关于SO的答案有关如何执行此操作的详细信息.

Wrap the existing Ant build with Maven. This can be nice if you want to include the build of the OSS project in the lifecycle of your project and have both of them built in one step. You can check this answer on SO for details on how to do this.

使用 Apache Ivy

Use Apache Ivy or Maven Ant Task in the existing build to produce and install a Maven artifact in your local repository. Use this artifact as a regular dependency in your Maven project (except that you'll have to declare its transitive dependencies manually). This is maybe the quicker and less intrusive approach if building both project separately is not a problem.

您似乎选择了选项3.我认为这是快速获胜的好选择.

It looks like you choose option 3. I think it's a good choice for a quick win.

这篇关于整合Maven&非Maven项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆