Maven - Directory Structure (Project)

Card Puncher Data Processing

About

Maven relies on the Standard Directory Layout

Standard project structure

A standard project

${basedir}
|-- pom.xml
`-- src
    |-- main
    |   `-- java
    |   |   `-- com
    |   |       `-- mycompany
    |   |           `-- app
    |   |               `-- App.java
    |   `-- sql, groovy, ...
    |   `-- resources
    |       `-- META-INF
    |           `-- application.properties
    |-- test
    |   `-- java
    |   |   `-- com
    |   |       `-- mycompany
    |   |           `-- app
    |   |               `-- AppTest.java
    |   `-- resources
    |       `-- test.properties
    `-- target
        `-- classes
            `-- com
                `-- mycompany
                      `-- app
                        `-- App.class

where:

  • the src/main/java directory contains the project source code,
  • 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
  • the pom.xml file is the project's Project Object Model, or POM.

basedir represents the directory containing pom.xml

Configuration

Build pom.xml elements

<project xmlns="http://maven.apache.org/POM/4.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  ...
  <build>
    <sourceDirectory>${basedir}/src/main/java</sourceDirectory>
    <scriptSourceDirectory>${basedir}/src/main/scripts</scriptSourceDirectory>
    <testSourceDirectory>${basedir}/src/test/java</testSourceDirectory>
    <outputDirectory>${basedir}/target/classes</outputDirectory>
    <testOutputDirectory>${basedir}/target/test-classes</testOutputDirectory>
    <directory>${basedir}/target</directory>
    ...
  </build>
</project>

If the values of a *Directory element above is set as an absolute path (when their properties are expanded) then that directory is used. Otherwise, it is relative to the base build directory: basedir.

For resources, check the pom.xml reference and the following article Resources: Including and excluding files and directories

<build>
	...
	<resources>
	  <resource>
		<directory>src/my-resources</directory>
		<includes>
		  <include>**/*.txt</include>
		  <include>**/*.rtf</include>
		</includes>
	  </resource>
	  ...
	</resources>
	...
</build>

Documentation / Reference





Discover More
Card Puncher Data Processing
Maven - (Web)Site (Documentation) Phase

, for instance referenced in , for instance Creating contentDirectory StructureCSSmvnsite phase default where the...
Card Puncher Data Processing
Maven - Assembly (Plugin)

The assembly plugin will build assembly. An “assembly” is a group of files, directories, and dependencies that are assembled into an archive format and distributed. The plugin goals documentation...
Card Puncher Data Processing
Maven - Clean

Clean is a phase that remove the target directory
Card Puncher Data Processing
Maven - Plugin Development

How to develop a maven plugin with Java Annotation. (It's important for the configuration). The code result of this tutorial is on github. gerardnico/helloworld-maven-pluginhelloworld-maven-plugin ...
Card Puncher Data Processing
Maven - Project

A project in the Maven sense contains all little pieces that come into play to give code life. Ie: configuration files, the developers involved and the roles they play, the defect tracking system,...



Share this page:
Follow us:
Task Runner