Defining the path class for ant built-in tasks

I use the classpath attribute in custom Ant tasks to tell Ant where to find the external task container, but how can I do the same for inline tasks?

In my case, I would like to make sure that Ant uses my copy of jsch.jar for the scp task, and not the one that is already installed on the system. Is there a way I can <scp> guarantee this with jsch.jar?

+4
source share
3 answers

If your ant call uses $ANT_HOME , you can only use the ant value ANT_HOME for the custom ant installation for this ant, where you make sure your $ANT_HOME/lib contains the correct copy of ant-jsch.jar .
See this SO question for more details.

+1
source

I think the best way to do this is to define your own task instead of messing with predefined tasks.

 <taskdef name="myscp" class="..." classpath="jsch.jar"/> <myscp .../> 
+1
source

I had the same problem, and here is what I did: use the Google Jar Jar to change the package names. Here, build.xml I used:

 <project name="Admin WAS Jython" default="jar"> <target name="jar" > <taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask" classpath="jarjar-1.0.jar"/> <jarjar jarfile="dist/ant-jsch-copy.jar"> <zipfileset src="ant-jsch.jar"/> <rule pattern="org.apache.tools.ant.taskdefs.optional.ssh.**" result=" org.apache.tools.ant.taskdefs.optional.ssh.copy.@1 "/> </jarjar> </target> 

Then in the ant project, use the following:

 <taskdef name="scp2" classname="org.apache.tools.ant.taskdefs.optional.ssh.copy.Scp" classpath="ant-jsch-copy.jar;jsch-0.1.43.jar"/> 

and use scp2 task instead of scp

+1
source

Source: https://habr.com/ru/post/1305423/


All Articles