wood burning stoves 2.0*
The moose likes Ant, Maven and Other Build Tools and the fly likes Problem with Ant Build Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Problem with Ant Build" Watch "Problem with Ant Build" New topic
Author

Problem with Ant Build

Ashok Kumar Babu
Ranch Hand

Joined: Jul 25, 2006
Posts: 129
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 ]

Ashok<br /> <br />SCJP 91%<br />SCWCD 88%
Edwin Dalorzo
Ranch Hand

Joined: Dec 31, 2004
Posts: 961
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

Joined: May 05, 2006
Posts: 39
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


Regards, Rudra Narayan
www.garnaik.com
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem with Ant Build
 
Similar Threads
Unchanged files get compiled. Why?
NoClassDefFoundError
how to tell ant that some packages are needed?
Could not parse configuration: /hibernate.cfg.xml
could not find the main class