在Maven项目中,嵌套目录或平面目录布局的原因是什么?

编程入门 行业动态 更新时间:2024-10-25 18:25:27
本文介绍了在Maven项目中,嵌套目录或平面目录布局的原因是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

随着我的Maven项目的发展,我试图保持在项目结构的顶部.到目前为止,我具有2-3个级别的嵌套目录布局,其中每个级别都有一个POM,其中带有module条目,对应于该级别的目录. POM继承(parent属性)不一定紧随其后,并且与该问题的目的无关.

现在,虽然嵌套结构对于Maven来说似乎很自然,而且只要处于一个特定级别,它就干净整洁,但我开始对自己在IDE(Eclipse和IntelliJ IDEA)中看到的内容感到困惑).

我看了一下Apache Felix的源代码,他们有一个相当复杂的项目,似乎是一个平面目录结构,所以我想知道这是否是更好的方法.

您在实践中遇到的两种方法都有哪些利弊?

请注意,其中此问题(其中我发现与此同时)似乎非常相似.我将其留给社区来决定是否应将其作为重复项关闭.

解决方案

我使用一种混合方法.具有不同生命周期的事物(从发行版和VCS的角度来看)是平坦的,具有相同生命周期的事物是嵌套的.我使用svn:externals进行结帐.我在以前的答案中写了这种方法.. >

As my Maven project grows, I'm trying to stay on top of the project structure. So far, I have a nested directory layout with 2-3 levels, where there's a POM on each level with module entries corresponding to the directories at that level. POM inheritance (parent property) does not necessarily follow this, and is not relevant for the purpose of this question.

Now, while the nested structure seems pretty natural to Maven, and it's nice and clean as long as you are on one particular level, I'm starting to get confused by what I look at in my IDE (Eclipse and IntelliJ IDEA).

I had a look at the Apache Felix sources, and they have a pretty complex project in what seems to be a flat directory structure, so I'm wondering if this would be a better way to go.

What are some pros and cons for either approach that you have experienced in practice?

Note that this question (which I found meanwhile) seems to be very similar. I'll leave it to the community to decide whether this should be closed as a duplicate.

解决方案

I use a kind of mixed approach. Things with distinct lifecycle (from a release and thus VCS point of view) are flat, things with the same lifecycle are nested. And I use svn:externals for the checkout. I wrote about this approach in this previous answer.

更多推荐

在Maven项目中,嵌套目录或平面目录布局的原因是什么?

本文发布于:2023-11-26 03:18:57,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1632419.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:目录   嵌套   布局   平面   原因

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!