2010/04/28

Deploying WAR Locally and Remotely (via scp)

Tried to run ant scp from maven and got weird class org.apache.tools.ant.taskdefs.optional.ssh.Scp was not found, even when you have all the ant-jsch and jsch jar files in ant lib directory ? Try to add ant-jsch as plugin's dependency in maven:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
         <modelVersion>4.0.0</modelVersion>

  <groupId>org.bithill.project</groupId>
  <artifactId>project-artifact1</artifactId>
  <packaging>war</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>Example project</name>

  <description></description>

  <dependencies>
  </dependencies>

  <build>

    <plugins>
      <plugin>

        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <phase>package</phase>
            <configuration>
              <tasks>
                <copy
                 file="target/${artifactId}-${version}.war"
                 todir="local_deolpy_dir_name" />
                <scp
                 file="target/${artifactId}-${version}.war"
                 todir="login:password@remote_host_name:remote_deploy_dir_name" />
              </tasks>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>

        <dependencies>
          <dependency>
            <groupId>org.apache.ant</groupId>
            <artifactId>ant-jsch</artifactId>
            <version>1.8.0</version>
            <scope>provided</scope>
          </dependency>
        </dependencies>
        
      </plugin>
    </plugins>

  </build>

</project>