You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Gautham Pamu <ga...@gmail.com> on 2006/04/22 10:25:00 UTC

m2 Can a web project depend on source code from other web project

Hi Everyone,

I have strange scenario. I have two web projects, one web project A is
accesing code from another web project B. Since
RAD allows it, the developer add the dependency on another web project in
RAD.

Even though I defined the dependency in pom.xml between the web projects,
the second web project  A is not able
to see the classes from ther other webproject. How should I define the
dependency for this project....


Thanks in advance
--
-Gautham Pamu

Re: m2 Can a web project depend on source code from other web project

Posted by Geoffrey De Smet <ge...@gmail.com>.
I believe it's possible for a war to depend on a war, in which case all 
webapp resources are copied from the dependency war, but I doubt the 
classes are

Wayne Fay wrote:
> On 4/22/06, Simon Kitching <sk...@apache.org> wrote:
>> It's quite common to generate "variants" of projects (sorry, there's
>> some maven terminology for this which I can't remember for the moment).
>> For example, a jar project can build foo.jar plus variants like
>> foo-src.jar, foo-jdk14.jar, etc. Anyone know if this mechanism could be
>> used to add a jarfile of the classes for a webapp (or some subset of
>> them) as one of its generated artifacts? Or is it done just like the
>> approach described above?
> 
> You're talking about classifiers ie <classifier>jdk14</classifier>. ;-)
> 
> You could probably rig some complicated system using assembler to
> unjar the B.war file, grab the files from b-war/WEB-INF/classes and
> build them into the A.war project. But no guarantees it would work.
> And it would take a decent amount of time to get it all working
> properly, I'd assume.
> 
> This is another case of "help Maven help you" -- I'd just get the
> B.war guy to break his project into 2 pieces, jar and war, and pull in
> the B-jar dependency by itself.
> 
> Wayne

-- 
With kind regards,
Geoffrey De Smet


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: m2 Can a web project depend on source code from other web project

Posted by Arik Kfir <ar...@gmail.com>.
same here - that's the whole idea of reuse. If you have code that you want
or need to share, then it should be its own as a component of the bigger
project.

On 4/23/06, Wayne Fay <wa...@gmail.com> wrote:
>
> On 4/22/06, Simon Kitching <sk...@apache.org> wrote:
> > It's quite common to generate "variants" of projects (sorry, there's
> > some maven terminology for this which I can't remember for the moment).
> > For example, a jar project can build foo.jar plus variants like
> > foo-src.jar, foo-jdk14.jar, etc. Anyone know if this mechanism could be
> > used to add a jarfile of the classes for a webapp (or some subset of
> > them) as one of its generated artifacts? Or is it done just like the
> > approach described above?
>
> You're talking about classifiers ie <classifier>jdk14</classifier>. ;-)
>
> You could probably rig some complicated system using assembler to
> unjar the B.war file, grab the files from b-war/WEB-INF/classes and
> build them into the A.war project. But no guarantees it would work.
> And it would take a decent amount of time to get it all working
> properly, I'd assume.
>
> This is another case of "help Maven help you" -- I'd just get the
> B.war guy to break his project into 2 pieces, jar and war, and pull in
> the B-jar dependency by itself.
>
> Wayne
>



--
______________________________________
Cheers,
      Arik Kfir                                   arikkfir@gmail.com
      Linux user, number 415067 - http://counter.li.org/
      http://corleon.dnsalias.org

Re: m2 Can a web project depend on source code from other web project

Posted by Wayne Fay <wa...@gmail.com>.
On 4/22/06, Simon Kitching <sk...@apache.org> wrote:
> It's quite common to generate "variants" of projects (sorry, there's
> some maven terminology for this which I can't remember for the moment).
> For example, a jar project can build foo.jar plus variants like
> foo-src.jar, foo-jdk14.jar, etc. Anyone know if this mechanism could be
> used to add a jarfile of the classes for a webapp (or some subset of
> them) as one of its generated artifacts? Or is it done just like the
> approach described above?

You're talking about classifiers ie <classifier>jdk14</classifier>. ;-)

You could probably rig some complicated system using assembler to
unjar the B.war file, grab the files from b-war/WEB-INF/classes and
build them into the A.war project. But no guarantees it would work.
And it would take a decent amount of time to get it all working
properly, I'd assume.

This is another case of "help Maven help you" -- I'd just get the
B.war guy to break his project into 2 pieces, jar and war, and pull in
the B-jar dependency by itself.

Wayne

Re: m2 Can a web project depend on source code from other web project

Posted by Simon Kitching <sk...@apache.org>.
On Sat, 2006-04-22 at 03:25 -0500, Gautham Pamu wrote:
> Hi Everyone,
> 
> I have strange scenario. I have two web projects, one web project A is
> accesing code from another web project B. Since
> RAD allows it, the developer add the dependency on another web project in
> RAD.
> 
> Even though I defined the dependency in pom.xml between the web projects,
> the second web project  A is not able
> to see the classes from ther other webproject. How should I define the
> dependency for this project....


