I'm new to Maven and I've been reading all morning tutorials (amazing tool).
This new Java project I started looking at however doesn't use the default directory structure. Instead of src/main/java
for sources it uses something like src/org/myapp
.
When I run mvn package
on the project (where pom.xml
is located) I get a message saying that no Sources have been compiled because it's not able to find them (the source path being different).
Is there a way to specify your own sources path in Maven?
The Maven directory structure is a standard directory structure which Maven expects to build a project. You do not have to follow the Maven directory structure, but it is much easier if you do, and it also makes it easier for other developers to understand your project directory structure.
The target directory is used to house all output of the build. The src directory contains all of the source material for building the project, its site and so on. It contains a subdirectory for each type: main for the main build artifact, test for the unit test code and resources, site and so on.
By default, Maven local repository is defaulted to ${user. home}/. m2/repository folder : Unix/Mac OS X – ~/.
Maven project structure and contents are declared in an xml file, pom. xml, referred as Project Object Model (POM), which is the fundamental unit of the entire Maven system.
Add sourceDirectory
to the build
tag in the pom file.
<build>
...
<sourceDirectory>src</sourceDirectory>
...
</build>
Here is the relevant section in the maven docs.
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