Deploying Build to FTP Server Using Maven 2

I have a project split into several submodules (each of them are libraries jar

):

myapp
    myapp-commons
    myapp-client
    myapp-server

      

I configured mine pom.xml

to create 3 assemblies ( client.zip

, oracle.tar.gz

and server.tar.gz

) which are finally stored in a directory myapp/target

. Now I want to distribute two of them ( oracle.tar.gz

and server.tar.gz

) to the server using FTP.

Even if I haven't tried it yet, I know I can do it quite easily by using some Ant lines inside mine pom.xml

, but I don't really like this option (I will only resolve my Ant problem if there is no other solution). There are several SO questions ( here or here ) that suggest solutions for this.

My question is to know if there is a better way to do this? I am aware of the Wagon Maven2 plugin, but I was unable to configure it to deploy assemblies (and no JAR generated).

+2


source to share


2 answers


As you say in your question, Ant's approach isn't perfect, but if you can't find an alternative, this answer shows you how to use the antrun plugin for FTP deployment.

Update based on your updated question, this part is less relevant, I'll leave it to help others though.



The wagon-ftp plugin allows you to connect to FTP servers. I haven't tried this, but then you can bind the deploy-plugin deployment target to the appropriate phase for delivering files to the FTP server (some usage tips on this blog ).

+2


source


The way to deploy artifacts using FTP is documented in Deploying artifacts using FTP :

To deploy artifacts using FTP, you must first specify the use of FTP server in the distributionManagement element of your POM, as well as specifying the extension in the assembly element that will pull the FTP artifacts required for deploying with FTP:

  ...

  <!-- Enabling the use of FTP -->
  <distributionManagement>
    <repository>
    <id>ftp-repository</id>
    <url>ftp://repository.mycompany.com/repository</url>
    </repository>
  </distributionManagement>

  <build>
    <extensions>
      <extension>
        <groupId>org.apache.maven.wagon</groupId>
         <artifactId>wagon-ftp</artifactId>
         <version>1.0-alpha-6</version>
      </extension>
    </extensions>
  </build>

      

Yours settings.xml

will contain an item server

where id

this item matches id

the FTP repository specified in the POM above:

<settings>

  ...

  <servers>
    <server>
      <id>ftp-repository</id>
      <username>user</username>
      <password>pass</password>
    </server>

  </servers>

  ...

</settings>

      



Now I understand that you only want to use these settings for a subset of the builds produced. To do this, I created a special module for creating collections that will be distributed using FTP and override the element distributionManagement

with FTP settings only in this module.

+2


source







All Articles