使用ftp部署Maven站点

时间:2009-07-01 14:42:03

标签: maven-2 ftp deployment

我正在使用Maven2,并希望使用ftp将我生成的网站部署到Web服务器。

我试图使用:

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

</distributionManagement>

问题是得到一个不支持ftp的错误。 可能是这个基本功能不起作用。

谢谢,

罗南。

1 个答案:

答案 0 :(得分:8)

因为我第一次误解了你的意图。这是正确的解决方案:

通过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>

在您的settings.xml中,您需要

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