You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by vicki <vi...@yahoo.com> on 2008/05/13 20:23:13 UTC

Modify Classpath

Hello,
I have a maven's subproject that runs tests against the artifacts of its
piers subprojects. Obviously, In other words, to run my tests I need to
create dependencies on the artifacts produced by the other subprojects. I
run my tests with maven's "exec" plugin. All the artifacts packaged as jars
are indeed on my classpath when I run maven exec. But dependencies on the
artifacts packaged as wars are not resolved in such a way that classes
directory inside these wars are put on the classpath. I do not want to
explicitly specify a classpath in the configuration of maven exec plugin.
Instead I'd like to have a classpath that is build with project's
dependencies.  Can anyone advise a good way of doing this?
Thanks a lot.
Vicki

-- 
View this message in context: http://www.nabble.com/Modify-Classpath-tp17215208p17215208.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: Modify Classpath

Posted by vicki <vi...@yahoo.com>.
This is exactly what I am doing - an integration test. I decided to create a
separate "test" subproject that  is a peer to the "tested" subprojects.  I
hoped that by declaring the same parent in my test subproject and inheriting
all the project's dependencies I will be able to avoid version confusions
and test the artifacts whose versions are perfectly aligned. I did not want
to employ any hecks to solve my artifact availability problem, but to do it
entirely with dependency mechanism available in maven. 

Michael McCallum-3 wrote:
> 
> in my particular case i needed the code for integration tests so was 
> borderline as to whether the artifact was actually separate or not... 
> 
> but in general i would agree
> On Wed, 14 May 2008 12:02:13 Brian E. Fox wrote:
>> If you have classes that you need outside a war, the correct way is to
>> make this into a jar that is used externally and also packaged inside
>> your war.
>>
> 
> -- 
> Michael McCallum
> Enterprise Engineer
> mailto:gholam@apache.org
> 
> ---------------------------------------------------------------------
> 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://www.nabble.com/Modify-Classpath-tp17215208p17236473.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: Modify Classpath

Posted by Michael McCallum <gh...@apache.org>.
in my particular case i needed the code for integration tests so was 
borderline as to whether the artifact was actually separate or not... 

but in general i would agree
On Wed, 14 May 2008 12:02:13 Brian E. Fox wrote:
> If you have classes that you need outside a war, the correct way is to
> make this into a jar that is used externally and also packaged inside
> your war.
>

-- 
Michael McCallum
Enterprise Engineer
mailto:gholam@apache.org

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


RE: Modify Classpath

Posted by "Brian E. Fox" <br...@reply.infinity.nu>.
If you have classes that you need outside a war, the correct way is to
make this into a jar that is used externally and also packaged inside
your war.

-----Original Message-----
From: vicki [mailto:vicki_kozel@yahoo.com] 
Sent: Tuesday, May 13, 2008 6:49 PM
To: users@maven.apache.org
Subject: Re: Modify Classpath


Olivier, thank you very much for the advice. Unfortunately, my quick
test of
build-classpath did did not solve my runtime classpath problem. First of
all, the examples of the build-classpath goal that I saw, show how to
output
the project's classpath to a file. What I need is to add project
dependencies to a runtime of a maven's "exec" plugin. I did use an
<attach>
tag that I set to true, hoping that this will take care of putting all
the
dependencies into the runtime, but it didn't. Second, the output file
with a
classpath that build-classpath goal produced, did not resolved the
artifacts
that are packaged as wars. It does put wars in the classpath, but this,
naturally, does not make classes inside these wars available in the
runtime. 


Olivier Dehon-2 wrote:
> 
> Have a look at the build-classpath goal of the dependency plugin:
>
http://maven.apache.org/plugins/maven-dependency-plugin/build-classpath-
mojo.html
> 
> -Olivier
> 
> On Tue, 2008-05-13 at 11:23 -0700, vicki wrote:
>> Hello,
>> I have a maven's subproject that runs tests against the artifacts of
its
>> piers subprojects. Obviously, In other words, to run my tests I need
to
>> create dependencies on the artifacts produced by the other
subprojects. I
>> run my tests with maven's "exec" plugin. All the artifacts packaged
as
>> jars
>> are indeed on my classpath when I run maven exec. But dependencies on
the
>> artifacts packaged as wars are not resolved in such a way that
classes
>> directory inside these wars are put on the classpath. I do not want
to
>> explicitly specify a classpath in the configuration of maven exec
plugin.
>> Instead I'd like to have a classpath that is build with project's
>> dependencies.  Can anyone advise a good way of doing this?
>> Thanks a lot.
>> Vicki
>> 
> 
> 
> ---------------------------------------------------------------------
> 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://www.nabble.com/Modify-Classpath-tp17215208p17220036.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


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


Re: Modify Classpath

Posted by vicki <vi...@yahoo.com>.
Olivier, thank you very much for the advice. Unfortunately, my quick test of
build-classpath did did not solve my runtime classpath problem. First of
all, the examples of the build-classpath goal that I saw, show how to output
the project's classpath to a file. What I need is to add project
dependencies to a runtime of a maven's "exec" plugin. I did use an <attach>
tag that I set to true, hoping that this will take care of putting all the
dependencies into the runtime, but it didn't. Second, the output file with a
classpath that build-classpath goal produced, did not resolved the artifacts
that are packaged as wars. It does put wars in the classpath, but this,
naturally, does not make classes inside these wars available in the runtime. 


