You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Christian Clauss <Ch...@ptv.de> on 2007/03/15 08:25:12 UTC

ant scp task in maven2

Hello everyone,

 

I need some help. I tried to include the Ant task scp in my Maven2 pom.xml
by defining "<taskdef name="scp" classname="com.jcraft.jsch.JSch" />" using
the maven-antrun-plugin. But it doesn't work "Embedded error: No public
execute() in class com.jcraft.jsch.JSch". If you want to start this task in
ant you simple have to copy the jsch-<version>.jar in your local ant/lib
directory and the scp task becomes available. What have I to do to get it
work in Maven2. I need this task to secure copy files from a local machine
to a remote linux machine.

Thanks for your help.

 

Greetings

Christian Clauss

 


Re: ant scp task in maven2

Posted by Kevin Jackson <fo...@gmail.com>.
Hi,

> I need some help. I tried to include the Ant task scp in my Maven2 pom.xml
> by defining "<taskdef name="scp" classname="com.jcraft.jsch.JSch" />" using
> the maven-antrun-plugin. But it doesn't work "Embedded error: No public
> execute() in class com.jcraft.jsch.JSch". If you want to start this task in
> ant you simple have to copy the jsch-<version>.jar in your local ant/lib
> directory and the scp task becomes available. What have I to do to get it
> work in Maven2. I need this task to secure copy files from a local machine
> to a remote linux machine.
>

I did this like so:
<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-antrun-plugin</artifactId>
				<executions>
					<execution>
						<goals>
							<goal>run</goal>
						</goals>
					</execution>
				</executions>
				<configuration>
					<tasks>
					<!-- read in build.xml -->
					<ant antFile="build.xml" target=""/>
					</tasks>
				</configuration>
			</plugin>

Then for the jsch stuff I used maven to manage it (downloading etc)
and then in the ant file I used an ant target to get the ant-jsch.jar
file and then used <taskdef> to define it - note that Ant hates having
a copy of the jar in your classpath and a copy in ANT_HOME/lib:

<target name="init">
		<!-- Sanity check for delegating classloader problems --> 		
 		<available property="ant-jsch.present" file="${ant.home}/lib/ant-jsch.jar"/>
 		<fail if="ant-jsch.present" message="Please remove ant-jsch.jar
from ANT_HOME/lib see [
http://ant.apache.org/faq.html#delegating-classloader ]"/>
 		
 		<path id="jsch.path">
 			<pathelement location="${src.tools.dir}/jsch/ant-jsch.jar" />
 			<pathelement location="${src.tools.dir}/jsch/jsch-0.1.24.jar" />
 		</path>
 		
 		<taskdef name="scp"
 				classname="org.apache.tools.ant.taskdefs.optional.ssh.Scp"
 				classpathref="jsch.path" />
 		
 		<taskdef name="sshexec"
 				classname="org.apache.tools.ant.taskdefs.optional.ssh.SSHExec"
 				classpathref="jsch.path" />
 		
 		<macrodef name="ssh-cmd">
 				<attribute name="command"/>
 				<attribute name="fail" default="true"/>
 				<sequential>
 					<sshexec host="${deploy.machine.address}"
port="${deploy.machine.ssh.port}"
 								username="root" password="${deploy.machine.root.user.password}"
 								command="@{command}"
 								failonerror="@{fail}" trust="true"/>
 				</sequential>
		</macrodef>
	</target>

Getting the repo is easy enough through ant ${user.home}/.m2/repository/...

And in your pom.xml you declare the dependency on ant and antjsch

Kev

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org