How to specify maven's distributionManagement organisation wide?

后端 未结 3 1290
青春惊慌失措
青春惊慌失措 2020-12-07 07:04

I\'m trying to figure out how to organize many (around 50+) maven2 projects, so that they can deploy into a central nexus repository. When using the mvn deploy

3条回答
  •  一向
    一向 (楼主)
    2020-12-07 07:44

    There's no need for a parent POM.

    You can omit the distributionManagement part entirely in your poms and set it either on your build server or in settings.xml.

    To do it on the build server, just pass to the mvn command:

    -DaltSnapshotDeploymentRepository=snapshots::default::https://YOUR_NEXUS_URL/snapshots
    -DaltReleaseDeploymentRepository=releases::default::https://YOUR_NEXUS_URL/releases
    

    See https://maven.apache.org/plugins/maven-deploy-plugin/deploy-mojo.html for details which options can be set.

    It's also possible to set this in your settings.xml.

    Just create a profile there which is enabled and contains the property.

    Example settings.xml:

    
    [...]
      
        
          nexus
          
            snapshots::default::https://YOUR_NEXUS_URL/snapshots
            releases::default::https://YOUR_NEXUS_URL/releases
          
        
      
    
      
        nexus
      
    
    
    

    Make sure that credentials for "snapshots" and "releases" are in the section of your settings.xml

    The properties altSnapshotDeploymentRepository and altReleaseDeploymentRepository are introduced with maven-deploy-plugin version 2.8. Older versions will fail with the error message

    Deployment failed: repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter
    

    To fix this, you can enforce a newer version of the plug-in:

            
              
                
                  
                    maven-deploy-plugin
                    2.8
                  
                
              
            
    

提交回复
热议问题