Olivier Dehon-2 wrote:
> 
> Have a look at the build-classpath goal of the dependency plugin:
> http://maven.apache.org/plugins/maven-dependency-plugin/build-classpath-mojo.html
> 
> -Olivier
> 
> On Tue, 2008-05-13 at 11:23 -0700, vicki wrote:
>> Hello,
>> I have a maven's subproject that runs tests against the artifacts of its
>> piers subprojects. Obviously, In other words, to run my tests I need to
>> create dependencies on the artifacts produced by the other subprojects. I
>> run my tests with maven's "exec" plugin. All the artifacts packaged as
>> jars
>> are indeed on my classpath when I run maven exec. But dependencies on the
>> artifacts packaged as wars are not resolved in such a way that classes
>> directory inside these wars are put on the classpath. I do not want to
>> explicitly specify a classpath in the configuration of maven exec plugin.
>> Instead I'd like to have a classpath that is build with project's
>> dependencies.  Can anyone advise a good way of doing this?
>> Thanks a lot.
>> Vicki
>> 
> 
> 
> ---------------------------------------------------------------------
> 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://www.nabble.com/Modify-Classpath-tp17215208p17220036.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: Modify Classpath

Posted by Olivier Dehon <od...@gmail.com>.
Have a look at the build-classpath goal of the dependency plugin:
http://maven.apache.org/plugins/maven-dependency-plugin/build-classpath-mojo.html

-Olivier

On Tue, 2008-05-13 at 11:23 -0700, vicki wrote:
> Hello,
> I have a maven's subproject that runs tests against the artifacts of its
> piers subprojects. Obviously, In other words, to run my tests I need to
> create dependencies on the artifacts produced by the other subprojects. I
> run my tests with maven's "exec" plugin. All the artifacts packaged as jars
> are indeed on my classpath when I run maven exec. But dependencies on the
> artifacts packaged as wars are not resolved in such a way that classes
> directory inside these wars are put on the classpath. I do not want to
> explicitly specify a classpath in the configuration of maven exec plugin.
> Instead I'd like to have a classpath that is build with project's
> dependencies.  Can anyone advise a good way of doing this?
> Thanks a lot.
> Vicki
> 


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


Re: Modify Classpath

Posted by Michael McCallum <gh...@apache.org>.
On Wed, 14 May 2008 11:18:54 Wendy Smoak wrote:
> On Tue, May 13, 2008 at 11:23 AM, vicki <vi...@yahoo.com> wrote:
> >  I have a maven's subproject that runs tests against the artifacts of its
> >  piers subprojects. Obviously, In other words, to run my tests I need to
> >  create dependencies on the artifacts produced by the other subprojects.
> > I run my tests with maven's "exec" plugin. All the artifacts packaged as
> > jars are indeed on my classpath when I run maven exec. But dependencies
> > on the artifacts packaged as wars are not resolved in such a way that
> > classes directory inside these wars are put on the classpath.
>
> Java simply has no concept of putting a war file on the classpath.  If
> you have code in a war module that you need to use elsewhere, the best
> idea is to move the code to a separate module that builds a jar.  That
> jar then becomes a dependency of your war module plus any other module
> that needs it.
>
> If you absolutely can't move the code, the next version of the war
> plugin will have the ability to deploy a classified/attached artifact
> containing the code from a war module.

1) you can make the packaging type of the project jar 
2) add a config for the war plugin to execute war... 
      <plugin>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.1-alpha-1</version>
        <executions>
          <execution>
            <goals>
              <goal>war</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <archiveClasses>true</archiveClasses>
          <classifier>application</classifier>
        </configuration>
      </plugin>
3) this gives you a jar and a war
4) you can then depend upon the jar (default) artifact to get the deps of this 
project and if you need to
<dependency>
	<groupId>a.b</groupId>
	<artifactId>a.b.c</artifactId>
	<version>[1,2-!)</version>
</dependency>
5) to use this war as an underlay you can depend on the project with 
classifier 'application'
<dependency>
	<groupId>a.b</groupId>
	<artifactId>a.b.c</artifactId>
	<version>[1,2-!)</version>
	<type>war</type>
</dependency>



-- 
Michael McCallum
Enterprise Engineer
mailto:gholam@apache.org

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


Re: Modify Classpath

Posted by Wendy Smoak <ws...@gmail.com>.
On Tue, May 13, 2008 at 11:23 AM, vicki <vi...@yahoo.com> wrote:

>  I have a maven's subproject that runs tests against the artifacts of its
>  piers subprojects. Obviously, In other words, to run my tests I need to
>  create dependencies on the artifacts produced by the other subprojects. I
>  run my tests with maven's "exec" plugin. All the artifacts packaged as jars
>  are indeed on my classpath when I run maven exec. But dependencies on the
>  artifacts packaged as wars are not resolved in such a way that classes
>  directory inside these wars are put on the classpath.

Java simply has no concept of putting a war file on the classpath.  If
you have code in a war module that you need to use elsewhere, the best
idea is to move the code to a separate module that builds a jar.  That
jar then becomes a dependency of your war module plus any other module
that needs it.

If you absolutely can't move the code, the next version of the war
plugin will have the ability to deploy a classified/attached artifact
containing the code from a war module.

-- 
Wendy

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