How does Maven resolve plugin versions?

后端 未结 3 1825
难免孤独
难免孤独 2021-02-19 00:49

I\'m reading the docs and still confused as to how Maven is deciding which versions of plugins to download.

For example, consider this simple scenario:

  1. an
3条回答
  •  孤独总比滥情好
    2021-02-19 01:43

    Maven defines 3 lifecycles in META-INF/plexus/components.xml:

    1. Default Lifecycle

    Default lifecycle are defined without any associated plugin. Plugin bindings for these lifecycles are defined separately for every packaging in META-INF/plexus/default-bindings.xml

    e.g. Plugin bindings for jar packaging

    
      
        org.apache.maven.plugins:maven-resources-plugin:2.6:resources
      
      
        org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile
      
      
        org.apache.maven.plugins:maven-resources-plugin:2.6:testResources
      
      
        org.apache.maven.plugins:maven-compiler-plugin:2.5.1:testCompile
      
      
        org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test
      
      
        org.apache.maven.plugins:maven-jar-plugin:2.4:jar
      
      
        org.apache.maven.plugins:maven-install-plugin:2.4:install
      
      
        org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy
      
    
    

    2. Clean Lifecycle clean lifecycle is defined directly with its plugin bindings.

    
      pre-clean
      clean
      post-clean
    
    
      
        org.apache.maven.plugins:maven-clean-plugin:2.5:clean
      
    
    

    3. Site Lifecycle Site lifecycle is defined directly with its plugin bindings.

    
      pre-site
      site
      post-site
      site-deploy
    
    
      
        org.apache.maven.plugins:maven-site-plugin:3.3:site
      
      
        org.apache.maven.plugins:maven-site-plugin:3.3:deploy
      
    
    

    If you want to override these default plugin version you can do it from command prompt as follows

    mvn org.apache.maven.plugins:maven-clean-plugin:2.0:clean
    

    instead of

    mvn clean:clean
    

提交回复
热议问题