Maven: how to copy artifact to specific directory?

前端 未结 4 890
北海茫月
北海茫月 2021-01-01 11:33

The \"install\" goal copies the artifact to the target directory and to the local repository.

How can I tell Maven to copy it also to a given directory

4条回答
  •  一向
    一向 (楼主)
    2021-01-01 11:57

    If you want to copy file to a webserver (local or distant) you can use Maven upload plugin :

                    
                        com.atlassian.maven.plugins
                        maven-upload-plugin
                        1.1
                        
                            
                                ${project.build.directory}/${project.build.finalName}.${project.packaging}
                            
                            ${jboss.deployDir}
                            ${jboss.host}
                            ${jboss.deployUrl}
                        
                    
    

    And to configure parameters in a smart way, I use maven profiles :

    
        
        
            developpement
            
                localhost
                appli/jboss-4.0.4.GA/server/default/deploy/
                file://C:/
            
        
        
        
            validation
            
                ENV_val
                /home/envval/jboss/server/default/deploy/
                scp://PROJECT_LAN_HOST
            
        
    
    

    I've created an "ant launcher", to use it by clicking under Eclipse ant view :

    
        
    
    

    But you can simply run it on a command line :

    mvn upload:upload -Pdeveloppement
    

    By the way, for distant deployment, you may need a login password for scp to work. You have to add them to you Maven settings.xml file :

    
      ...
      
        
          ENV_val
          login
          password
        
      
      ...
    
    

提交回复
热议问题