On Mon, Jan 09, 2006 at 08:16:00PM +0200, Oded Arbel wrote:
> The problem is like this (the actual system is far more complex):
> - suppose two web applications, app1 and app2, both use some API (which 
> I developed myself). 
> - I don't want to develop the API twice on both web applications, so I 
> have a third project for the API  itself, which is a not a web 
> application and so isn't in WEB-INF/classes of neither app1 nor app2.
> - I don't want to build a jar for that API library to put in app1 and 
> app2's WEB-INF/lib because its also constantly being developed - if I 
> wanted to do this then after each commit, in addition to the build 
> stage I would have to copy the jar by hand to all the applications that 
> use it, which is an error prone process.

        You've got to be kidding.  Copy by hand!?  Why?  Just build the jar
file to some predefined location, and have the build process for each app
copy it from there.  There's no need to copy it by hand, have ant, or whatever
you're using to build, do it for you.
        That seems much simpler than playing with custom class loaders, or
startup classpath dependencies, or loose class files.
e.g. say you've got 4 different api's.  When you build those, a jar file
gets created in (e.g.) /myjars:
        /myjars/api1.jar
        /myjars/api2.jar
        /myjars/api3.jar
        /myjars/api4.jar

Let's say app1 uses api's 1, 3 and 4, so it has something like this 
somewhere in its build.xml:  (assuming you're using ant)
        <copy file="/myjars/api1.jar" todir="${WEB_DIR_LOCATION}/lib"/>
        <copy file="/myjars/api3.jar" todir="${WEB_DIR_LOCATION}/lib"/>
        <copy file="/myjars/api4.jar" todir="${WEB_DIR_LOCATION}/lib"/>
and app2 uses 2 and 4, so it instead has:
        <copy file="/myjars/api2.jar" todir="${WEB_DIR_LOCATION}/lib"/>
        <copy file="/myjars/api4.jar" todir="${WEB_DIR_LOCATION}/lib"/>
etc...

of course, if you don't want a global location for the api jar files,
you can always use a relative path.  This is what I do in my app.  I've
got a directory structure that looks like this:
   mycode/
      myapi/
        build.xml   (builds the java files and creates myapi.jar)
        build/myapi.jar
      myapp/
        build.xml   (copies ../myapi/build/myapi.jar to build/WEB-INF/lib e.g.:
        <copy file="../../myapi/build/api1.jar" 
todir="${WEB_DIR_LOCATION}/lib"/>
        build/WEB-INF/lib/myapi.jar

eric

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to