0% found this document useful (0 votes)
4 views10 pages

02 Mavengradle

The document provides a guide on using Maven for project management, build generation, and dependency resolution, including installation instructions for Windows, macOS, and Linux. It outlines the project structure, the role of pom.xml, and the difference between plugins and dependencies, as well as Maven's lifecycle phases. Additionally, it includes homework assignments and an agenda for the next session focusing on Java fundamentals.

Uploaded by

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

02 Mavengradle

The document provides a guide on using Maven for project management, build generation, and dependency resolution, including installation instructions for Windows, macOS, and Linux. It outlines the project structure, the role of pom.xml, and the difference between plugins and dependencies, as well as Maven's lifecycle phases. Additionally, it includes homework assignments and an agenda for the next session focusing on Java fundamentals.

Uploaded by

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

Maven/Gradle

It is also a program which can do


Project management, build generation, dependency resolution
it uses pom.xml (xml data structure)
How to install
windows
install choco (run powershell run as admin and run commands)
Set-ExecutionPolicy AllSigned -Scope LocalMachine
[System.Net.ServicePointManager]::SecurityProtocol =
[System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-
Object
System.Net.WebClient).DownloadString('https://community.chocolatey.org/in
stall.ps1')) 1

install maven using:- choco install maven


macOS
install homebrew (goto brew.sh & install)
brew install maven
Linux
sudo apt install maven
Common Error in WINDOWS

add JAVA_HOME env global variable


restart your PC
congrats🎉
project structure
src
main
java
com
singhdevhub company name
App.java
test
java
com
singhdevhub company name
AppTest.java

pom.xml

Let’s generate our first project:- mvn archetype:generate


pom.xml

uniquely identifiers

plugins to extend mvn powers

variables/properties

dependencies to download jars


from mvn central
plugins vs dependencies
Dependencies
reusable code, compiled code
classes, functions to use
mvn lifecycle
Validate ⟶ Compile ⟶ Test (UTs) ⟶ Package the code (JAR or WAR) ⟶ Verify ⟶ Install package
in local repo ⟶ Deploy package to remote repo

Plugins
tools that extend plain mvn capabilities maven-compiler-plugin: Compiles your Java
extend Maven lifecycle (e.g., compile, test, source code.
package, deploy) maven-surefire-plugin: Runs your unit tests.
maven-jar-plugin: Packages your project into
a JAR file.
maven-war-plugin: Packages your web
application into a WAR file.
maven-deploy-plugin: Deploys your project
to a remote repository.
external libraries
mvn compile

using pom.xml
using javac and putting code to target/classes
similarly try mvn test, mvn package
JAR → bundle of everything, ready to import, deploy
mvn install
maven remote repo → your company’s repository, public mvn central repo
mvn install:- install JAR package under your local repository
local repo you can find at (home/.m2) & you can see in terminal also where
your jar file from target folder is going

Local repository:-
when we install any dependency what happens ?
while installing mvn checks in local repo if it exists
if not, pull from remote repository

mvn deploy
mvn wrapper
used to maintain consistency across machines (like docker)
will give us executable mvn
run using ./mvn command
homework
assignment 1
try to go through without me teaching you int, char, arrays etc
we will take it in next session
mvn deploy to maven public central repository
others can use your application by importing
integrate in other projects
Add a plugin of yours in mvn
verify plugin (check by running mvn verify)

Next week’s sessions agenda


primitive types, classes & objects (while going through assignment 1)
Wrapper classes
memory allocation, padding for classes and datatypes

You might also like