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.
Related
I have a project with different modules bundled into each others.
We build with ant and I have no problem running the Ant build inside Intellij if I provide the path to the generic build files through a property (repository.dir : C:/myRepositoryFolder).
Similarly, I have no problem running my ant build in command line given I have set my environment variable ANT-OPTS with -Drepository.dir=C:/myRepositoryFolder
However, Intellij does not know where to find this folder and therefore the inspection 'Ant inspections / Ant references resolve problems' blow off on most of my build.xml.
Does anybody know where I can show Intellij where to find this folder without modifying my existent build.properties?
Thanks in advance!
I tried several ways to install ant and junit on the same server as hudson. I eventually downloaded the Ant source, installed the optional dependencies by using the included fetch.xml file, built the source code, and dropped junit-4.8.1.jar into the lib directory where the compiled ant code [that I just built] is. Then I set ANT_HOME to the ant root directory by using the "export ANT_HOME=/usr/share/ant" command. I also set a Hudson configuration variable of "ANT_HOME" with the same value (/usr/share/ant) and I also put a new file into the /etc/profile.d directory with the export ANT_HOME command as well. At this point I'm not sure what else to try, but Hudson still gives me the error:
BUILD FAILED /var/lib/hudson/jobs/MyProject/build.xml:31: Problem:
failed to create task or type junit Cause: the class
org.apache.tools.ant.taskdefs.optional.junit.JUnitTask was not found.
This looks like one of Ant's optional components. Action: Check that the appropriate optional JAR exists in
-/usr/share/ant/lib
-/var/lib/hudson/.ant/lib
-a directory added on the command line with the -lib argument
Do not panic, this is a common problem. The commonest cause is a
missing JAR.
This is not a bug; it is a configuration problem
I did, in fact, check /usr/share/ant/lib and the class "org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.class" is located in the ant-junit jar file as I confirmed by running the command: jar tfv ant-junit.jar | grep org.apache.tools.ant.taskdefs.optional.junit.JUnitTask
Can someone please tell me what to try, I am not sure where to go from here.
If you are on Ubuntu you can simply apt-get ant; I did that and linked to the junit jar within my project.
Cheers,
Neil
It turns out that hudson itself installs some version of Ant in one of its own libraries. I suppose that somehow caused a conflict because when I got rid of it, things worked. I think it is in /var/hudson or /var/hudson/lib. That path is added to the PATH environment variable during hudson installation. So your choice is either to add your own Ant install to the BEGINNING of the path, to delete hudson's version of Ant, or to delete that part of the PATH.
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 having problems building my project, using an Ant script, from the command prompt using Ant itself. It can't find a certain import for a particular Java file in my project (which has nearly 5,000 source files as it is). The import is included in a .jar package whose location I have set in the Ant file itself. (As a pathelement, along with other needed JARs that either are fine, or haven't tried to been used when the crash occurs). The crash happens with javac, with the simple message of "import etc.ect.* cannot be found at line etc" Oddly enough, I can build the project just fine from the Ant file using an IDE like Eclipse. Any ideas what could be wrong? Thanks!
Wow, the solution was completely unrelated. It was a dumb fault in the java code where the class was trying to import .* from a directory that only had folders in it. For some reason, Eclipse didn't seem to mind, but javac did!
Eclipse's root classloader contains a lot of classes, when you run ant from console there's much less.
Just tell javac task to use the required .jar, and you'll be fine.
You should post the stack trace, does it say "import required by ..."? ( I forget the exact text). Likely there's a jar that's available in your eclipse environment that is not included in your ant script. Look in the stack trace for the missing class to identify the jar that's not being included in your build.
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.