You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Lee Meador <le...@leemeador.com> on 2006/02/03 20:50:56 UTC

What scope is like 'provided' and 'test' together?

I have a jar (webservices.jar) that I need for these things:

1) Compile main source.
2) Run tests in projects that are dependant on this one.

But not for running the main source since that will run in the ejb
container.

<scope>provided</scope> doesn't work because the jar isn't available for the
tests in the dependent projects which need to instantiate a class from the
jar but not to call it.
<scope>compile</scope> doesn't work because the jar ends up inside the ear
<scope>test</scope> doesn't work because the main code doesn't compile.

Am I looking at this wrong somehow?

The one solution I have found is to put it as "provided" in this project and
put it as 'test" in another project that runs tests that need classes. (I
use the term "project" to mean a think with a POM of its own.) The problems
with this are:

1) I can't run any such tests in the same project. (I can live with this.)
2) I have to put the dependency in the other project even though it is only
needed when running the test that references this project. That seems
"wrong" in some way.

Any ideas?

-- Lee Meador
Sent from gmail. My real email address is lee@leemeador.com

Re: What scope is like 'provided' and 'test' together?

Posted by Martijn Dashorst <ma...@gmail.com>.
Hmm,

Why not use the scope in the same way as the class attribute in html?

This would give:

<scope>test provided</scope>

this should tell maven that the dependency is needed for test, compile
and is provided in a later stage by some container.

Martijn

On 2/6/06, Lee Meador <le...@leemeador.com> wrote:
> David,
>
> I am doing something sort of like you described and that seems to work. The
> work-around is to set the scope one way in a project that is depended on and
> then exclude it in a project that is dependant.
>
> It's just not very satisfying when what you want is to include the jar for
> regular  compile and test compile and for test run but not for normal run.
> and the options don't include that combination.
>
> Thanks.
>
> On 2/4/06, David H. DeWolf <dd...@apache.org> wrote:
> >
> > Lee,
> >
> > Have you tried using the exclusions that are available within the
> > dependency declarations?
> >
> > If this webservices.jar is needed in a project (say project-a) which
> > is included within an ear (say ear-project), you would define the
> > following dependency within the ear-project pom:
> >
> >     <dependency>
> >       <groupId>whatever</groupId>
> >       <artifactId>project-a</artifactId>
> >       <version>1.0</version>
> >       <scope>compile</scope>
> >       <exclusions>
> >         <exclusion>
> >           <groupId>whatever</groupId>
> >           <artifactId>webservices</artifactId>
> >         </exclusion>
> >       </exclusions>
> >     </dependency>
> >
> > With this approach, you could use a compile scoped dependency but not
> > have it included in the ear.
> >
> > Hope that helps,
> >
> > David
> >
> > On 2/3/06, Lee Meador <le...@leemeador.com> wrote:
> > > I have a jar (webservices.jar) that I need for these things:
> > >
> > > 1) Compile main source.
> > > 2) Run tests in projects that are dependant on this one.
> > >
> > > But not for running the main source since that will run in the ejb
> > > container.
> > >
> > > <scope>provided</scope> doesn't work because the jar isn't available for
> > the
> > > tests in the dependent projects which need to instantiate a class from
> > the
> > > jar but not to call it.
> > > <scope>compile</scope> doesn't work because the jar ends up inside the
> > ear
> > > <scope>test</scope> doesn't work because the main code doesn't compile.
> > >
> > > Am I looking at this wrong somehow?
> > >
> > > The one solution I have found is to put it as "provided" in this project
> > and
> > > put it as 'test" in another project that runs tests that need classes.
> > (I
> > > use the term "project" to mean a think with a POM of its own.) The
> > problems
> > > with this are:
> > >
> > > 1) I can't run any such tests in the same project. (I can live with
> > this.)
> > > 2) I have to put the dependency in the other project even though it is
> > only
> > > needed when running the test that references this project. That seems
> > > "wrong" in some way.
> > >
> > > Any ideas?
> > >
> > > -- Lee Meador
> > > Sent from gmail. My real email address is lee@leemeador.com
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > For additional commands, e-mail: users-help@maven.apache.org
> >
> >
>
>
> --
> -- Lee Meador
> Sent from gmail. My real email address is lee@leemeador.com
>
>


--
Living a wicket life...

Martijn Dashorst - http://www.jroller.com/page/dashorst

Wicket 1.1.1 is out: http://wicket.sourceforge.net/wicket-1.1

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


Re: What scope is like 'provided' and 'test' together?

Posted by Lee Meador <le...@leemeador.com>.
David,

I am doing something sort of like you described and that seems to work. The
work-around is to set the scope one way in a project that is depended on and
then exclude it in a project that is dependant.

It's just not very satisfying when what you want is to include the jar for
regular  compile and test compile and for test run but not for normal run.
and the options don't include that combination.

Thanks.

On 2/4/06, David H. DeWolf <dd...@apache.org> wrote:
>
> Lee,
>
> Have you tried using the exclusions that are available within the
> dependency declarations?
>
> If this webservices.jar is needed in a project (say project-a) which
> is included within an ear (say ear-project), you would define the
> following dependency within the ear-project pom:
>
>     <dependency>
>       <groupId>whatever</groupId>
>       <artifactId>project-a</artifactId>
>       <version>1.0</version>
>       <scope>compile</scope>
>       <exclusions>
>         <exclusion>
>           <groupId>whatever</groupId>
>           <artifactId>webservices</artifactId>
>         </exclusion>
>       </exclusions>
>     </dependency>
>
> With this approach, you could use a compile scoped dependency but not
> have it included in the ear.
>
> Hope that helps,
>
> David
>
> On 2/3/06, Lee Meador <le...@leemeador.com> wrote:
> > I have a jar (webservices.jar) that I need for these things:
> >
> > 1) Compile main source.
> > 2) Run tests in projects that are dependant on this one.
> >
> > But not for running the main source since that will run in the ejb
> > container.
> >
> > <scope>provided</scope> doesn't work because the jar isn't available for
> the
> > tests in the dependent projects which need to instantiate a class from
> the
> > jar but not to call it.
> > <scope>compile</scope> doesn't work because the jar ends up inside the
> ear
> > <scope>test</scope> doesn't work because the main code doesn't compile.
> >
> > Am I looking at this wrong somehow?
> >
> > The one solution I have found is to put it as "provided" in this project
> and
> > put it as 'test" in another project that runs tests that need classes.
> (I
> > use the term "project" to mean a think with a POM of its own.) The
> problems
> > with this are:
> >
> > 1) I can't run any such tests in the same project. (I can live with
> this.)
> > 2) I have to put the dependency in the other project even though it is
> only
> > needed when running the test that references this project. That seems
> > "wrong" in some way.
> >
> > Any ideas?
> >
> > -- Lee Meador
> > Sent from gmail. My real email address is lee@leemeador.com
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>


--
-- Lee Meador
Sent from gmail. My real email address is lee@leemeador.com

Re: What scope is like 'provided' and 'test' together?

Posted by "David H. DeWolf" <dd...@apache.org>.
Lee,

Have you tried using the exclusions that are available within the
dependency declarations?

If this webservices.jar is needed in a project (say project-a) which
is included within an ear (say ear-project), you would define the
following dependency within the ear-project pom:

    <dependency>
      <groupId>whatever</groupId>
      <artifactId>project-a</artifactId>
      <version>1.0</version>
      <scope>compile</scope>
      <exclusions>
        <exclusion>
          <groupId>whatever</groupId>
          <artifactId>webservices</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

With this approach, you could use a compile scoped dependency but not
have it included in the ear.

Hope that helps,

David

On 2/3/06, Lee Meador <le...@leemeador.com> wrote:
> I have a jar (webservices.jar) that I need for these things:
>
> 1) Compile main source.
> 2) Run tests in projects that are dependant on this one.
>
> But not for running the main source since that will run in the ejb
> container.
>
> <scope>provided</scope> doesn't work because the jar isn't available for the
> tests in the dependent projects which need to instantiate a class from the
> jar but not to call it.
> <scope>compile</scope> doesn't work because the jar ends up inside the ear
> <scope>test</scope> doesn't work because the main code doesn't compile.
>
> Am I looking at this wrong somehow?
>
> The one solution I have found is to put it as "provided" in this project and
> put it as 'test" in another project that runs tests that need classes. (I
> use the term "project" to mean a think with a POM of its own.) The problems
> with this are:
>
> 1) I can't run any such tests in the same project. (I can live with this.)
> 2) I have to put the dependency in the other project even though it is only
> needed when running the test that references this project. That seems
> "wrong" in some way.
>
> Any ideas?
>
> -- Lee Meador
> Sent from gmail. My real email address is lee@leemeador.com
>
>

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