Jenkins

Jenkins is an open source automation server. It helps automate the parts of software development related to building, testing, and deploying, facilitating continuous integration and continuous delivery. It is a server-based system that runs in servlet containers such as Apache Tomcat. Jenkins is an open source continuous integration/continuous delivery and deployment (CI/CD) automation software DevOps […]

Continue reading "Jenkins"

Maven is a build automation tool used primarily for Java projects. Maven can also be used to build and manage projects written in C#, Ruby, Scala, and other languages. The Maven project is hosted by the Apache Software Foundation of the most popular DevOps tools for build automation and management are Gradle and Maven. Both tools offer a wide array of build tools including dependency management,
debugging, and more to help users work through the entire build process. We wanted a standard way to build the projects, a clear definition of what the project consisted of, an easy way to publish project information, and a way to share JARs across several projects. The result is a tool that can now be used for building and managing any Java-based project. We hope that we have created something that will make the day-to-day work of Java developers easier and generally help with the comprehension of any Java-based project.

Maven’s Objectives

Maven’s primary goal is to allow a developer to comprehend the complete state of a development effort in the shortest period of time. In order to attain this goal, Maven deals with several areas of concern:

  • Making the build process easy
  • Providing a uniform build system
  • Providing quality project information
  • Encouraging better development practices

Making the build process easy

While using Maven doesn’t eliminate the need to know about the underlying mechanisms, Maven does shield developers from many details.

Providing a uniform build system

Maven builds a project using its project object model (POM) and a set of plugins. Once you familiarize yourself with one Maven project, you know how all Maven projects build. This saves time when navigating many projects.

Providing quality project information

Maven provides useful project information that is in part taken from your POM and in part generated from your project’s sources. For example, Maven can provide:

  • Change log created directly from source control
  • Cross referenced sources
  • Mailing lists managed by the project
  • Dependencies used by the project
  • Unit test reports including coverage

Third party code analysis products also provide Maven plugins that add their reports to the standard information given by Maven.

Apache Maven Installation And Setup In AWS EC2 Redhat Instnace.

Prerequisite
  • AWS Acccount.
  • Create Redhat EC2 T2.medium Instnace with 4GB of RAM.
  • Create Security Group and open Required ports.
    • 22 ..etc
  • Attach Security Group to EC2 Instance.
  • Install java openJDK 1.8+

Install Java JDK 1.8+ and other softares (GIT, wget and tree)

# install Java JDK 1.8+ as a pre-requisit for maven to run.

sudo hostname maven
cd /opt
sudo yum install wget nano tree unzip git-all -y
sudo yum install java-11-openjdk-devel java-1.8.0-openjdk-devel -y
java -version
git --version

2. Download, extract and Install Maven

#Step1) Download the Maven Software
sudo wget https://dlcdn.apache.org/maven/maven-3/3.8.4/binaries/apache-maven-3.8.4-bin.zip
sudo unzip apache-maven-3.8.4-bin.zip
sudo rm -rf apache-maven-3.8.4-bin.zip
sudo mv apache-maven-3.8.4/ maven

.#Step3) Set Environmental Variable – For Specific User eg ec2-user

vi ~/.bash_profile  # and add the lines below
export M2_HOME=/opt/maven
export PATH=$PATH:$M2_HOME/bin

.#Step4) Refresh the profile file and Verify if maven is running

source ~/.bashrc
mvn -version

Providing guidelines for best practices development

Maven aims to gather current principles for best practices development and make it easy to guide a project in that direction. For example, specification, execution, and reporting of unit tests are part of the normal build cycle using Maven.

Current unit testing best practices were used as guidelines:

  • Keeping test source code in a separate, but parallel source tree
  • Using test case naming conventions to locate and execute tests
  • Having test cases setup their environment instead of customizing the build for test preparation

Maven also assists in project workflow such as release and issue management.

Maven also suggests some guidelines on how to layout your project’s directory structure. Once you learn the layout, you can easily navigate other projects that use Maven.

While Maven takes an opinionated approach to project layout, some projects may not fit with this structure for historical reasons. While Maven is designed to be flexible to the needs of different projects, it cannot cater to every situation without compromising its objectives.

If your project has an unusual build structure that cannot be reorganized, you may have to forgo some features or the use of Maven altogether.

What is Maven Not?

You might have heard some of the following things about Maven:

  • Maven is a site and documentation tool
  • Maven extends Ant to let you download dependencies
  • Maven is a set of reusable Ant scriptlets

While Maven does these things, as you can read above in the “What is Maven?” section, these are not the only features Maven has, and its objectives are quite different.

Maven Options

