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 MavenCommand line options in Maven
In this topic, we will have a look at various command line options or switches that can be passed to mvn command. Troubleshooting the issues using Debug mode Sometimes, maven fails to execute the goal. By default, Maven does not output all information necessary to find out the cause of failure. In such scenarios, we can use -X switch to see detailed output so that we can pin point actual problem. -X switch is also useful to find out from where maven is reading settings. It also shows which local repository is being used.
mvn -X compile
Turning on the offline mode By default, offline mode is turned off. It means that Maven will hit the remote repositories outside of your network to check for any updates. But sometimes, network is down So you want to work offline. You can use below command to turn on the offline mode.
mvn -o compile
Note that in this mode, only local repository will be used. Running maven in Batch mode By default, Maven runs in interactive mode. To run the maven in Batch mode, you can use below command.
mvn -B compile
Notice that in batch mode, you will not be asked for any input. Activating build profiles in Maven A POM file can specify multiple profiles. We can activate profiles from command line using below options. In below case, we have activated 2 profiles p1 and p2
mvn -P p1,p2 compile
Using custom files (POM, settings) in Maven The locations of POM.xml and settings files are standardized. But you can instruct maven to use these files from different locations using below options.
mvn -f “mypom.xml” -s “mysettings.xml” -gs “myglobalsettings” compile
Web development and Automation testing
solutions delivered!!