Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Handling unconventional source directory for a web project in maven

Tags:

java

maven-2

I've inherited a web project (Servlets) which is currently build inside eclipse.

I want to add maven around it. But the project's source directory is not following the maven convention. Instead of being inside src/main/java, it's src/package/name/...

I don't want to change anything right now because they are working at full speed towards a milestone. Can I configure maven to accept src/ as the java source directory ? Thanks

like image 755
ashitaka Avatar asked Oct 22 '08 03:10

ashitaka


People also ask

Which option rightly gives the project's source directory in Maven?

Source Directories The Maven property ${project. basedir} defaults to the top level directory of the project, so the build directory defaults to the target directory in project base dir. It also sets the property ${project.

What is Sourcedirectory in Maven?

Maven - Directory Structure (Project)the src/main/resources directory contains the project resources, the src/test/java directory contains the test source, the src/test/resources directory contains the test resources, the target/classes directory contains the compiled classes.

In which folder artifacts build using Maven are created?

The target folder is the maven default output folder. When a project is build or packaged, all the content of the sources, resources and web files will be put inside of it, it will be used for construct the artifacts and for run tests.

What is target folder in Maven project?

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.


1 Answers

Just add this to your pom in the build section.

<sourceDirectory>${basedir}/src</sourceDirectory>

Here's the relevant section of the POM doc on configuring the directories.

like image 81
sblundy Avatar answered Sep 19 '22 22:09

sblundy