Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven directory structure

Tags:

java

maven-2

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?

like image 878
Luca Matteis Avatar asked Oct 28 '10 08:10

Luca Matteis


People also ask

What is Maven directory structure?

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.

What is Maven target directory?

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.

What are the folders available in Maven home directory?

By default, Maven local repository is defaulted to ${user. home}/. m2/repository folder : Unix/Mac OS X – ~/.

Which file describes the structure of Maven project?

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.


1 Answers

Add sourceDirectory to the build tag in the pom file.

<build>
    ...
 <sourceDirectory>src</sourceDirectory>
    ...
</build>

Here is the relevant section in the maven docs.

like image 82
dogbane Avatar answered Oct 21 '22 10:10

dogbane