0% found this document useful (0 votes)
8 views

Devops Program 2

The document provides a step-by-step guide on creating a Maven project using Eclipse, including details on setting up the POM file, managing dependencies, and using plugins. It explains the significance of groupId, artifactId, and archetypes in Maven projects. Additionally, it highlights the role of Maven plugins in executing various project actions and maintaining build logic.

Uploaded by

Tejaswini Patil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Devops Program 2

The document provides a step-by-step guide on creating a Maven project using Eclipse, including details on setting up the POM file, managing dependencies, and using plugins. It explains the significance of groupId, artifactId, and archetypes in Maven projects. Additionally, it highlights the role of Maven plugins in executing various project actions and maintaining build logic.

Uploaded by

Tejaswini Patil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Program 2:

Working with Maven: Creating a Maven Project, Understanding the


POM File, Dependency Management and Plugins.
Creating a Maven Project:
STEP 1: Open ECLIPSE then follow this navigation
File —-----> New —------>Maven Project

STEP 2: Make sure Use default Workspace Location is selected, then click Next

Step 3: In Screen shown above, click near the entry place of Filter and type “apache” or
select Catalog as Internal
We want a simple maven JAR based application. So, we will choose the “maven-archetype-
quickstart” artifact to create the project.
Step 4: Enter
Group Id: com.program2.maven
Artifact Id: program2-example-jar
Keep snapshot as it is
After entering above mentioned details click on Finish
You be able to see the automation build happening for Maven Jar Project
It asks for Configuration confirmation just click Y and press Enter

The RESULT be as in below

Step 5: Now its time to build Maven Project


Go to Maven Project —------------>Right Click on the Project and select Maven Build

After the above procedure is done


Select Goal as package
And Click Run
The result be as in below

Now go to App.java finally run java application


Understanding a pom file:
A POM (Project Object Model) file, also known as pom.xml, is a fundamental file in
Maven that contains information about a project. It's an XML file that's used to configure a
project's dependencies, plugins, and build lifecycle.

Dependency Management and Plugins.


What is a dependency in Maven?
In Maven, a dependency is an archive file like JAR, ZIP, etc., that your project needs to
compile, build, test, and run. These project dependencies are defined in the pom. xml file.
When executing a maven build or goal, these project dependencies are resolved and then
fetched from the local repository.
Dependency Management: Maven is a powerful tool for managing dependencies in Java
projects. It simplifies the process of defining, creating, and maintaining reproducible builds
with well-defined classpaths and library versions.
What is a Plugin?
"Maven" is really just a core framework for a collection of Maven Plugins. In other
words, plugins are where much of the real action is performed, plugins are used to: create
jar files, create war files, compile code, unit test code, create project documentation, and on
and on. Almost any action that you can think of performing on a project is implemented as a
Maven plugin.
Plugins are the central feature of Maven that allow for the reuse of common build
logic across multiple projects. They do this by executing an "action" (i.e. creating a WAR file
or compiling unit tests) in the context of a project's description - the Project Object Model
(POM). Plugin behavior can be customized through a set of unique parameters which are
exposed by a description of each plugin goal.

What is groupId in maven ?


groupId identifies a particular project uniquely across all projects, so we should
follow a naming convention.
A good way of maintaining the integrity of groupId is to use the project structure. In
case the project consists of multiple modules then every module should append an identifier
to the parent. groupId. i.e. com.javarewind.maven, com.java rewind.spring,
com.javarewind.struts .. etc
What is artifactId in maven ?
artifactId is the name of war file without version, if you are creating it by yourself,
you are free to took any name of your choice in lower case and without any strange symbol.
But if this is a third-party jar than we have to take the name of the jar as suggested by its
distribution.
What is the archetype in maven?
Archetype is a Maven project templating toolkit which tells the maven the type of
project we are going to create. Archetype enables the maven to create a template project of
the user's choice so that the user can get the project up and running instantly.

You might also like