Maven provides a lot of command-line options to alter the maven build process. Let’s look at some of the important maven options.

1. mvn clean

This command cleans the maven project by deleting the target directory. The command output relevant delete target directory.

2. mvn compiler:compile

This command compiles the java source classes of the maven project.

3. mvn compiler:testCompile

This command compiles the test classes of the maven project.

4. mvn package

This command builds the maven project and packages them into a JAR, WAR, EAR.

5. mvn install

This command builds the maven project and installs the project files (JAR, WAR, pom.xml, etc) to the local repository.

6. mvn deploy

This command is used to deploy the artifact to the remote repository. The remote repository should be configured properly in the project pom.xml file distribution Management tag. The server entries in the maven settings.xml file is used to provide authentication details.

7. mvn validate

This command validates the maven project that everything is correct and all the necessary information is available.

8. mvn dependency:tree

This command generates the dependency tree of the maven project.

9. mvn dependency:analyze

This command analyzes the maven project to identify the unused declared and used undeclared dependencies. It’s useful in reducing the build size by identifying the unused dependencies and then remove it from the pom.xml file.

10. mvn archetype:generate

Maven archetypes is a maven project templating toolkit. We can use this command to generate a skeleton maven project of different types, such as JAR, web application, maven site, etc.

11. mvn site:site

This command generates a site for the project. You will notice a “site” directory in the target after executing this command. There will be multiple HTML files inside the site directory that provides information related to the project.

12. mvn test

This command is used to run the test cases of the project.

13. mvn compile

It’s used to compile the source Java classes of the project.

14. mvn verify

This command build the project, runs all the test cases and run any checks on the results of the integration tests to ensure quality criteria are met.

15. mvn -help

This command prints the maven usage and all the available options for us to use.

16. mvn -f maven-example-jar/pom.xml package

This command is used to build a project from a different location. We are providing the pom.xml file location to build the project. It’s useful when you have to run a maven build from a script.

17. mvn -o package

This command is used to run the maven build in the offline mode. It’s useful when we have all the required JARs download in the local repository and we don’t want Maven to look for any JARs in the remote repository.

18. mvn -q package

Runs the maven build in the quiet mode, only the test cases results and errors are displayed.

19. mvn -X package

Prints the maven version and runs the build in the debug mode. It’s opposite of the quiet mode and you will see a lot of debug messages in the console.

20. mvn -v

Used to display the maven version information.

21. mvn -V package

This command prints the maven version and then continue with the build. It’s equivalent to the commands mvn -v;mvn package.

22. mvn -DskipTests package

The skipTests system property is used to skip the unit test cases from the build cycle. We can also use -Dmaven.test.skip=true to skip the test cases execution.

23. mvn -T 4 package

This command tells maven to run parallel builds using the specified thread count. It’s useful in multiple module projects where modules can be built in parallel. It can reduce the build time of the project.

Chattme.com’s community rules.

Try to champion or be civil in all of your chat and interactions with community member. Treat others the way you expect to be treated. Do not harrassment any body, don’t be rude, no bully, intimidate, defame, harass or stalk any members of chattme.com. Chattme.com has a zero tolerance policy for abuse. You can reports any sensed harassment, intimidation and assault are taken very seriously.

Maven

Maven is a build automation tool used primarily for Java projects. Maven can also be used to build and manage projects written in C#, Ruby, Scala, and other languages. The Maven project is hosted by the Apache Software Foundation of the most popular DevOps tools for build automation and management are Gradle and Maven. Both […]

Continue reading "Maven"

SonarQube

What is SonarQube.SonarQube is an open-source platform developed by SonarSource for continuous inspection of code quality. Sonar does static code analysis, which provides a detailed report of bugs, code smells, vulnerabilities, code duplications, This plugin lets you centralize the configuration of SonarQube server connection details in Jenkins global configuration. Then you can trigger SonarQube analysis […]

Continue reading "SonarQube"

Nexus

Nexus Repository OSS is an open source repository that supports many artifact formats, including Docker, Java™, and npm. With the Nexus tool integration, pipelines in your toolchain can publish and retrieve versioned apps and their dependencies by using central repositories that are accessible from other environments. . What is the purpose of NEXUS! The goal […]

Continue reading "Nexus"

Ansible

What is Ansible? Ansible is an open source IT configuration management (CM) and automation platform, provided by Red Hat. It uses human-readable YAML templates so that users can program repetitive tasks to occur automatically, without learning an advanced language.  Ansible can be used to provision the underlying infrastructure of your environment, virtualized hosts and hypervisors, […]

Continue reading "Ansible"
Follow by Email
LinkedIn
Share
WhatsApp

New Report

Close