Maven project structure
Every time I pull a project from a maven repository, it has a different project structure than what I am used to dealing with. Specifically, in the root, there is only a src directory. Under there you have a main. Under there is usually a java and a webapp directory. I see examples of this with Equinox and the Struts 2 blank projects.
Is this a maven thing? An eclipse thing? What is the deal?
请先登录再写评论。
It is a maven (2) convention. If you want maven to generate a correct IDEA project for you then use 'mvn idea:idea' :)
S.
Take a look in the maven documentation at http://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html
for more details. You may also want to join the maven user mailing list .
Weird. I wonder why came up with their own directory structure for java projects.
It's supposed to be a philosophy of 'convention over configuration'.
If some aspect of a project matches the 'standard' way of doing it, then there is no need to specify it in the project's POM file.
I agree with that. I am just curious that they chose a convention that is not the standard way that people create their project structure? Or maybe this is now the standard and I am now out of date?
It's the standard in the Maven Dimension. The problem is that things in the Maven Dimension frequently make very little sense in our own.
:) Haha. At least I learned something today.
Thanks for the info.
Colin Fleming wrote:
The fundamental reason of Maven putting everything in different
directories is that they are trying to infer the purpose of a file from
it's location. The top level contains only project files, src, target
and sub-modules. This gives an uniform structure which allows the
plugins to reason about the application structure and do their magic
without explicit configuration.
For example:
- All project sources are under src
- All generated files are under target
- target contains only generated files, so it can be safely deleted and
should never be chacked in.
- The first level under src tells us what aspect of the application are
these sources for: main, test, site, integration-test, etc.
- The second level under src tells us what is the type (this is somewhat
undefined, but you can thin about it as java, resources, sql, scripts)
- etc.
If all directories were in a flat hierarchy under the root, it might
have worked, but the rules would have to be more complex. It's a
tradeoff and imho it's worth it.
Very good explanation. Is any other framework or Sun looking to go to this directory structure?