Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with Ant Build

 
Ashok Kumar Babu
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I am having a souce folder src.
Inside src I am having a package event
Inside event I am having a java file Event.java

package event;
public class Event{}

When I compile my java files using ant. Class files are created and in the class files the package declaration seems to be

package src.event;
public class Event{}

My question- Is it a problem with the build file? I have also added the build.xml below for you reference.


<project name="hibernate-tutorial" default="compile">

<property name="basedir" value="."/>
<property name="sourcedir" value="${basedir}/src"/>
<property name="targetdir" value="${basedir}/bin"/>
<property name="librarydir" value="${basedir}/lib"/>

<path id="libraries">
<fileset dir="${librarydir}">
<include name="*.jar"/>
</fileset>
</path>

<target name="compile">
<javac srcdir="${sourcedir}"
destdir="${targetdir}"
classpathref="libraries"/>
</target>
</project>


Thanks All
Ashok
[ July 25, 2006: Message edited by: Ashok Kumar Babu ]
 
Edwin Dalorzo
Ranch Hand
Posts: 961
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First, I must say that it is not necessary that you create the basedir variable.

Ant already contains a set of built-in properties and basedir is one of them. See about it here.

Now, that you want to do, I typically do it this way, and it works.

Look how I declare the basedir property in the project tag. You are missing that, and that could be causing you trouble.

Another important issue is that the build.xml file should be in the same directory where the src, bin and lib directories are.

In other words

project
|
x------src
|
x------bin
|
x------lib
|
x------build.xml



I hope this helps!
[ July 25, 2006: Message edited by: Edwin Dalorzo ]
 
Rudra Narayan Garnaik
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi am giving the link for a build file which is working fine.

Make a look over it.

http://www.geocities.com/rudra4_w/ANT.doc


Open the doc and see the build.xml written on the button of this file.

web page
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're really distributing a build.xml file as a DOC? You didn't want to provide it as a txt or even an XML file? I'm not trying to be rude, but doc files are of limitted use and may contain viruses.

Dave
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic