Installing Ant on Cygwin - ant

I'm having some trouble figuring out how to install Ant on Cygwin. I want to use Ant to build Nutch. I've looked through a bunch of tutorials but I can't find anything that is low level enough for me to understand. I need something like...
Download ant, put it here
Open Cygwin
type "export ANT_HOME=..."
...
Can anyone help me out here?

Assuming you have a JDK already installed, you can do this:
$ export ANT_HOME=/cygdrive/c/apache-ant-1.7.1
which assumes you've unzipped Ant into C:\apache-ant-1.7.1. Then:
$ export PATH=$ANT_HOME/bin:$PATH
$ ant -version
Apache Ant version 1.7.1 compiled on June 27 2008

In Windows, add the path to your ant /bin directory to the Path system variable. This can easily be done by right clicking on Computer > Properties > Advanced System Settings > Environment Variables, click on Path in the System Variables, click on Edit and add ; followed by the path to your ant bin directory to the end of the Variable value.
Start or restart Cygwin.
Type ant -version The version should be displayed.

Here's a step-by-step guide:
simply download and unzip ANT binaries say into c:\apache-ant-1.8.1
download and unzip NUTCH sources say into: c:\apache-nutch-1.2
open the command prompt and run the following:
cd c:\apache-nutch-1.2
c:\apache-ant-1.8.1\bin\ant
the same would work from the Bash shell, just use Cygwin-style paths:
cd /cygdrive/c/apache-nutch-1.2
./cygdrive/c/apache-ant-1.8.1/bin/ant
That's it, you will find a new directory build containing the output.
For convenience, you might want to add the Ant bin directory to the PATH environment variable so that you don't have to give the full path each time, but that's optional.
BTW I just did those exact steps, and all went fine.
Finally, follow this tutorial to get started.

Related

Install gradle on Centos

I'm trying to install gradle for building android app with the help of Jenkins. But I'm not able to find the link to download gradle for Centos. I tried to use binaries from https://gradle.org/downloads/, but when I unzipped I got gradle.bat file inside bin directory which tells me that this is for Windows.
Is there a place where I can download gradle for using in Jenkins?
... but when I unzipped I got gradle.bat file inside bin directory which tells me that this is for Windows.
It also contains a file called gradle, which is a shell script.
Your download is also suitable for running on any Linux or UNIX platform .... including CentOS.
Please add the GRADLE_HOME path to the PATH variable by using following steps:
echo $PATH
Copy the echoed paths and add the GRADLE_HOME path e.g.: /opt/gradle/bin to the PATH variable using a colon (:) using command: export PATH = echoed paths:GRADLE_HOME path
Now, you can use the command gradle from any path and it should work.

How can I run WebDriver script using Ant?

I'm new to WebDriver. I have created data driven framework for Google calculator, Search, Sign in and sign up functionality with JUnit lib.
I want to run my script using Ant.
Below is the configuration for my environment:
OS: win8
Selenium-server-standalone-2.38.0.jar
Junit 4
Apache Ant 1.7
Please help.
Here are the steps to run it via ANT:
Check that you have ant installed in your system, properly. Open Command Prompt and type ant, if you have it installed perfectly it print in command prompt build.xml doesn't exist and/or Build failed
But if none of above messages displayed you need follow below steps:
1.1 Right Click My Computer icon and go to properties
1.2 Go to Advanced System Settings >> Advanced tab >> click Environment Variables under Start up and recovery
and create a new variable ANT_HOME and give ant directory path to it
1.3 Edit Path variable and add ant's bin directory path to it (do not add/remove path already present in their)<>See pictures below to set it properly:>
Once point one is done, go to your project's directory and open command prompt there (shift+right click will give option to open command prompt in working directory).
Now type ant "target name in your build.xml" example: ant run
Assuming you are aware of Ant you can run it through build.xml file.

"JUnitTask was not found" error (Hudson, Ant, JUnit)

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.

Can not compile Nutch1.4 with ant

all
I'm trying to deploy Nutch1.4 to Hadoop cluster(following this page). I got some problems when compiling Nutch with ant.
problem 1
When I run ant command, I got the following error:
/home/xenserver/apache-nutch-1.4-bin/build.xml:71: invalid Date syntax in "01/25/1971 2:00 pm"
I remove attribute "datetime" from line 71 in file build.xml and run ant again. Then I got another problem.
problem 2
The error is:
/home/xenserver/apache-nutch-1.4/build.xml:412: syntax errors in ivy file: java.text.ParseException: http://java.sun.com/xml/jaxp/properties/schemaLanguage in file:/home/xenserver/apache-nutch-1.4/ivy/ivy.xml
at org.apache.ivy.plugins.parser.xml.XmlModuleDescriptorParser$Parser.parse(XmlModuleDescriptorParser.java:273)
........
What's wrong with the steps above? Is there any tutorial for compiling Nutch1.4?
Need your help.Thanks in advance.
For compiling nutch 1.4, all you have to do is run ant clean deploy from the nutch directory. The output is created in the directory named 'runtime' with 2 folders: one for local mode and other one for cluster mode.
please check the date settings and ant installation on your machine. I think that is casing the issue. Also have you tampered/ edited /home/xenserver/apache-nutch-1.4/ivy/ivy.xml ? Please check that file too.
EDIT:
There is some problem with the build file when executed on your Linux box.
Check these out: this and this.
These are the things that you should verify on your setup:
java version and ant version : dont use old ones. get the latest ones or ones that are compatible with your nutch release. FYI: for nutch-1.4 I am using apache-ant-1.8.3 and java jdk1.6.0_18. This combination works perfectly fine with me.
Check that you have installed a JDK and not a JRE
Check if your JAVA_HOME environment variable point to the JDK. System PATH variable must have $JAVA_HOME/bin and $ANT_HOME/bin appended to it. ANT_HOME variable must point to the ant installation directory.
Can you successfully run normal ant targets on any other build files ? try out with small ant build file.
Still facing the same issue, run ant command with -v option. This will provide more information about the error faced.
eg.
ant -v clean deploy

