You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Mikael Andersson <ma...@gmail.com> on 2006/03/31 23:52:00 UTC

simple way of changin scope for dependencies?

Hi,
I have a pom used with the jetty6 plugin and myfaces (via the archetype),
for the jetty plugin to work properly I had to change from provided to
compile for a depency and add a couple of tomcat jars.

I wonder if there is a nice and simple way of changing the scope of certain
dependencies without editing the pom file all the time, like using profiles
or environment variables? Otherwise I will probably forget to change the pom
and bundle those jars with the war running on tomcat :(

Had a quick go with -DscopeVal=compile and then in the pom
<scope>${scopeVal}</scope> , which failed. I am relatively new to maven2 and
not that familiar with the more advanced stuff, so help please :)

Thanks,
 Micke

Re: simple way of changin scope for dependencies?

Posted by Wayne Fay <wa...@gmail.com>.
Cool, I honestly wasn't aware that you could include dependencies in
the profiles like that, I'm obviously pretty new to profiles. ;-)

I'm curious if you could combine <dependencyManagement> to handle
version numbers in pom.xml along with these profiles to include
certain deps with scope=compile in some builds and not include them
with other builds using scope=provided etc. Sounds hairy but probably
would work, just because Maven2 is so cool.

Wayne

On 4/1/06, Mikael Andersson <ma...@gmail.com> wrote:
> That solved the problem, thanks.
>
> For those interested, I simply added this to the pom :
>    <profiles>
>        <profile>
>            <id>jettyConfig</id>
>            <dependencies>
>                <dependency>
>                    <groupId>javax.servlet</groupId>
>                    <artifactId>jsp-api</artifactId>
>                    <version>2.0</version>
>                    <scope>compile</scope>
>                </dependency>
>
>                <dependency>
>                    <groupId>tomcat</groupId>
>                    <artifactId>jasper-compiler</artifactId>
>                    <version>5.5.9</version>
>                    <scope>compile</scope>
>                </dependency>
>                <dependency>
>                    <groupId>tomcat</groupId>
>                    <artifactId>jasper-runtime</artifactId>
>                    <version>5.5.9</version>
>                    <scope>compile</scope>
>                </dependency>
>                <dependency>
>                    <groupId>tomcat</groupId>
>                    <artifactId>jasper-compiler-jdt</artifactId>
>                    <version>5.5.9</version>
>                    <scope>compile</scope>
>                </dependency>
>            </dependencies>
>        </profile>
>    </profiles>
>
> Which overrides the scope for the jsp-api jar, and adds the tomcat stuff :)
> With this in the pom, just run with : mvn -P jettyConfig clean jetty6:run
>
> Maven2 is great, the more I learn the more I love it.
>
> Cheers,
>  Mikael
>
> On 31/03/06, Alexandre Poitras <al...@gmail.com> wrote:
> >
> > Take a look at the profiles :
> > http://maven.apache.org/guides/introduction/introduction-to-profiles.html
> >
> > I think the dependenciesManagement section is what you are looking for.
> >
> > On 3/31/06, Mikael Andersson <ma...@gmail.com> wrote:
> > > Hi,
> > > I have a pom used with the jetty6 plugin and myfaces (via the
> > archetype),
> > > for the jetty plugin to work properly I had to change from provided to
> > > compile for a depency and add a couple of tomcat jars.
> > >
> > > I wonder if there is a nice and simple way of changing the scope of
> > certain
> > > dependencies without editing the pom file all the time, like using
> > profiles
> > > or environment variables? Otherwise I will probably forget to change the
> > pom
> > > and bundle those jars with the war running on tomcat :(
> > >
> > > Had a quick go with -DscopeVal=compile and then in the pom
> > > <scope>${scopeVal}</scope> , which failed. I am relatively new to maven2
> > and
> > > not that familiar with the more advanced stuff, so help please :)
> > >
> > > Thanks,
> > >  Micke
> > >
> > >
> >
> >
> > --
> > Alexandre Poitras
> > Québec, Canada
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > For additional commands, e-mail: users-help@maven.apache.org
> >
> >
>
>

Re: simple way of changin scope for dependencies?

Posted by Mikael Andersson <ma...@gmail.com>.
That solved the problem, thanks.

For those interested, I simply added this to the pom :
    <profiles>
        <profile>
            <id>jettyConfig</id>
            <dependencies>
                <dependency>
                    <groupId>javax.servlet</groupId>
                    <artifactId>jsp-api</artifactId>
                    <version>2.0</version>
                    <scope>compile</scope>
                </dependency>

                <dependency>
                    <groupId>tomcat</groupId>
                    <artifactId>jasper-compiler</artifactId>
                    <version>5.5.9</version>
                    <scope>compile</scope>
                </dependency>
                <dependency>
                    <groupId>tomcat</groupId>
                    <artifactId>jasper-runtime</artifactId>
                    <version>5.5.9</version>
                    <scope>compile</scope>
                </dependency>
                <dependency>
                    <groupId>tomcat</groupId>
                    <artifactId>jasper-compiler-jdt</artifactId>
                    <version>5.5.9</version>
                    <scope>compile</scope>
                </dependency>
            </dependencies>
        </profile>
    </profiles>

Which overrides the scope for the jsp-api jar, and adds the tomcat stuff :)
With this in the pom, just run with : mvn -P jettyConfig clean jetty6:run

Maven2 is great, the more I learn the more I love it.

Cheers,
 Mikael

On 31/03/06, Alexandre Poitras <al...@gmail.com> wrote:
>
> Take a look at the profiles :
> http://maven.apache.org/guides/introduction/introduction-to-profiles.html
>
> I think the dependenciesManagement section is what you are looking for.
>
> On 3/31/06, Mikael Andersson <ma...@gmail.com> wrote:
> > Hi,
> > I have a pom used with the jetty6 plugin and myfaces (via the
> archetype),
> > for the jetty plugin to work properly I had to change from provided to
> > compile for a depency and add a couple of tomcat jars.
> >
> > I wonder if there is a nice and simple way of changing the scope of
> certain
> > dependencies without editing the pom file all the time, like using
> profiles
> > or environment variables? Otherwise I will probably forget to change the
> pom
> > and bundle those jars with the war running on tomcat :(
> >
> > Had a quick go with -DscopeVal=compile and then in the pom
> > <scope>${scopeVal}</scope> , which failed. I am relatively new to maven2
> and
> > not that familiar with the more advanced stuff, so help please :)
> >
> > Thanks,
> >  Micke
> >
> >
>
>
> --
> Alexandre Poitras
> Québec, Canada
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: simple way of changin scope for dependencies?

Posted by Alexandre Poitras <al...@gmail.com>.
Take a look at the profiles :
http://maven.apache.org/guides/introduction/introduction-to-profiles.html

I think the dependenciesManagement section is what you are looking for.

On 3/31/06, Mikael Andersson <ma...@gmail.com> wrote:
> Hi,
> I have a pom used with the jetty6 plugin and myfaces (via the archetype),
> for the jetty plugin to work properly I had to change from provided to
> compile for a depency and add a couple of tomcat jars.
>
> I wonder if there is a nice and simple way of changing the scope of certain
> dependencies without editing the pom file all the time, like using profiles
> or environment variables? Otherwise I will probably forget to change the pom
> and bundle those jars with the war running on tomcat :(
>
> Had a quick go with -DscopeVal=compile and then in the pom
> <scope>${scopeVal}</scope> , which failed. I am relatively new to maven2 and
> not that familiar with the more advanced stuff, so help please :)
>
> Thanks,
>  Micke
>
>


--
Alexandre Poitras
Québec, Canada

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