“Mavenize”意味着什么?一个专案? [英] What does it mean to "Mavenize" a project?

查看:101
本文介绍了“Mavenize”意味着什么?一个专案?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我被要求对现有项目进行调整,我不知道这是什么意思。在maven网站上,它概述了如何从头开始创建一个maven项目,但如果我已经获得了大量的代码呢?



我很乐意在命令行或Eclipse / Netbeans中工作。我知道2个IDE的插件很多,这样的东西比较容易,但我不知道从哪里开始。



还有更多的东西,而不仅仅是编写一个具有所有依赖关系的pom文件?

解决方案

要Mavenize简单的方法是写一个POM(并且可能会移动代码),以便它建立在Maven中。



通常最简单的方法是轻松重组你的代码匹配Maven约定(例如将源移动到src / main / java,并明确分开单独的模块)。你可以忽略这些约定,并告诉Maven你是如何存储你的课程等等的,但是一般来说,让Maven大部分的Maven都可以开箱即用的工作,一点点的痛苦就是值得投资。



您的Ant(或类似)文件绝大多数都是样板,这是Maven背后的主意。然而,在那里可能会有一些定制的东西(例如,以TestIntegration开头的测试类只能在夜间运行),您需要在Maven中复制。



但是,一般来说,它意味着使用构建的现有功能,并使用Maven复制相同的功能。


I've recently been asked to mavenize an existing project, and I don't know exactly what that means. On the maven website it outlines how to create a maven project from scratch, but what if I've already got a substantial amount of code?

I'm comfortable working on the command line or in Eclipse/Netbeans. I know there are a lot of plugins for the 2 IDE's that make this kind of thing easier but I don't know where to start.

Is there anything more to it than just writing a pom file that has all the dependencies in it?

解决方案

To "Mavenize" simply means to write a POM (and possibly move code around) so that it builds in Maven.

Often the easiest way to do this is to restructure your code slightly so it matches Maven conventions (e.g. move "sources" to "src/main/java", and explicitly split up separate modules). You can ignore the conventions, and tell Maven how you're storing your classes etc., but in general a small bit of pain up front to make most of Maven then work "out of the box" is worth investing in.

Chances are the vast majority of your Ant (or similar) file is boilerplate, which was the idea behind Maven in the first place. However, there may be some bespoke stuff in there (e.g. test classes that start with "TestIntegration" should only be run on nightly builds) which you'll need to reproduce in Maven.

But yeah, in general it means to take the existing functionality of a build, and reproduce that same functionality using Maven.

这篇关于“Mavenize”意味着什么?一个专案?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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