In eclipse, I can tell my external ant tool to run with stuff in the classpath.
If i want to run ant from the command line, how would i do that?
For argument's sake, the classpath i want to add is c:\some\folder\here\hooray.jar
Use the -lib argument. From the Ant docs on this page:
Additional directories to be searched may be added by using the -lib option. The -lib option specifies a search path. Any jars or classes in the directories of the path will be added to Ant's classloader.
Related
I want to use Listeners&Loggers in my script build.xml
I have seen the suggested method, but it is on cmd -logger org.apache.tools.ant.listener.ProfileLogger
Also gone through groovy method, but is there any other way I can specify Listeners&Loggers in my script.
Thanks
RSA is built on Eclipse. Both let you select an Ant builder for a project. Which gives you all the Ant options including a command line.
I have a complex build system involving many ant scripts, some targets of which invoke the javac task.
These ant scripts do not provide for a way to request a debug build from javac, i.e. neither debug nor debuglevel parameters of the javac task are specified.
Is it still possible to instruct javac to build with debugging support without changing the build scripts themselves?
The scripts are invoked from console.
The short answer is no unfortunately :(
Are the Ant scripts invoking javac by calling an external executable, i.e., is fork=true? If so, you could try putting a wrapper script named javac earlier in the $PATH. A tool like strace could show you exactly how javac is being invoked.
On Unix it could look something like this:
echo '#!/bin/bash
exec /usr/bin/javac -g "${#}"' > ./javac
chmod +x javac
PATH=".:${PATH}" ant build
If Ant is invoking the Java compiler in-process, you can make an edited version of Ant's javac task class that defaults to having debugging turned on, and put this earlier than the official Ant jar in the classpath when invoking Ant.
i have never seen this strange -
i am into maintenance project where i got a build.xml and i never installed ant. ant is bundled into the project and so i use -
ant deploy_project.
but when i look at build.xml i cannot find any target named "deploy_project".
can anyone help me how the "deploy_project" target gets executed without this target being present in build.xml?
I suspect that since i didn't install ant by myself and is bundled with the project, any configuration of ant may have been overridden...but how to find it is where i am stuck, can any one pls help me?
(I am sure the target isn't present in build.xml).
thanks much in advance.
Run the following command:
$ ant -p
This will usually print out all the targets in your build.xml. Or at least the ones with descriptions.
Also look for <import file="..."> statements in your build.xml. These allow you to import other Ant build files which can contain targets that aren't in your build.xml. I suspect, if you do a search for the string deploy_project in your build.xml, and you can't find a target by that name, you have an import statement somewhere in your build.xml, so search for <import.
If you are SURE that the target is not present, and you are not specifying the build file with -f option, then only 1 explanation I can think of -
your ANT_HOME is somewhere else and there will be another build.xml there.
(Quickest way to check is find it - SET for Windows echo $PATH for Unix), find the value for ANT_HOME and in the same directory, a build.xml will be present with your *INVISIBLE* target
If you have searched the C: drive and still cannot find any build.xml, then the bundled ANT you have might be a customized one or an ANT wrapper. Meaning have a .bat file called ant.bat which accepts deploy_project as an argument and then maps it to another task using variable substitution. So look for a batch file ant.bat or anything titled ant.
I have a build script that requires the -lib command line switch like so:
ant -lib lib/jsch-20101122.jar ....
This works fine, but I'd like to include that command line argument as part of my build.xml file and make my build cleaner.
I'd prefer not to include this jar in my ANT_HOME/bin directory.
Is there any way to do it?
I assume, that you want to use the scp-task (http://ant.apache.org/manual/Tasks/scp.html)
The official doc (http://ant.apache.org/manual/install.html#optionalTasks) for optional Tasks offers no real alternative (you may want to look at the CLASSPATH alternative, though).
The scp-task does not seem to have a classpath setting.
I have configured Log4j in my project and that is invoked by an Ant task.
I want the Ant logs as well as project logs to be written to single file along with timestamps.
Could you let me know how to take care of this in Ant?
You can run Ant in such a way that it's logging is via Log4j, there's an example in the Ant Listeners & Loggers page:
ant -listener org.apache.tools.ant.listener.Log4jListener
but see the Ant documentation for proper details, how to ensure log4j.properties etc. are found.