Using the Maven Help plugin

Maven provides a –h command-line flag to display various command-line parameters that it supports. However, there is a Help plugin that helps you get other information.

How to do it...

  1. Open the simple Maven project.
  2. Run the following command:
      mvn help:effective-pom 
    
  3. Observe the output:
    How to do it...
  4. Run the following command on a project with a profile (for instance, project-with-profile):
    mvn help:all-profiles
    
  5. Observe the output:
    [INFO] --- maven-help-plugin:2.2:all-profiles (default-cli) @ project-with-profile ---
    [INFO] Listing Profiles for Project: com.packt.cookbook:project-with-profile:jar
    :1.0-SNAPSHOT
      Profile Id: dev (Active: false , Source: pom)
    
  6. Run the following command:
    mvn –help:active-profiles
    
  7. Observe the output:
    Active Profiles for Project 'com.packt.cookbook:project-with-profile:jar:1.0-SNAPSHOT':
    
    The following profiles are active:
    
  8. Now run the following command:
    mvn –Pdev help:active-profiles
    
  9. Observe the output:
    Active Profiles for Project 'com.packt.cookbook:project-with-profile:jar:1.0-SNAPSHOT':
    
    The following profiles are active:
    
     - dev (source: com.packt.cookbook:project-with-profile:1.0-SNAPSHOT)
    

How it works...

The Maven Help plugin provides different goals. These are also supported by IDEs, and are as follows:

  • effective-pom: This displays the pom file that will be used by Maven after applying inheritance, interpolation, and profiles. This is useful to know the final pom file when it is needed for troubleshooting.
  • all-profiles: This goal displays all the profiles that are available for the project. It indicates whether the profiles are active or not.
  • active-profiles: This goal displays the list of active profiles. We explicitly enabled the dev profile (which was not active by default), so it showed up in the list of active profiles.

There's more...

The Maven Help plugin provides a few other goals as well. A notable one is the describe goal, which is used to get details of any plugin.

  1. To understand this, let's use an instance and run the following command:
    mvn help:describe -DgroupId=org.jacoco -DartifactId=jacoco-maven-plugin -Ddetail=true
    
  2. Observe the results:
    There's more...

Tip

The describe goal does not need you to have a Maven project. You are just getting some help information for a particular plugin!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.17.128