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.
Related
I'm relatively new to using build files and Ant to compile and execute from a command line so i wanted to know how it would be possible to modify the build-impl.xml file auto generated from netbeans so that after it compiles it also executes the program.
Currently when i type just "ant" in the command window where the build.xml file is listed it compiles and etc but then says
-do-jar-copylibs:
[copylibs] Nothing to copy.
[echo] To run this application from the command line without Ant, try:
[echo] java -jar "C:\Users\Eric\Documents\Word Documents\Java Test Code\NetbeansVersion\Cops\dist\Cops.jar"
I can run that command and it will run fine, but i want the program to execute by just typing ant.
The build.xml file - Pastebin
Build-impl.xml file - Pastebin
There are a couple "tasks" available in ant that you could use to accomplish this.
You can use either of these:
Java Task,
Exec Task
Those documentation pages provide examples as well. Before you go there though, you might want to start at the basic manual to get an idea of the structure of an ant build file to determine where and how you want to add this execution step in.
It feels a little "off" to me to have your build script executing the program, but I'm sure you've got a reason, so I might suggest adding a new target that does the build steps and then also runs this command to kick off the program. That way you've still got the option of running the build without running the program.
I have tried to run a example from the website http://confluence.highsource.org/display/J2B/Annotate+Plugin#AnnotatePlugin-Activation. The very first schema provided in the webpage and I saved it as schema.xsd under c:\jaxb folder. Then, I ran the command 'xjc -extension schema.xsd' from command prompt and I get the similar error. Apparently xjc doesn't seem to understand this url http://annox.dev.java.net. How do I solve this?
You have to add the annotate plugin with all the dependencies to the classpath. See this Ant build file for what dependencies are
You have to activate the plugin using -Xannotate switch
Here's a sample Ant project. I'll assemble a command-line example for the next version.
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 am using Apache Ant scripts for building a web application. I have written some targets in the build.xml file and the script is running fine. I remember using just "build" command to run ant build instead of "ant build". Can anyone tell me how is that achieved? I was a bit curious on this.
There's no built in "build" command. You could create a simple script file called "build" in the same directory that launched the ant build.
Create a text file with this as the contents:
ant build
In windows save this as a file called build.bat then you can just type build from the command line to start your build.
On unix or linux, save the file as build, then make it executable (with chmod +x build). You'll need to type ./build to get it to run.
I don't think there's a lot of value doing this to replace the simple case of ant build, but if you have to regularly run a build that has multiple targets, or need to pass in certain system variables then it could come in useful.
Maybe your are remembering typing "ant" instead of "ant build" in the past. This is possible to setup. You just need to set default attribute on the root project element in your Ant script to the name of the target you want invoked when an explicit target isn't specified.
For instance...
<project name="myproj" default="build">
...
</project>
I'm trying to pass a -lib argument to ant as part of an automated build using Hudson but can't see a way to do this. I could add the relevant libraries to the ant/lib folder but that would then mean the same version of the library necessarily being shared by all builds on that machine.
Any help much appreciated.
In your Hudson job configuration you can specify ant arguments such as -lib in the Targets field. See the help message that opens when you click the ? next to the Targets field.