I've noticed that a lot of projects have the following structure:
I currently use the following convention (as my projects are 100% java):
I'm not currently using Maven but am wondering if this is a Maven convention or not or if there is another reason. Can someone explain why the first version is so popular these days and if I should adopt this new convention or not?
Chris
The src/main Directory As the name indicates, src/main is the most important directory of a Maven project. Anything that is supposed to be part of an artifact, be it a jar or war, should be present here. Its subdirectories are: src/main/java – Java source code for the artifact.
Describes the Java™ source tree. When you create an API project, it is set up as a Java project with separate folders for source and class files. The source folder is named src . It contains the Java code of the application.
The /src folder comprises of the raw non-minified code. The /src folder is used to store the file with the primary purpose of reading (and/or editing) the code. The /src folder contains all the sources, i.e. the code which is required to be manipulated before it can be used.
At the top you see a directory called "src". This is the source root directory. It is not a Java package itself.
Main benefit is in having the test
directory as subdirectory of src
with the same directory structure as the one in main
:
All package private methods of RootLevelPackageClass
will be visible, i.e. testable from TestRootLevelPackageClass
. Since the testing code is also source its place should be under src
directory.
Yes, this is the Maven convention.
Even if your project is 100% Java (as is typical with Maven btw), you often have resource files (which go to src/main/resources
according to the Maven convention), or web app stuff, or ... all these fit into the Maven system easily.
If you are happy with your current build system (whatever it is), there is no reason to switch to Maven. Otherwise, or if starting a new project, you could evaluate your options, including Maven.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With