Maven
Maven
• Maven requires that you describe what your project is doing. To this end,
Maven offers lifecycles and individual phases that you can configure to tell
Maven what to do in these phases.
Validate,Compile,Test,Package,Integration test,Verify,Deploy
• Maven is ideally suited for running all your tests as part of your
normal build setup. You don’t need a customized environment for
different types of tests. Unit tests run by default, and integration
tests are specified as a phase in the Maven build (between the
packaging and the install phases). In this way, you can rely upon the
previously built package, which can output a WAR file. To run your
integration tests, you need to add and configure the dedicated plug-
ins.
Maven component repositories
1. Verify that your system has java installed or not. if not then install java.
2. Check java Environmental variable is set or not. if not then set java
environmental variable.
3. Download maven.
4. Unpack your maven zip at any place in your system.
5. Add the bin directory of the created directory apache-maven-3.5.3(it
depends upon your installation version) to the PATH environment
variable and system variable.
6. open cmd and run mvn -v command. If it print following lines of code
then installation completed.
POM(Project Object Model)
• Project Object Model (POM) is an XML file that has all the
information regarding project and configuration details. The POM has
the description of the project, details regarding the versioning, and
configuration management of the project.
• The XML file is located in the project home directory. When you
execute a task, Maven searches for the POM in the current directory.
The Need for Maven
• Add or write the code to create the application creation, and process it
into the source code repository.
• Edit any necessary configuration / pom.XML / plugin details.
• Build the actual application.
• Save your build process output as either a WAR or EAR file to a local server
or other location.
• Access the file from the local location or server and deploy it to the
production or client site.
• Update the application document by changing the date and updated
application version number, if necessary.
• Create and generate a report as requested for the application or the
requirement.
Advantages of Maven
• Accenture
• JPMorgan Chase & Co
• Via Varejo
• craft base
• Red Hat
• Mitratech Holdings, Inc.
• KRG TECHNOLOGIES
• Radio - Canada
mvn archetype:generate -DgroupId=com.
javaproject -DartifactId=javaproject -
DarchetypeArtifactId=maven-archetype-
quickstart -DinteractiveMode=false
SonarQube
• Can perform automatic reviews with static code analysis for many
problems that affect code quality.
• Helps maintain quality and reliability of code projects over its life-span
using advanced quality test metrics and graphs.
• Integrates seamlessly with other tools like Jenkins, Atlassian, MSBuild,
etc, which helps productive workflow.
• Supports most popular programming languages like Java, Python,
JavaScript, etc (along with framework support).
How SonarQube helps to assess the quality of the code
At this point, you should be greeted with a little `.bat` file (if you
are on windows) or a `.sh` file (if you are on Linux or Mac). The next
step will be to execute this file to proceed into the console.
On Windows, navigate into the parent directory containing the
`StartSonar.bat` file. This can be done by navigating to the unzipped
folder ('sonarqube') and into the bin and windows-x86-xx folder
Step 3: Start a new SonarQube project
Now that you have successfully run your SonarQube server, you can proceed
to start your first code project. Click on the ‘+’ icon on the top right of the
navigation bar and select ‘Create New Project.’
In the next page, enter a unique project key and a short and suitable display
Name and click on Set Up.
Step 4: Setup Project properties and SonarScanner
This step should be pretty straightforward if you have spent any time
working on code projects.
Register the
…\sonar-scanner-cli-<version>-<OS>\sonar-scanner-<version>-<OS>\bin
directory in your environment variable list.
This can be done by adding an entry in the `Add Environment Variables`
window for Windows.
Step 5: View your analysis report on Sonar Dashboard
After the scan has completed through your code-base, go back to your SonarQube
dashboard on http://localhost:9000 and log in using your credentials. Select your
created project and you will find a code analysis report waiting for you.
The free Community Edition should include Reliability (measured in # of bugs),
Security (in terms of vulnerabilities), Maintainability (depending on your code debt
and smells), Coverage, and Duplications. Depending on the number and intensity of
each check, the Quality Gate will either 'Pass' or 'Fail' the project. A green color
grade will show areas where your code performed well while yellow and red color
grades will highlight problem areas.
https://www.geeksforgeeks.org/introduction-apache-maven-build-automation-
tool-java-projects/
https://www.youtube.com/watch?v=1tC6Z57AOkY