Junior
What does Maven provide when building a project?
sobes.tech AI
Answer from AI
Maven provides:
- Dependency management: Automatic downloading, resolution, and caching of libraries.
- Standardized project structure: The expected directory and file layout.
- Build lifecycle: Defined phases (compile, test, package, etc.) that can be executed.
- Plugin management: Extensibility through plugins for various tasks (unit testing, report generation, deployment, etc.).
- Profile management: Ability to adapt the build for different environments (development, testing, production).
- Report generation: Coverage reports, static analysis, and other metrics.
- Centralized artifact repository: Built-in repository (.m2) and the ability to work with remote repositories (Maven Central, private Nexus/Artifactory).
Default project structure:
src/
├── main/
│ ├── java/ // Java source files
│ ├── resources/ // Application resources
│ └── webapp/ // Web application sources (for war)
└── test/
├── java/ // Test source files
└── resources/ // Test resources
Example plugin:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>