What's Maven?
It's common to hear about maven, especially for Java Projects but don't confuse Maven with Java, okay? I can explain what's maven and it's use case.
Maven is a popular build automation tool primarily used for Java projects. It provides a structured way to manage project dependencies, build processes, and releases. Maven uses a declarative approach to project management, where you define your project's specifications and dependencies in an XML file called pom.xml (Project Object Model).
Maven helps simplify the build process by managing the dependencies of your project, downloading the required libraries from repositories, and providing a standardized way to build and package your application. It can also generate project documentation, run tests, and perform other tasks related to building and managing Java projects.
To summarize, Maven provides a powerful toolset for building, managing, and releasing Java applications, and it is widely used in the Java development community.
Generating a Maven project without IDE
Usually engineers generate Maven project through an IDE but there are easiest ways to do the same without IDE supports.
If you don't install Maven yet, I recommend to install it before we start. Thus, you can download Maven here and after installed, following the steps to install here.
First of all, to be sure you've installed Maven, open the terminal and running the commando below:
mvn -version
A message similar to the one below will be displayed on terminal.
Now, let's getting started generating your Maven project.
1° Step: Open the terminal again and running the command below.
mvn archetype:generate -DgroupId=com.coffeeantips.maven.app
-DartifactId=coffeeantips-maven-app
-DarchetypeArtifactId=maven-archetype-quickstart
-DarchetypeVersion=1.0 -DinteractiveMode=false
2° Step: After running the commando above a folder called coffeeantips-maven-app/ were created. Change into this directory and we'll see the following structure of folders and files.
Understanding the command parameters
archetype:generate: Generates a new project from an archetype or updates the current project.
-DgroupId: Specifies the package where folders and projects files will be generated.
-DartifactId: Project's name or artifact.
-DarchetypeArtifactId: Maven provides a list of archetypes, you can check here. But for this example, we're using an archetype to generate a sample Maven project.
-DarchetypeVersion: Version project.
-DinteractiveMode: It's a way to define if Maven will interact with user asking for inputs.
Books to study and read
If you want to learn more about and reach a high level of knowledge, I strongly recommend reading the following book(s):
Maven: The Definitive Guide Written by Maven creator Jason Van Zyl and his team at Sonatype, Maven: The Definitive Guide clearly explains how this tool can bring order to your software development projects.
In this book you'll learn about: The POM and Project Relationships, The Build Lifecycle, Plugins, Project website generation, Advanced site generation, Reporting, Properties, Build Profiles, The Maven Repository and more.
Well that’s it, I hope you enjoyed it!
Comments