Maven site deploy using ftp

2019-04-22 07:02发布

问题:

I am using Maven2 and would like to deploy my generated site to a web server using ftp.

i tried to use:

<distributionManagement>
    <site>
        <id>website</id>
        <url>ftp://host/pub/</url>
    </site>

</distributionManagement>

the problem is that get an error that ftp is not supported. could it be that this basic feature doesn't work.

Thanks,

Ronen.

回答1:

As I misinterpreted your intention the first time. Here the right solution:

Deploy site via ftp-server

<project>
  [...]
  <distributionManagement>
    <repository>
      <id>ftpserver</id>
      <name>some ftpserver name</name>
      <url>ftp://host/pub</url>
    </repository>
  </distributionManagement>
  <build>
    <extensions>
      <!-- uncomment this one if you use maven < 2.1.0 -->
      <!-- and want to copy directories too :) -->
      <!--
      <extension>
        <groupId>org.mod4j.patched</groupId>
        <artifactId>wagon-ftp</artifactId>
        <version>1.0-beta-2-PATCHEDv3-WAGON-148</version>
      </extension>
      -->

      <!-- uncomment this one (or next) if you use maven >= 2.1.0  -->
      <!--
      <extension>
        <groupId>org.mod4j.patched</groupId>
        <artifactId>wagon-ftp</artifactId>
        <version>1.0-beta-5-PATCHED-v1</version>
      </extension>
      -->
      <!-- i guess you could also use this one instead of the -->
      <!-- org.mod4j.patched version too, but maybe they patched -->
      <!-- something substantial here too in regrad to the apache version -->
      <!--
      <extension>
        <groupId>org.apache.maven.wagon</groupId>
        <artifactId>wagon-ftp</artifactId>
        <version>1.0-beta-5</version>
      </extension>
      -->

      <!-- don't uncomment this one, even if you use maven < 2.1.0. -->
      <!-- except the you don't want to be able to copy directories -->
      <!-- and you know you want too :-) (why would you?) -->
      <!--
      <extension>
        <groupId>org.apache.maven.wagon</groupId>
        <artifactId>wagon-ftp</artifactId>
        <version>1.0-beta-2</version>
      </extension>
      -->
    </extensions>
  </build>
  [...]
</project>

And in your settings.xml you will need

<settings>
  ...
  <servers>
    <server>
      <id>ftpserver</id>
      <username>user</username>
      <password>pass</password>
    </server>
  </servers>
  ...
</settings>