Categories
Development

Maven update versions

In my projects I use Maven as dependency managment system.

In the past I updated versions of libraries manually in pom.xml. But as projects grow, this becomes more and more annoying and time consuming. So I decided to give it a try to do this automatically.

Add Plugins

Add the Enforcer Maven Plugin and the Versions Maven Plugin:

        
  
    
      org.apache.maven.plugins
      maven-enforcer-plugin
      3.5.0
      
        
          enforce-maven
          
            enforce
          
          
            
              
                3.9
              
                
          
        
      
    
    
      org.codehaus.mojo
      versions-maven-plugin
      2.16.2
      
        false
      
    
  

Preparation

I could not update the version of the plugins when the version information is hardcoded in the plugin section. So I used properties for the plugin versions.


  3.5.0
  2.16.2



  
    
      org.apache.maven.plugins
      maven-enforcer-plugin
      ${enforcer-plugin.version}
      
        
          enforce-maven
          
            enforce
          
          
            
              
                3.9
              
                
          
        
      
    
    
      org.codehaus.mojo
      versions-maven-plugin
      ${versions-plugin.version}
      
        false
      
    
  

Check updates

Check for newer versions in properties, dependencies and plugins:

mvn versions:display-property-updates
mvn versions:display-dependency-updates
mvn versions:display-plugin-updates

Update

Update everything:

mvn versions:update-properties
mvn versions:use-latest-releases

Leave a Reply

Your email address will not be published. Required fields are marked *