Wednesday, March 15, 2023

Maven

Maven is an Open Source, Java based build tool.
With help of this we can create packages /  build artifacts.

Maven is not a executable Software.
Maven is a Archive file.

  • Java ------------> Ant , Maven & Gradle
  • .Net -------------> Nant & MS Build
  • Python --------->  PyBuild
  • Ruby -------------> Rake
  • JS, Node JS, Angular -----------> Grunt, gulp
Types of application using Java:
  1. Java Standalone applicatoin 
    • Jar (Java Archive)
    • Java code ( .classfiles )
  2. Java Web application
    • War (Web Archive)
    • Java code  + Web content ( html , css , js , xml , images)
  3. Java Enterprise  application
    • Ear  ( Enterprice  Archive )
    • Java code  + Web content ( html , css , js , xml , images)  more then web content called.
Default build scritpt file:
  • Ant     --------> build.xml
  • Maven --------> pom.xml  (Package Object Model)------->3.6.3 Version
  • Gradle  - ------> build.gradle
Deirectory Structure:
  • bin --------> binaries  --------> mvn
  • conf -------> Settings.xml
  • lib ---------> liberaries --------> Jar files 
  • boot ------->
                                         Java 8 (or) Java 1.8 Version
java -version
mvn -version

Pom.xml:

<Project>---------> Parent tag
            <groupId>com.CompanyName</groupId>
                             com.IBM
                             com.Siemens
            <ArtifactId>Project_Name</ArtifactId>
                                maven-standalone-application
            <Version>1.0.0</Version>
            <Packaging>Package_type</Packaging>
                                   Jar
                                   War
                                   Ear

                       <dependencies>

                                <dependency>
                                                     .........          
                                 <dependency>
                                 <dependency>
                                                     .........         
                                 <dependency>

                      </dependencies>
</Project>

Mavne Repositories :
  • Maven Local Repo 
    • C:\Users\Reddy Shekar\.m2\repository  ----> Windows
    • /home/Reddy Shekar/.m2/repository  -------> Linux
    • /Users/Reddy Shekar/.m2/repository  -------> Mac
  • Maven Central Repo
  • Maven Remote Repo
Is there any change to change the maven local repo path ?   [Interview question]
Yes
Settings.xml
        <LocalRepository>
            Here we can keep the Custom path
        </LocalRepository>


Maven Life Cycles:
  • Clean                    It will deletes the previous build files.
  • Site                       To generate document for source code.
  • Default       
    • Validate ---->It will validate your project Structure and resource files.
    • Compile ---->It will compile your Source code.
    • Test ---------->It will use to run the JUnit Test cases.
    • Package ----> It will create a packages / Build artifacts.
    • Install  ------> It will store build artifacts in to Local Repo.
    • Deploy ------> It will store build artifacts in to Remote Repo.


mvn clean package  ----> 1 Hr

How to skip running Test cases?

mvn clean package -DskipTests
                                  |
                                  |
                                  Option
                                  | 
 mvn clean package -Dmaven.test.skip=true   ----> Not copying
                                                                                  Not Compiling
                                                                                  Skip Test cases.


mvn clean install

How to run a partucular module in Ear?

mvn clean package -pl module1
mvn clean package -pl module1 module2
mvn clean package -pl module1 module2 module3
                                 |
                                 |
                                Project list

Labels:

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home