Maven Tutorial
Introduction to Maven Installation and environment configuration Maven settings Standard directory structure in Maven project command line IntelliJ IDEA Super POM and Parent POM Understanding POM.xml file Declaring maven dependencies Dependency management using repositories in Maven Adding jar file as a dependency in Maven Maven archetypes Maven build life cycle, phases and goals Generating project API documentation Generating Site documentation for a project Installing artifacts in local repository Deploying the artifact on remote repository Maven plug-ins surefire plugin compiler plugin Profiles in MavenExecuting Maven phases and goals through command prompt Maven command line optionsexec-maven-plugin usage Skipping tests in Maven Test execution report in MavenSettings in Maven
Maven settings can be specified in 2 files.- User settings file - ~/.m2/settings.xml
- Maven global settings file - maven_home/conf/settings.xml
Repository Path
Default repository path is ~/.m2/repository But you can change is using below tag in settings.xml
<localRepository>local_repository_path</localRepository>
Interactive mode
Maven interactive mode is true by default. But you change it to false using below tag in settings.xml
<interactiveMode>false</interactiveMode>
Offline mode
Offline mode – It is false by default. But you can change it using below tag.
<offline>true</offline>
Proxy settings
As you know that maven downloads the libraries from internet, you will have to provide proxy settings in case you are behind proxy.
<proxies>
<proxy>
<id>p1</id>
<active>true</active>
<protocol>http</protocol>
<username>user</username>
<password>password</password>
<host>proxy-server-name</host>
<port>80</port>
<nonProxyHosts>exclude.in|abc.com</nonProxyHosts>
</proxy>
</proxies>
Server authentication settings
You can use servers tag to store the authentication information of the servers used by maven
<servers>
<server>
<id>repo1</id>
<username>repo1user</username>
<password>repo1password</password>
</server>
<server>
<!–
more server configuration
–>
</server>
</servers>
Mirror settings
Sometimes the repository used by maven can not serve the requests due to heavy load. So in such situations, we can use mirrors of that particular repositories to download resources.
<mirrors>
<mirror>
<id>mirrorId</id>
<mirrorOf>repo1</mirrorOf>
<name>Mirror Name</name>
<url>https://mirrored_repo1.com.au</url>
</mirror>
</mirrors>
Profiles settings
You can also use profiles so that different settings are used in different conditions. For example – You can create a OS specific profile. Certain tasks are dependent on OS type. So depending upon OS type, specific profile is activated.
<profiles>
<profile>
<id>windows-profile</id>
<activation>
<os>
<family>windows</family>
</os>
</activation>
</profile>
<profile>
<id>unix-profile</id>
<activation>
<os>
<family>unix</family>
</os>
</activation>
</profile>
</profiles>
Web development and Automation testing
solutions delivered!!