Maven FAQ's

Maven is a build automation and project management tool primarily for Java projects. It helps manage dependencies, the build lifecycle, project structure, and plugins. Configuration is done in a pom.xml file which contains project information and dependencies.

  • src/main/java – Application source code (production).
  • src/main/resources – Application resources and configuration files.
  • src/test/java – Test source code (unit & integration tests).
  • src/test/resources – Test resources (test configs, test data).
  • target – Output folder for compiled classes and packaged artifacts.
  • pom.xml – Maven project configuration file (dependencies, plugins, build info).

A repository is a storage location for project dependencies and artifacts (jar, war, etc.).

  • Local Repository – Stored on the developer's machine (default: ~/.m2/repository).
  • Remote Repository – Hosted on a server (e.g., a company Nexus or Artifactory).
  • Central Repository – The default public repository (Maven Central) used by Maven to download artifacts.

Maven Goal: A single task provided by a plugin (for example, clean, install, test).

Maven Phase: A step in the Maven build lifecycle that may execute one or more goals. Common lifecycle phases include:

  • validate – validate the project is correct and all necessary information is available.
  • compile – compile the source code.
  • test – run unit tests using a suitable unit testing framework.
  • package – package compiled code into a distributable format (jar, war).
  • verify – run integration tests to verify the package is valid.
  • install – install the package into the local repository for use as a dependency in other projects.
  • deploy – copy the final package to a remote repository for sharing with other developers and projects.