Solved

using ant for compiling java files

Posted on 2004-08-16
4
189 Views
Last Modified: 2012-05-05
i have java files in many packages. Such as
com\pack1\pack2\pack3\ (java files here)
com\pack1\pack2\ (java files here)
com\pack1\ (java files here)
.....
com\a\b\c\(java files here)
com\a\b\(java files here)
..

I have to give an option to the end user to compile the source files(if she ever wants to do so). So I asked this ques in EE that how can i do this without using many javac statments and putting them in a batch file. i was suggested that i should use ant.
Now I have managed to compile the source files using ant and copy other files(such as xml, xsl, jar etc) to the target directory. I do this by  first navigating to the ant folder(which has build.xml file) and writing ant there. It compiles all those java files and puts them in build directory along with other needed files.
What i want to know is how can i make the end user use this. Do i have to tell her to install ant, copy build.xml file there and the source dir and navigate to it and write ant or is there a better way of doing this?
Thanks

0
Comment
Question by:thomas908
  • 2
4 Comments
 
LVL 8

Author Comment

by:thomas908
ID: 11807849
here is my build.xml

<?xml version="1.0"?>

<project name="My" default="compile" basedir=".">
<property name="name" value="My" />
<property name="build" value="${basedir}\build" />
<property name="source" value="${basedir}\source\src" />
<property name="baselib" value="\source" />

<target name="init" >

     <mkdir dir="build" />

</target>

<target name="CopyFiles" depends="init">
    <copy toDir="build">
      <fileset dir="source"
        includes="**/*.*">
        <exclude name="**/*.java"/>
      </fileset>
    </copy>
</target>



<target name="compile" depends="CopyFiles" >
    <javac srcdir="${source}" destdir="${build}">
    </javac>
</target>



</project>
0
 
LVL 35

Assisted Solution

by:girionis
girionis earned 125 total points
ID: 11807887
If you bundle all the files together then you can specify default folders for your ant scripts. These folders should be relative to where you install ant otherwise the user would have to use absolute paths and this is not recommended.
0
 
LVL 6

Accepted Solution

by:
expertmb earned 125 total points
ID: 11807894
>>Do i have to tell her to install ant,
yes user has to have ant installed in their system to run the ant.

>>copy build.xml file there and the source dir and navigate to it and write ant or is there a better way of doing this?

copy entire src in zip format. user will extract it, the folder will be created as per your dir structure.
after installing ant she has to run the ant command.

another way is to write the installation document. i feel this is a good option.

mb...
 
0
 
LVL 35

Expert Comment

by:girionis
ID: 11838520
:)
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
The viewer will learn how to implement Singleton Design Pattern in Java.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now