Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

New to ant - Compilation failure

 
Kavita Ghia
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 781
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
Kavita Ghia
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic