Skip to main content



      Home
Home » Language IDEs » ServerTools (WTP) » Best project structure for web app?
Best project structure for web app? [message #17726] Wed, 11 February 2004 19:19 Go to next message
Eclipse UserFriend
So far we've been mounting our eclipse project directory from tomcat.
This requires that the project contain a WEB-INF directory with
lib/classes/etc in it. Eclipse is set to compile into WEB-INF/classes,
and everything works.

Project/
doc/
src/ (eclipse source dir)
WEB-INF/
classes/ (eclipse generates into here)
lib/
web.xml
.cvsignore (with "classes" included)

But I would like to have a nicer project structure that looks like this:

Project/
doc/ (hand written docs)
src/ (java source)
lib/ (dependancies)
web/ (jsp files)
etc/ (contains web.xml)
webapp/ (not in CVS)
[copied from web/]
WEB-INF/
classes/ [compiled from src/]
lib/ [copied from lib/ *except* for j2ee api jars]
web.xml [copied from etc/]
.cvsignore (contains "webapp")

Then I could have tomcat point to Project/webapp/. This would let me hide
the nasty WEB-INF directory, and as a bonus waring would be very simple.
My war file would then be a simple zip of webapp/.

This is straightforward to achieve with Ant, but it would require that I
execute an Ant target after every update. I'm not used to working this
way, but if folks have some advice for making this bearable I'm all ears.
Even so, I like the immediacy of simply *saving* a change and having
Tomcat pick up the change.

Ideally Eclipse would support some simple copy semantics. Does it? Can I
achieve what I want here? Is there a way to get Eclipse to execute an Ant
target on resource modification?

Thanks,
Josh
Re: Best project structure for web app? [message #17836 is a reply to message #17726] Thu, 12 February 2004 03:12 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jmordax.terra.es

Select your project, right button, properties, External Tool Builders,
New, ANT Build and fill it with your specific details.

Hope this helps,

Chemi.

Josh Rehman wrote:

>So far we've been mounting our eclipse project directory from tomcat.
>This requires that the project contain a WEB-INF directory with
>lib/classes/etc in it. Eclipse is set to compile into WEB-INF/classes,
>and everything works.
>
>Project/
> doc/
> src/ (eclipse source dir)
> WEB-INF/
> classes/ (eclipse generates into here)
> lib/
> web.xml
> .cvsignore (with "classes" included)
>
>But I would like to have a nicer project structure that looks like this:
>
>Project/
> doc/ (hand written docs)
> src/ (java source)
> lib/ (dependancies)
> web/ (jsp files)
> etc/ (contains web.xml)
> webapp/ (not in CVS)
> [copied from web/]
> WEB-INF/
> classes/ [compiled from src/]
> lib/ [copied from lib/ *except* for j2ee api jars]
> web.xml [copied from etc/]
> .cvsignore (contains "webapp")
>
>Then I could have tomcat point to Project/webapp/. This would let me hide
>the nasty WEB-INF directory, and as a bonus waring would be very simple.
>My war file would then be a simple zip of webapp/.
>
>This is straightforward to achieve with Ant, but it would require that I
>execute an Ant target after every update. I'm not used to working this
>way, but if folks have some advice for making this bearable I'm all ears.
>Even so, I like the immediacy of simply *saving* a change and having
>Tomcat pick up the change.
>
>Ideally Eclipse would support some simple copy semantics. Does it? Can I
>achieve what I want here? Is there a way to get Eclipse to execute an Ant
>target on resource modification?
>
>Thanks,
>Josh
>
>
Re: Best project structure for web app? [message #17863 is a reply to message #17726] Thu, 12 February 2004 18:18 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: kc.baltz.Lollimail.com

Josh Rehman wrote:
> So far we've been mounting our eclipse project directory from tomcat.
> This requires that the project contain a WEB-INF directory with
> lib/classes/etc in it. Eclipse is set to compile into WEB-INF/classes,
> and everything works.
>
> Project/
> doc/
> src/ (eclipse source dir)
> WEB-INF/
> classes/ (eclipse generates into here)
> lib/
> web.xml
> .cvsignore (with "classes" included)

We do almost what you've done. It looks like this:

Project/
doc/
src/ (eclipse source dir)
web/
WEB-INF/
classes/ (eclipse generates into here)
lib/
web.xml
.cvsignore (with "classes" included)

We do use an Ant build to move lots of files around, but for incremental
development where you are only recompiling the occasional class, just
recompiling in Eclipse is fine.

K.C.



>
> But I would like to have a nicer project structure that looks like this:
>
> Project/
> doc/ (hand written docs)
> src/ (java source)
> lib/ (dependancies)
> web/ (jsp files)
> etc/ (contains web.xml)
> webapp/ (not in CVS)
> [copied from web/]
> WEB-INF/
> classes/ [compiled from src/]
> lib/ [copied from lib/ *except* for j2ee api jars]
> web.xml [copied from etc/]
> .cvsignore (contains "webapp")
>
> Then I could have tomcat point to Project/webapp/. This would let me hide
> the nasty WEB-INF directory, and as a bonus waring would be very simple.
> My war file would then be a simple zip of webapp/.
>
> This is straightforward to achieve with Ant, but it would require that I
> execute an Ant target after every update. I'm not used to working this
> way, but if folks have some advice for making this bearable I'm all ears.
> Even so, I like the immediacy of simply *saving* a change and having
> Tomcat pick up the change.
>
> Ideally Eclipse would support some simple copy semantics. Does it? Can I
> achieve what I want here? Is there a way to get Eclipse to execute an Ant
> target on resource modification?
>
> Thanks,
> Josh
Re: Best project structure for web app? [message #17953 is a reply to message #17726] Mon, 16 February 2004 17:48 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: rtayek.no.spam.freightgate.com

"Josh Rehman" <jrehman@citysearch.com> wrote in message
news:Xns948CA65F1C6AFjoshrehman@204.138.98.10...
> So far we've been mounting our eclipse project directory from tomcat. ...
> But I would like to have a nicer project structure that looks like this:
>
> Project/
> web/ (jsp files)
> etc/ (contains web.xml)
> webapp/ (not in CVS)
> [copied from web/]
> WEB-INF/ ...
> .cvsignore (contains "webapp")
>
> Then I could have tomcat point to Project/webapp/. ...
> This is straightforward to achieve with Ant...
> Ideally Eclipse would support some simple copy semantics. Does it? Can I
> achieve what I want here? Is there a way to get Eclipse to execute an Ant
> target on resource modification?
>
have you looked at the directory structure in the tomcat 5 sample? (see
below)

i am trying to make eclipse build the same way my ant script does. i found
specifying the output foder for each src mount point to be helpful. this
seems to work fine for two source mount points (ant their corresponding
tst/'s).

i exect to be attemping do address the same problem that you have (most
everything wants to get built in build/). so please keep us informed of your
progress.

thanks


<project name="My Project" default="compile" basedir=".">
<property file="build.properties"/>
<property file="${user.home}/build.properties"/>
<property environment="env"/>
<property name="app.name" value="myapp"/>
<property name="app.path" value="/${app.name}"/>
<property name="app.version" value="0.1-dev"/>
<property name="build.home" value="${basedir}/build"/>
<property name="catalina.home" value="../../../.."/> <!-- UPDATE THIS! -->
<property name="dist.home" value="${basedir}/dist"/>
<property name="docs.home" value="${basedir}/docs"/>
<property name="manager.url" value="http://localhost:8080/manager"/>
<property name="src.home" value="${basedir}/src"/>
<property name="web.home" value="${basedir}/web"/>
<!--
- Copy the file "server/lib/catalina-ant.jar" from your Tomcat 5
installation into the "lib" directory of your Ant installation.
-->
<taskdef name="deploy" classname="org.apache.catalina.ant.DeployTask"/>
<taskdef name="list" classname="org.apache.catalina.ant.ListTask"/>
<taskdef name="reload" classname="org.apache.catalina.ant.ReloadTask"/>
<taskdef name="undeploy"
classname="org.apache.catalina.ant.UndeployTask"/>

<property name="compile.debug" value="true"/>
<property name="compile.deprecation" value="false"/>
<property name="compile.optimize" value="true"/>

<!-- ==================== External Dependencies
=========================== -->
<!-- Dummy external dependency -->
<!--
<property name="foo.jar"
value="/path/to/foo.jar"/>
-->
<!-- ==================== Compilation Classpath
=========================== -->
<path id="compile.classpath">
<!-- Include all JAR files that will be included in /WEB-INF/lib -->
<!-- *** CUSTOMIZE HERE AS REQUIRED BY YOUR APPLICATION *** -->
<!--
<pathelement location="${foo.jar}"/>
-->
<!-- Include all elements that Tomcat exposes to applications -->
<pathelement location="${catalina.home}/common/classes"/>
<fileset dir="${catalina.home}/common/endorsed">
<include name="*.jar"/>
</fileset>
<fileset dir="${catalina.home}/common/lib">
<include name="*.jar"/>
</fileset>
<pathelement location="${catalina.home}/shared/classes"/>
<fileset dir="${catalina.home}/shared/lib">
<include name="*.jar"/>
</fileset>
</path>
<target name="all" depends="clean,compile" description="Clean build and
dist directories, then compile"/>
<target name="clean" description="Delete old build and dist directories">
<echo message="catalina.home=${catalina.home}"/>
<echo message="app.version=${app.version}"/>
<delete dir="${build.home}"/>
<delete dir="${dist.home}"/>
</target>
<target name="compile" depends="prepare" description="Compile Java
sources">
<mkdir dir="${build.home}/WEB-INF/classes"/>
<javac srcdir="${src.home}"
destdir="${build.home}/WEB-INF/classes"
debug="${compile.debug}"
deprecation="${compile.deprecation}"
optimize="${compile.optimize}">
<classpath refid="compile.classpath"/>
</javac>
<!-- Copy application resources -->
<copy todir="${build.home}/WEB-INF/classes">
<fileset dir="${src.home}" excludes="**/*.java"/>
</copy>
</target>
<target name="dist" depends="compile,javadoc" description="Create binary
distribution">
<mkdir dir="${dist.home}/docs"/>
<copy todir="${dist.home}/docs">
<fileset dir="${docs.home}"/>
</copy>
<!-- Create application JAR file -->
<jar jarfile="${dist.home}/${app.name}-${app.version}.war"
basedir="${build.home}"/>
<!-- Copy additional files to ${dist.home} as necessary -->
</target>
<target name="install" depends="compile" description="Install application
to servlet container">
<deploy url="${manager.url}"
username="${manager.username}"
password="${manager.password}"
path="${app.path}"
war="file://${dist.home}/${app.name}-${app.version}.war"/>
</target>
<target name="javadoc" depends="compile" description="Create Javadoc API
documentation">
<mkdir dir="${dist.home}/docs/api"/>
<javadoc sourcepath="${src.home}" destdir="${dist.home}/docs/api"
packagenames="*">
<classpath refid="compile.classpath"/>
</javadoc>
</target>
<target name="list" description="List installed applications on servlet
container">
<list url="${manager.url}" username="${manager.username}"
password="${manager.password}"/>
</target>
<target name="prepare">
<!-- Create build directories as needed -->
<mkdir dir="${build.home}"/>
<mkdir dir="${build.home}/WEB-INF"/>
<mkdir dir="${build.home}/WEB-INF/classes"/>
<!-- Copy static content of this web application -->
<copy todir="${build.home}">
<fileset dir="${web.home}"/>
</copy>
<copy todir="${build.home}/WEB-INF" file="web.xml"/>
<!-- Copy external dependencies as required -->
<!-- *** CUSTOMIZE HERE AS REQUIRED BY YOUR APPLICATION *** -->
<mkdir dir="${build.home}/WEB-INF/lib"/>
<!--
<copy todir="${build.home}/WEB-INF/lib" file="${foo.jar}"/>
-->
<!-- Copy static files from external dependencies as needed -->
<!-- *** CUSTOMIZE HERE AS REQUIRED BY YOUR APPLICATION *** -->
</target>
<target name="reload" depends="compile" description="Reload application on
servlet container">
<reload url="${manager.url}" username="${manager.username}"
password="${manager.password}" path="${app.path}"/>
</target>
<target name="remove" description="Remove application on servlet
container">
<undeploy url="${manager.url}"
username="${manager.username}"
password="${manager.password}"
path="${app.path}"/>
</target>
</project>
Re: Best project structure for web app? [message #18189 is a reply to message #17726] Mon, 23 February 2004 15:13 Go to previous message
Eclipse UserFriend
Originally posted by: rajbsaini.yahoo.com

The problem with keeping different build directories for ant script and
eclipse is ant recompiles all .java while theya re already compiled by
the eclipe

I personaly dont want like WEB-INF or META-INF visible in the directory
structure.

I wrote a build file for each moduel which just need to assemble the
project (no need to compile as it is already done by JDT).

My small build files just copy the required files such as .jar, .xml
descriptors and web contents to the build.

You can create a jar, war or ear out of the build folder or mount is as
your webapps for the tomcat.

I use the diffeent output directory for a source folder feature of the
eclipse to achive the deployment direcotry structure.

Project/
EJB-Modules/
X-module/
src/
conf/
ejb-jar.xml
docs/
build.xml
Y-Module/
...
Web-Modules/
A-Module/
src/
conf/
web.xml
xxxx.tld
docs/
build.xml
lib/
x.jar
y.jar
dist/
conf/
application.xml

build.xml

<hidden)
build/
ejb/
module-x/
module-y/
web/
web-app-x\
WEB-INF\
classes\
lib\
.html
.jsp




Regards,

Raj


osh Rehman wrote:
> So far we've been mounting our eclipse project directory from tomcat.
> This requires that the project contain a WEB-INF directory with
> lib/classes/etc in it. Eclipse is set to compile into WEB-INF/classes,
> and everything works.
>
> Project/
> doc/
> src/ (eclipse source dir)
> WEB-INF/
> classes/ (eclipse generates into here)
> lib/
> web.xml
> .cvsignore (with "classes" included)
>
> But I would like to have a nicer project structure that looks like this:
>
> Project/
> doc/ (hand written docs)
> src/ (java source)
> lib/ (dependancies)
> web/ (jsp files)
> etc/ (contains web.xml)
> webapp/ (not in CVS)
> [copied from web/]
> WEB-INF/
> classes/ [compiled from src/]
> lib/ [copied from lib/ *except* for j2ee api jars]
> web.xml [copied from etc/]
> .cvsignore (contains "webapp")
>
> Then I could have tomcat point to Project/webapp/. This would let me hide
> the nasty WEB-INF directory, and as a bonus waring would be very simple.
> My war file would then be a simple zip of webapp/.
>
> This is straightforward to achieve with Ant, but it would require that I
> execute an Ant target after every update. I'm not used to working this
> way, but if folks have some advice for making this bearable I'm all ears.
> Even so, I like the immediacy of simply *saving* a change and having
> Tomcat pick up the change.
>
> Ideally Eclipse would support some simple copy semantics. Does it? Can I
> achieve what I want here? Is there a way to get Eclipse to execute an Ant
> target on resource modification?
>
> Thanks,
> Josh
Previous Topic:CVS
Next Topic:Eclipse Solex HELP: Value-lees Parameter Useage
Goto Forum:
  


Current Time: Thu May 08 05:49:07 EDT 2025

Powered by FUDForum. Page generated in 0.03561 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top