aspose file tools*
The moose likes Ant, Maven and Other Build Tools and the fly likes New to ant - Compilation failure Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "New to ant - Compilation failure" Watch "New to ant - Compilation failure" New topic
Author

New to ant - Compilation failure

Kavita Ghia
Ranch Hand

Joined: Oct 10, 2000
Posts: 91
Hi,

I have the following code in my build.xml file

<?xml version = "1.0"?>
<project name="kavitaexamples" basedir ="." default = "init">
<target name="init">
<delete dir="classes"/>
<mkdir dir="classes"/>
</target>
<target name="compile" depends="init">
<javac src="." destdir=".">
</javac>
</target>
</project>

I have my hello.java file in the current directory.

The build is successful, however the hello.class file in not created in the current directory. Only classes folder gets deleted & recreated.
Please guide me as to where I am going wrong.
James Sabre
Ranch Hand

Joined: Sep 07, 2004
Posts: 781

You need to tell it which files to compile. For example
will compile all Java files in the current directory and place the result in the directory 'classes' relative to the current directory.


Retired horse trader.
 Note: double-underline links may be advertisements automatically added by this site and are probably not endorsed by me.
Kavita Ghia
Ranch Hand

Joined: Oct 10, 2000
Posts: 91
HI,

I could resolve the problem as under:



Is there a better way of copying the webapp files into tomcat? Would appreciate any pointer.

Thanks,
Kavita
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5827
    
    7

I follow the mechanism used by Maven, even when doing builds in Ant. Basically, I do this:

1) Compile the java source files
2) Copy all of the files that make up the WAR into a directory (this is an exploded WAR)
3) Convert the directory in step 2 into a WAR file
4) Copy either the exploded WAR from step 2 or the WAR file from step 4 to Tomcat

I recommend you study Maven to see how it does this, and even if you decide not to go with Maven, follow its basic build steps (and follow its directory structure).


JBoss In Action
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: New to ant - Compilation failure