views:

277

answers:

2

I have a project divided into several sub-modules (each of them are jar libraries):

myapp
    myapp-commons
    myapp-client
    myapp-server

I've configured my pom.xml in order to create 3 assemblies (client.zip, oracle.tar.gz and server.tar.gz) that are finally stored in the myapp/target directory. I want now is to distribute two of them (oracle.tar.gz and server.tar.gz) to a server using FTP.

Even if I didn't try yet, I know that I can do that quite easily using some lines of Ant inside my pom.xml, but I don't really like this option (I will solve my problem with Ant only if there are no other solution). There are some SO questions (here or here) that offer solutions for that.

My question is to know if there is a better way to do that? I know about the Wagon Maven2 plugin but I didn't succeed in configuring it in order to deploy the assemblies (and not the JAR created).

+1  A: 

As you say in your question, the Ant approach is not ideal, but if you don't find an alternative, this answer shows how to use the antrun plugin to deploy with FTP. The

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

The wagon-ftp plugin allows you to connect to FTP servers. I've not tried this, but you may then be able to bind the deploy-plugin's deploy-file goal to an appropriate phase to deliver the files to the FTP server (some hints on usage at this blog).

Rich Seller
+1 for wagon-ftp.
Pascal Thivent
Sorry, I said "cargo" in my question, but I meant "wagon" in fact ;o)
romaintaz
+1  A: 

The way to deploy artifacts using FTP is documented in Deployment of artifacts with FTP:

In order to deploy artifacts using FTP you must first specify the use of an FTP server in the distributionManagement element of your POM as well as specifying an extension in your build element which will pull in the FTP artifacts required to deploy 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>

Your settings.xml would contain a server element where the id of that element matches id of 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, my understanding is that you want to use such settings for a subset of the produced assemblies only. To do so, I'd create a dedicated module to produced the assemblies to be distributed using FTP and override the distributionManagement element with the FTP setup in this module only.

Pascal Thivent