Avatar of ams7503
ams7503

asked on 

Ant Script Help

Hi ;

I need help with ant script. I have a build.sh and go.sh that I created and would like to use ant instead,build compiles
the code and go runs it
build.sh:
 if [ -d "bin" ]; then
        echo "removing old bin"
        rm -rf bin
fi
echo "creating new bin"
mkdir bin
echo "compiling java"
javac -d ./bin -classpath ./etc:./lib/log4j-1.2.9.jar:./lib/log4j.properties src/com/sigma/amster/matcher/DomParser.java
 src/com/sigma/amster/matcher/documentRecord.java src/com/sigma/amster/matcher/matchData1.java
echo "copying contents of etc to bin"
cp etc/* bin

go.sh- this runs the code:
java -classpath ./lib/log4j-1.2.9.jar:./lib/log4j.properties:bin:etc com.sigma.amster.matcher.matchData1,where matchData1.java

I am trying to use ant for the above,compile the code and then run it. I have not used ant before and hence need some help.
Thanks in advance
Java

Avatar of undefined
Last Comment
ams7503
ASKER CERTIFIED SOLUTION
Avatar of contactkarthi
contactkarthi
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of ams7503
ams7503

ASKER

thanks for the info. I wasn't expecting anyone to write a script for me, perhaps a few examples or resource where I could quickly start :)
just let me know if you are held up or have a question..
Avatar of Mayank S
Mayank S
Flag of India image

The second link should be enough.
Avatar of ams7503
ams7503

ASKER

Hi;
Thanks for the info. I have a general idea of what is to be done and have a bit of touble putting it togethere.
I know I will have atleast 2 targets,one for compile and one for run.To that end I have the following:

<project name="matchTool" default="compile" basedir=".">

<!-- ==================== File and Directory Names ======================== -->

   <property name="build.home"    value="${basedir}/bin"/>
  <property name="src.home"      value="${basedir}/src"/>

<!-- ==================== Compile Target ================================== -->

  <target name="compile" description="Compile Java source">
  <!--Compile Java classes-->
  <javac srcdir="${src}" destdir="${dest}"/>
  </target>


<!-- ====================Run Tool ========================== -->
<target name="run" description="Run the Tool" depends="compile">
<!-- Run Java class-->
<java fork="true" classname="matchData1"/>
</target>
</project>
How should I include the full path for the src and destination?Also,javac needs to know the classpath- how is that taken care of?Please help















Avatar of Mayank S
Mayank S
Flag of India image

Use this for writing the build-file - http://ant.apache.org/manual/using.html

Classpath etc are also discussed there
Avatar of ams7503
ams7503

ASKER

while setting the properties,src and build- should the full path be given?
My source code lies in src/com/sigma/amster/matcher/matchData1.java,domParser.java.
Should the property for src be
<property name="src.home"      value="${basedir}/src"/>
or
<property name="src.home"      value="${basedir}/src/com/sigma/amster/matcher/">
Avatar of Mayank S
Mayank S
Flag of India image

Only uptil src
Avatar of ams7503
ams7503

ASKER

Thanks all for your help,I think I have a good understanding of ant,now.However, my problem is - I downloaded ant and setup.Added ANT_HOME to my .tcshrc.Should I include it to my classpath?How does it know where to find ANT?Should it be added to path?
Java
Java

Java is a platform-independent, object-oriented programming language and run-time environment, designed to have as few implementation dependencies as possible such that developers can write one set of code across all platforms using libraries. Most devices will not run Java natively, and require a run-time component to be installed in order to execute a Java program.

102K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo