maven antrun plugin을 통해 ant의 scp 타스크를 이용하여 파일을 전송하기 위해 딸랑 jsch 라이브러리만 의존성에 추가하면 scp 타스크가 없다고 에러가 떨어진다. 

   <plugin>
    <artifactId>maven-antrun-plugin</artifactId>
    <executions>
     ... ...
    </executions>
    <dependencies>
     <dependency>
      <groupId>com.jcraft</groupId>
      <artifactId>jsch</artifactId>
      <version>0.1.38</version>
     </dependency>
    </dependencies>
   </plugin>

jsch 뿐 아리나 ant-jsch 아티팩트도 antrun 플러그인 의존성에 추가해야 한다. maven을 통하지 않고 순전히 scp작업을 build.xml에 정의해서 ant로 실행하면 jsch 라이브러리만 ant에 추가해주면 된다. ant-jsch.jar는 이미 ant에 포함되어 있기 때문이다.

   <plugin>
    <artifactId>maven-antrun-plugin</artifactId>
    <executions>
     <execution>
      <id>remote-exploded-deploy-scp</id>
      <phase>integration-test</phase>
      <goals>
       <goal>run</goal>
      </goals>
      <configuration>
       <tasks>
        <scp todir="user:user@myserver:/home/user/temp" trust="true">
         <fileset dir="${project.basedir}/temp" />
        </scp>
       </tasks>
      </configuration>
     </execution>
     <execution>
      <id>server-restart</id>
      <phase>integration-test</phase>
      <goals>
       <goal>run</goal>
      </goals>
      <configuration>
       <tasks>
        <sshexec host="myserver" username="user" password="user" trust="true"
         timeout="20000" failonerror="false" command="sh restart.sh" />
       </tasks>
      </configuration>
     </execution>
    </executions>
    <dependencies>
     <dependency>
      <groupId>org.apache.ant</groupId>
      <artifactId>ant-jsch</artifactId>
      <version>1.7.1</version>
     </dependency>
     <dependency>
      <groupId>com.jcraft</groupId>
      <artifactId>jsch</artifactId>
      <version>0.1.38</version>
     </dependency>
    </dependencies>
   </plugin>

마찬가지로 ftp 타스크를 쓸 때도 commons-net 뿐 아니라 ant-commons-net도 추가해주어야 한다.

   <plugin>
    <artifactId>maven-antrun-plugin</artifactId>
    <executions>
     <execution>
      <id>remote-exploded-deploy-ftp</id>
      <phase>integration-test</phase>
      <goals>
       <goal>run</goal>
      </goals>
      <configuration>
       <tasks>
        <ftp server="myserver" remotedir="/home/user/temp" userid="user"
         password="user">
         <fileset dir="${project.basedir}/temp" />
        </ftp>
       </tasks>
      </configuration>
     </execution>
    </executions>
    <dependencies>
     <dependency>
      <groupId>org.apache.ant</groupId>
      <artifactId>ant-commons-net</artifactId>
      <version>1.7.1</version>
     </dependency>
     <dependency>
      <groupId>commons-net</groupId>
      <artifactId>commons-net</artifactId>
      <version>1.4.1</version>
     </dependency>
    </dependencies>
   </plugin>
Posted by 에코지오
,