How do I change the JAVA_HOME for ant?

I'm doing java work on a class server where I don't have root. Whenever I try to compile using ant, it points to the wrong directory (/usr/tomcat instead of /usr/tomcat/jre ).
One of the things we were told to do when setting up our user accounts was to add export JAVA_HOME=/usr/tomcat/jre to the .bashrc file. I don't know if that was supposed to take care of the problem but it doesn't seem to.
So, how can I change the JAVA_HOME property for ant but only for when I run ant?
EDIT:
echo $JAVA_HOME points to /usr/tomcat/jre
echo $JAVA_HOME\bin points to /usr/tomcat/jrebin
The problem is when I normally run ant I get this error:
Unable to locate tools.jar. Expected to find it in /usr/tomcat/lib/tools.jar
Buildfile: build.xml
compile:
[javac] Compiling 1 source file to /home/ejm244/build/classes
BUILD FAILED
/home/ejm244/build.xml:9: Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK
Total time: 0 seconds
You could create your own script for running ant, e.g. named ant.sh like:
#!/bin/sh
JAVA_HOME=</path/to/jdk>; export JAVA_HOME
ant $#
and then run your script.
$ chmod 755 ant.sh
$./ant.sh clean compile
or whatever ant target you wish to run
JAVA_HOME should point at where the JDK is installed not not a JRE.
So, if you type ls $JAVA_HOME what do you see?
if you do ls $JAVA_HOME/bin/ do you see javac?
If the first doesn't work then you don't have JAVA_HOME pointing at the right directory.
If the second doesn't work then you need to point JAVA_HOME at a JDK instead of a JRE.
Looking at the shell script for invoking ant, it is possible that the value for $JAVA_HOME set for your shell in .bashrc can be overridden in the files /etc/ant.conf, $HOME/.ant/ant.conf, and $HOME/.antrc. If you execute bash -x <path to ant script> it will emit debugging information which should help you track down where $JAVA_HOME is being overridden.
On my Windows 7 machine setting:
JAVA_HOME="C:\Program Files\Java\jdk1.6.0_18"
didn't work. But setting:
JAVA_HOME=C:\Program Files\Java\jdk1.6.0_18
worked.
There are 2 ways of changing the compiler:
export JAVA_HOME=/path/to/jdk before you start Ant.
Set <javac exectuable="/path/to/javac">
Another option would be to add a respective tools.jar to the classpath, but this is usually used if Ant is started from another tools like Maven.
For more details on these (or other) options of changing Java Compiler in Ant, see this article for example.
Set the env var:
JAVACMD - full path of the Java executable. Use this to invoke a different JVM than JAVA_HOME/bin/java(.exe).
Reference: http://ant.apache.org/manual/running.html
Though the environment variable JAVA_HOME set correctly, the ant may use the configured JRE within the each build.xml or any build files.
To check what version of the JRE the ant is using, right click on the build file -> select the build ant which displays the details about the tasks to choose etc, select the JRE which you want to use.
Its advisable to use the project level settings or just at the workspace level.
JAVA_HOME needs to point to a JDK home if you're trying to compile code. Check to see if '/usr/tomcat/jre/bin/javac' exists. I doubt it does.
If you don't have a JDK, then you can work around it by getting the ECJ (eclipse compiler) library, dropping it into '~/.ant/lib' and adding a system property to the command-line to use that compiler - check the Ant manual for details.
http://ant.apache.org/
Set the JRE in the project (project properties -> Java Build Path-> Libraries, typically last entry), or global default in preferences (Java->Installed JREs) to a JDK, not a JRE.
When using Bash just try this:
$ export JAVA_HOME=/usr/tomcat/jre
When running ant from the shell, you don't need to export JAVA_HOME first, which would set that variable for your current shell and all future commands, instead use
user#host:~# JAVA_HOME=/path/to/jdk ant targets
You will need to change JAVA_HOME path to the Java SDK directory instead of the Java RE directory. In Windows you can do this using the set command in a command prompt.
e.g.
set JAVA_HOME="C:\Program Files\Java\jdk1.6.0_14"
try with this:
/usr/sbin/update-alternatives --config java
java_home always points to the jdk, the compiler that gave you the classes,
and the jre is thw way that your browser or whatever will the compiled classes so it must have matching between jdk and jre in the version.

Resources