0

我想将我的网站直接上传到我的 ftp 服务器。我正在尝试配置我的 pom.xml,但插件有一些问题。我已经在线阅读了许多指南,但没有一个是独一无二的,或者至少存在很大差异。你有什么技巧或窍门吗?

<profile>
  <id>deploy</id>
  <build>
    <plugins>
      <plugin>
        <inherited>false</inherited>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
        <version>1.6</version>
        <configuration>
          <target>
            <ftp action="send" server="server"
              remotedir="/a/b" userid="usr"
              password="pw" depends="no"
              verbose="yes" binary="yes">
              <fileset dir="modules/my-module/target">
                <include name="my-static-file.zip" />
              </fileset>
            </ftp>
            <taskdef name="ftp"              classname="org.apache.tools.ant.taskdefs.optional.net.FTP"
              classpathref="maven.plugin.classpath" />
          </target>
        </configuration>
        <dependencies>
          <dependency>
            <groupId>commons-net</groupId>
            <artifactId>commons-net</artifactId>
            <version>1.4.1</version>
          </dependency>
          <dependency>
            <groupId>ant</groupId>
            <artifactId>ant-commons-net</artifactId>
            <version>1.6.5</version>
          </dependency>
          <dependency>
            <groupId>ant</groupId>
            <artifactId>ant-jsch</artifactId>
            <version>1.6.5</version>
          </dependency>
          <dependency>
            <groupId>jsch</groupId>
            <artifactId>jsch</artifactId>
            <version>0.1.29</version>
          </dependency>
        </dependencies>
      </plugin>
    </plugins>
  </build>
</profile>
4

2 回答 2

0

Instead of maven-antrun-plugin it is better to use upload goal of maven-wagon-plugin. Here is an example project demonstrating uploading multiple files to ftp.

于 2012-05-31T19:04:26.997 回答
0

现在这是我的 pom.xml。

<build>
  <extensions>
    <extension>
       <groupId>org.apache.maven.wagon</groupId>
       <artifactId>wagon-ftp</artifactId>
       <version>2.2</version>
     </extension>
   </extensions>
      <defaultGoal>package</defaultGoal>
    <plugins>
      <plugin>
        <artifactId>maven-war-plugin</artifactId>
      </plugin>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <source>1.6</source>
          <target>1.6</target>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>wagon-maven-plugin</artifactId>
        <version>1.0-beta-4</version>
        <configuration>
         <skip>false</skip>
          <serverId>ftpserver</serverId>
          <url>ftp://---.---.----.---/var/www/html</url>
        </configuration>
        <executions>
          <execution>
            <id>upload</id>
            <phase>deploy</phase>
            <goals>
              <goal>upload</goal>
            </goals>
            <configuration>
              <fromDir>${project.basedir}/target/${project.artifactId}-${project.version}/</fromDir>
              <includes>*</includes>
              <toDir></toDir>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

我正在使用 Eclipse 3.7,当我使用 Run As -> Maven Install 时一切正常,但我想启动部署阶段以将所有内容上传到我的 ftp 服务器。我如何配置 Eclipse?我的 POM 现在对这个任务是正确的吗?

于 2012-06-09T16:38:59.803 回答