Where Maven puts files during build

If you build a project with Maven, you can notice that it creates a target folder, and copies the resource files, the compiled source files, the test resource files and the compiled test source files into specific directories. For example the target/classes directory will contain the compiled source files and the resource files. The questions that could arise are:

  • How Maven know that it needs to create the directories with these names?
  • How does it know where to find the source files to compile?
  • How does it know where are the resource files?

They must be configured somewhere, otherwise Maven wouldn’t know what are the names of these directories. The important thing to know here is that contents of pom.xml files can be inherited. These default settings that we get are  inherited from another pom xml file called the Super POM, from which every pom gets it’s default settings.

The directories mentioned above are defined in the Super POM similar to this:


Note the directories that are created can be different if you overwrite these configuration options in your project’s pom.xml file.

Download source

You can download the source files used in this project here.

If  you build this project using the mvn clean install command, you can check out the created target folder and the directories inside it.