You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by laredotornado <la...@gmail.com> on 2009/12/01 16:10:24 UTC

How do you include classes from a WAR as a dependency?

Hi,

I'm using Maven 2.2.  I think I read somewhere that you cannot have a WAR as
a dependency because maven doesn't know how to read the WEB-INF/classes
directory.  I am finding this to be true because I have this dependency in
my test project ...

    <dependency>
        <groupId>myco.galc.capitol.tours</groupId>
        <artifactId>myco-galc-capitol-tours</artifactId>
        <version>1.0-SNAPSHOT</version>
        <type>war</type>
    </dependency>

but I am still getting compilation errors complaining that a class cannot be
found that I know to be in my WAR file.  What is the work-around for this? 
That is, how can I include a WAR as a dependency?

Thanks,  - Dave
-- 
View this message in context: http://old.nabble.com/How-do-you-include-classes-from-a-WAR-as-a-dependency--tp26593382p26593382.html
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: How do you include classes from a WAR as a dependency?

Posted by laredotornado <la...@gmail.com>.
I just discovered there is a "<sourceDirectory>" element as part of the
"<build>" tag.  So in my test folder, I made the <sourceDirectory> my
webapp's java folder, where the .java files are contained.

Is this the conventional way of doing it?  That prevents me from having to
make a JAR file out of my WAR's classes, but maybe I'm misunderstanding the
purpose of the <sourceDirectory> element.

Thanks, - Dave




Wendy Smoak-3 wrote:
> 
> On Tue, Dec 1, 2009 at 8:10 AM, laredotornado <la...@gmail.com>
> wrote:
> 
>> I'm using Maven 2.2.  I think I read somewhere that you cannot have a WAR
>> as
>> a dependency because maven doesn't know how to read the WEB-INF/classes
>> directory.
> 
> This isn't Maven related, it's a Java thing.  Try compiling code at
> the command line with a war on the classpath -- it won't work.
> 
> If something else depends on the classes in your war, then those
> classes probably deserve to be in a separate module which creates a
> jar.  Then both your war and the other project can depend on this jar.
> 
> You might also be interested in the 'archiveClasses' parameter of the
> war plugin, which will make it create a jar instead of using
> WEB-INF/classes.
> http://maven.apache.org/plugins/maven-war-plugin/war-mojo.html
> 
> -- 
> Wendy
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/How-do-you-include-classes-from-a-WAR-as-a-dependency--tp26593382p26594232.html
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: How do you include classes from a WAR as a dependency?

Posted by Wendy Smoak <ws...@gmail.com>.
On Tue, Dec 1, 2009 at 8:10 AM, laredotornado <la...@gmail.com> wrote:

> I'm using Maven 2.2.  I think I read somewhere that you cannot have a WAR as
> a dependency because maven doesn't know how to read the WEB-INF/classes
> directory.

This isn't Maven related, it's a Java thing.  Try compiling code at
the command line with a war on the classpath -- it won't work.

If something else depends on the classes in your war, then those
classes probably deserve to be in a separate module which creates a
jar.  Then both your war and the other project can depend on this jar.

You might also be interested in the 'archiveClasses' parameter of the
war plugin, which will make it create a jar instead of using
WEB-INF/classes.
http://maven.apache.org/plugins/maven-war-plugin/war-mojo.html

-- 
Wendy

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