In order for project A to have a dependency on a jar, it needs to be
able to point to that jar in the local maven repository. However when a
"war" project is installed into a repository, it is the .war that is
installed; there is therefore nothing suitable for A to point to.

I guess it's possible to use "brute force". The maven-assembly-plugin
allows you to build a jarfile containing whatever you want from the
project. And the maven-install-plugin allows you to install whatever
artifacts you want into the local repository. You could therefore attach
a custom assembly definition to the "assemble" phase, and a custom
install definition to the "install" phase, using <execute> tags.

It's quite common to generate "variants" of projects (sorry, there's
some maven terminology for this which I can't remember for the moment).
For example, a jar project can build foo.jar plus variants like
foo-src.jar, foo-jdk14.jar, etc. Anyone know if this mechanism could be
used to add a jarfile of the classes for a webapp (or some subset of
them) as one of its generated artifacts? Or is it done just like the
approach described above?

Otherwise I think you *have* to split up project B into two parts: a
"jar" project and a "war" project. Both A and b-war can then depend on
B-jar. It's certainly the cleanest solution.

NB: I'm no maven guru; any or all of the above could be wrong :-)

Regards,

Simon


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: m2 Can a web project depend on source code from other web project

Posted by Alexandre Poitras <al...@gmail.com>.
Well my first guess would be it has something to do with the
dependency "type" element (Maven probably set it automatically as a
war dependency). Another value would maybe solve the problem but I
don't know for sure. I suggest you to do some reseach in the archive
of this list or maybe some other people can answer this one.

On 4/22/06, Gautham Pamu <ga...@gmail.com> wrote:
> Hi Alexandre,
>
> Thanks Alexandre for responding to my question.
>
> Even I follow that rule, for common code, I try to have a project for it and
> use it across web projects but this project was created by another
> developer. if possible I don't want to change
> it for this iteration, later I will definitely ask him to refactor the code
> to a java project.
>
> So is there way to configure the webproject to access the classes from the
> other project. If it is not feasible.. I will definitely request the
> developer to move it to a comon util project.
>
> Thanks
> Gautham Pamu
>
>
> On 4/22/06, Alexandre Poitras <al...@gmail.com> wrote:
> >
> > Why don't you extract the common Java code in a utility library? This
> > is what people usually do.
> >
> > On 4/22/06, Gautham Pamu <ga...@gmail.com> wrote:
> > > Hi Everyone,
> > >
> > > I have strange scenario. I have two web projects, one web project A is
> > > accesing code from another web project B. Since
> > > RAD allows it, the developer add the dependency on another web project
> > in
> > > RAD.
> > >
> > > Even though I defined the dependency in pom.xml between the web
> > projects,
> > > the second web project  A is not able
> > > to see the classes from ther other webproject. How should I define the
> > > dependency for this project....
> > >
> > >
> > > Thanks in advance
> > > --
> > > -Gautham Pamu
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > For additional commands, e-mail: users-help@maven.apache.org
> >
> >
>
>
> --
> -Gautham Pamu
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: m2 Can a web project depend on source code from other web project

Posted by Gautham Pamu <ga...@gmail.com>.
Hi Alexandre,

Thanks Alexandre for responding to my question.

Even I follow that rule, for common code, I try to have a project for it and
use it across web projects but this project was created by another
developer. if possible I don't want to change
it for this iteration, later I will definitely ask him to refactor the code
to a java project.

So is there way to configure the webproject to access the classes from the
other project. If it is not feasible.. I will definitely request the
developer to move it to a comon util project.

Thanks
Gautham Pamu


On 4/22/06, Alexandre Poitras <al...@gmail.com> wrote:
>
> Why don't you extract the common Java code in a utility library? This
> is what people usually do.
>
> On 4/22/06, Gautham Pamu <ga...@gmail.com> wrote:
> > Hi Everyone,
> >
> > I have strange scenario. I have two web projects, one web project A is
> > accesing code from another web project B. Since
> > RAD allows it, the developer add the dependency on another web project
> in
> > RAD.
> >
> > Even though I defined the dependency in pom.xml between the web
> projects,
> > the second web project  A is not able
> > to see the classes from ther other webproject. How should I define the
> > dependency for this project....
> >
> >
> > Thanks in advance
> > --
> > -Gautham Pamu
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>


--
-Gautham Pamu

Re: m2 Can a web project depend on source code from other web project

Posted by Alexandre Poitras <al...@gmail.com>.
Why don't you extract the common Java code in a utility library? This
is what people usually do.

On 4/22/06, Gautham Pamu <ga...@gmail.com> wrote:
> Hi Everyone,
>
> I have strange scenario. I have two web projects, one web project A is
> accesing code from another web project B. Since
> RAD allows it, the developer add the dependency on another web project in
> RAD.
>
> Even though I defined the dependency in pom.xml between the web projects,
> the second web project  A is not able
> to see the classes from ther other webproject. How should I define the
> dependency for this project....
>
>
> Thanks in advance
> --
> -Gautham Pamu
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org