Maven ftp站点插件

时间:2012-05-31 17:37:57

标签: maven maven-plugin

我想将我的网站直接上传到我的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>

2 个答案:

答案 0 :(得分:0)

答案 1 :(得分: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>

当我使用Run As时,我正在使用Eclipse 3.7 - &gt; Maven以正确的方式安装所有内容,但我想启动部署阶段以将所有内容上传到我的ftp服务器中。 我如何配置Eclipse?我的POM现在对这项任务是否正确?