• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Web Development Environment Best Practices With Ant

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi-
This is something that I've struggled with for a while, and never really knew the best practice is.
If you are using ant to build a web app with the WAR task, how do you structure your directory layout in version control?
the WAR task prefers that there is no existing WEB-INF dir. It will pull in all the assets you specify (DD, web libs) and create the entire nested thing for you.
This works fine in creating a war, but makes for a difficult development environment setup. Since there exists no deployable directory on the filesystem, a new build is required with every single change, even to static html/js/images. This is very frustrating, esp. to the front-end folks who are afraid of build tools like ant ;)

What does everyone else do?

I have been using a workaround - I create a target named "explode" which will manually create a WEB-INF dir, but this seems like a bit of a kludge. It also introduces the possibility of a file mistakenly being added to version control.
 
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I personally used to structure my code in the layout of a standard WAR, but then I saw the light and swapped to Maven ;)

Back onto the topic, this thread may help a little

Another option is to have a prepareWar target which copies what you need into a staging directory structure that your subsequent War task can utilise, that way your source code layout can be what you like.
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I keep a build directory in the project and the exploded WAR is (usually) a subdirectory of the build directory. The non-code items that have to be copied in typically come from a subdirectory of a top-level project directory I name etc. I also store general config information, database scripts, etc. in the etc directory. The build directory is not under version control, so one of the things that my Ant project is expected to be able to do is construct a totally new exploded WAR from scratch, by compiling and copying in accordance with the Ant script.

Lately, I've been doing more with Maven, however.

Just for info, I'm one of those people who build extensive property definitions into my Ant build.xml for things like the source directory, output classes directory, build root, exploded WAR - just about any directory or file. It's slightly more work bu it makes it very easy to do specialized builds such as an experimental build to an alternate external build directory.
 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I also prefer the Maven way, with the resources (web.xml, JSPs, CSSs, GIFs, etc) for the webapp in the src/main/webapp/ directory (and subdirectories), and the "exploded, compiled WAR" in the target/app-name/ directory. Though for the source code for JBoss in Action we used a slightly different directory structure that I prefer - the compiled war directory is at target/app-name.war/, and the WAR file, built using the 'jar' task and not the 'war' task, is located at target/dist/app-name.war. This makes it easier to deploy either the exploded directory or the war file.

Disclaimer: that above are not official best practices, but rather merely reflect what I do.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic