Loading JSCH Library from local lib directory in ant build.xml - ant

I can do SCP task while i add jsch-0.1.44.jar to ant/lib directory.But i want to load from the local lib dir and add it to classpath.Could you please help

The built-in tasks have limited options for customizing the classpath.
1) Place your custom jars in the ${user.home}/.ant/lib directory
/home/mark/.ant
└── lib
├── ivy.jar
└── jsch.jar
This is where I install jars that are my personal extensions to the standard ANT distro
2) Supply the location of the jar directory on the commandline
ant -lib /path/to/jsh/jar
3)
You could try to declare a new task as recommended here:
specifying classpath for built-in ant tasks

Related

Download dependencies from Ivy.xml

I have an ant project with ivy dependencies in it. Unfortunately my Intelij IDEA does not understend ivy dependencies. But ant builds project well. I want to download all dependencies to one folder and add jars explicitly to project.
How can i download all dependencies automatically?
As described here http://ant.apache.org/ivy/history/latest-milestone/ant.html
During ant build ivy dependencies downloads to "cache". If i'll found this cache path i can took jars from there.
Look at what ant is doing. If its a well written ant script you'll find (do an ant -p -v) targets specifically for retrieving the ivy dependencies. Also you may inspect the build.xml and watch out for retrieve tasks probably in the ivy namespace.

Maven Assembly Plugin and Executable jar

I'm able to successfully build the Maven assembly plugin in my project and generate a jar file with all the needed dependencies. But now I also want to instruct Maven after building me the jar file with dependencies, go into the target folder where the jar file with dependencies is located and run my main program.
Should I consider looking into the Maven Exec Plugin for what I want to acheive?
Yes the exec-maven-plugin is the right choice. The question is if you like to start the assembled jar archive or just a java class with it's dependencies.

Apache Ant Build, jar with external librarys

i have a Apache Ant build.xml to create a simple executeable jar file, but this file is very big.
Now i have the idea to build a executeable jar file with my code and have a directory named "lib" with all external jar files.
I think this will reduce the size of my application to 3%.
Thanks for your help.

cannot be found: com/jcraft/jsch/UserInfo

I am trying to use the Ant <scp> task in my buildfile. It gives me an error every time I run the target:
cannot be found: com/jcraft/jsch/UserInfo
I have read some posts that talk about having this issue with Ant 1.7. Some of the posts are talking about removing the ant-jsch.jar files from the ant_home lib. Unfortunately I can't do that as the ant_home is common across lot of other projects and I can't remove or update any jar files from the lib directory.
Is there a way that I can solve this issue purely using Ant configuration?
ant-jsch.jar contains ssh related tasks developed by Apache Ant team, while jsch.jar contains the jsch library which is the dependency of those ssh tasks.
So do a little check: check if jsch.jar is in your $ANT_HOME/lib and also check if the jar contains UserInfo.class.
If one of above happens, download the latest version of jsch.jar and put it in $ANT_HOME/lib.
I am currently using Ant 1.8.4 with a jsch.jar downloaded last year without any problem.
Update:
Check this page first:
http://ant.apache.org/manual/install.html#optionalTasks
Please note that <scp> and other ssh tasks (the ant-jsch.jar) are included in the Ant binary distribution by default. You don't need to write <taskdef> to use <scp> because it is included in Ant's lib directory by default. I recommend you to put jsch.jar in that directory with the following points:
These ssh tasks don't support classpath def, that is to say, you can't define a <classpath> pointing to jsch.jar and then reference to it in an ssh task.
Also you can put jsch.jar in any directory included in your system's CLASSPATH environment variable, but it is not a good practice.
We usually put a task and its dependency in the same directory.

Is there an easy way to use an OSGi bundle in a classpath for Ant junit or java tasks?

I have a bunch of OSGi bundles that are basically jars that contain other jars and a manifest.
bundle xyz.jar:
somejar1.jar
somejar2.jar
Manifest
I want to run some junit tests, and need some classes inside these bundles. Is there an easy way in Ant to say
<path name="myclasspath" location="[stuff inside OSGI bundle xyz.jar]> ?
I could unjar these to a temp directory, but that seems tedious, plus I would not be leveraging the classpath inside the OSGi bundle.
It should not a problem if you're using ant to run PDE build/OSGi application, OSGi would handle with the classpath.

Resources