============ Build Tools ============ => Build tools are used to automate project build process. => Build process means convert project source code into executable format. Ex: .java files ---> jar or war file for execution .csharp files ---> dll file for execution => We have several build tools in the market 1) ANT (outdated) 2) Maven & Gradle (For Java projects) 3) MS Build (For Dot Net Projects) 4) NPM (for Angular, React, Node JS) ============================= Java Project Execution Flow ============================= => Java Developers will develop source code for the project Ex: .java files => We need to convert source code into byte code using java compiler. => When we compile source code it will be converted into byte code Ex: .class files => We need to package .class files as jar or war file for execution. JAR : Java Archieve WAR : Web Archieve => Standalone apps will be packaged as jar file => Web Apps will be packaged as war file. ======= Maven ======= => It is a build tool => It is free and open source s/w developed by Apache Org. => Maven s/w developed by using Java language. => Maven is used as java projects build automation tool. Note: The main aim of maven is to automate and simplify java projects build process. ================================= What we can do by using maven ? ================================= 1) We can create java project folder structure. 2) We can download required libraries for the project development Ex: hibernate, spring, springboot, junit, logback.. 3) We can compile source code of the project .java file -------> .class file 4) We can execute Unit test cases of the project (junits) 5) We can package our application as jar or war file for deployment. ====================== Maven Setup in Linux ====================== # check maven software availability $ mvn -version # check java software availability $ java -version # install maven s/w $ sudo yum install maven -y Note: When we install maven with above command then java will be installed automatically. ==================== Maven Terminology ==================== 1) Archetype : Represents type of project we want to create quick-start : stand-alone app (jar) web-app : web application (war) 2) groupId : Represents company domain name ex: in.ashokit com.tcs com.ibm 3) artifactId : Represents project name ex: sbi_car_app ashokit_ecomm 4) version : Represents project version SNAPSHOT : means under development RELEASE : means delivered to client 5) packaging : Represents project executable format ex: jar or war 6) dependencies : Libraries requied for project development ex: hibernate, springboot, junit, log4j.... 7) maven goals : To perform project build process. ex: compile, test, package... 8) maven repositories : Location where maven dependencies will be stored. 1) Central Repository 2) Remote Repository 3) Local Repository ========================= Creating Maven Project ========================= => Connect to linux vm using ssh client and execute below command to create maven stand-alone application # create maven stand-alone app $ mvn archetype:generate -DgroupId=in.ashokit -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.5 -DinteractiveMode=false # create maven web-app $ mvn archetype:generate -DgroupId=in.ashokit -DartifactId=my-web-app -DarchetypeArtifactId=maven-archetype-webapp -DarchetypeVersion=1.4 -DinteractiveMode=false $ sudo yum install tree -y $ tree pom.xml :: Project object model. In this file developers will configure maven dependencies. src :: source code of the project (it contains .java files) ============= Maven Goals ============= => Maven Goals are used to perform Project Build Process syntax : mvn Note: We need to execute maven goals from project root directory (where pom.xml is available) => We have several maven goals like below # clean : To delete project target directory # compile : Compile source code of the project Note: It will convert .java files to .class files Note: It will generate target directory to store .class files # test : To execute project unit test code (junits) # package : To package our project as a jar / war file package = compile + test + package Note: application package will be stored into target directory. ex: mvn clean package =================== Maven Repositories =================== Repositoriy : It is a place where maven dependencies will be stored. => We have 3 types of repositories in maven 1) Local Repository 2) Central Repository 3) Remote Repository => Local Repository will be created in our machine (.m2 folder) => Central Repository will be maintained by apache organization (public) => Remote Repository will be maintained by our company to store shared libraries (private). Note: To setup remote repositories we will use Nexus / JFrog softwares. ================== Maven - Summary ================== 1) What is build tool & why 2) What is java application build process 3) Maven Introduction 4) Maven Setup in Linux 5) What we can do using maven 6) Maven Terminology 7) Maven Project creation 8) Maven Dependencies 9) Maven Goals 10) Maven Repositories