maven-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ralph Pöllath <li...@poellath.org>
Subject Re: How to use dependencyManagement?
Date Thu, 29 Sep 2005 16:36:42 GMT
On 29.09.2005, at 16:19, John Casey wrote:
> If you specify these two dependencies directly in your own dependency
> set, and set their scope to provided, it should work.

That's what I thought. Doesn't work for me though (I think it did  
with previous versions):

// pom.xml
<project>
     <modelVersion>4.0.0</modelVersion>
     <groupId>test</groupId>
     <artifactId>test</artifactId>
     <packaging>war</packaging>
     <version>0.1</version>

     <dependencies>
         <dependency>
             <groupId>javax.servlet</groupId>
             <artifactId>servlet-api</artifactId>
             <version>2.4</version>
             <scope>provided</scope>
         </dependency>

        <dependency>
             <groupId>springframework</groupId>
             <artifactId>spring-web</artifactId>
             <version>1.2.4</version>
             <exclusions>
                 <!-- faces api not available on repo1 -->
                 <exclusion>
                     <groupId>javax.faces</groupId>
                     <artifactId>jsf-api</artifactId>
                 </exclusion>
             </exclusions>
         </dependency>
     </dependencies>
</project>

// create web.xml to make maven happy
$ mkdir -p src/main/webapp/WEB-INF
$ touch src/main/webapp/WEB-INF/web.xml

$ m2 package
[INFO]  
------------------------------------------------------------------------ 
----
[INFO] Building test:test:war:0.1
[INFO]    task-segment: [package]
[INFO]  
------------------------------------------------------------------------ 
----
[INFO] [resources:resources]
[WARNING]
         Artifact javax.servlet:servlet-api:jar:2.4 has scope  
'provided' replaced with 'compile'
         as a dependency has given a broader scope. If this is not  
intended, use -X to locate the dependency,
         or force the desired scope using dependencyManagement.
...
[INFO] [war:war]
[INFO] Copy webapp resources to test-0.1
[INFO] Assembling webapp test in test-0.1
[INFO] Generating war test-0.1.war
[INFO] Building war: test-0.1.war
[INFO] BUILD SUCCESSFUL

// oops
$ ls target/test-0.1/WEB-INF/lib | grep servlet
servlet-api-2.4.jar

> FYI, DependencyManagement information is only triggered on demand.  
> That
> is, the info in the DependencyManagement section will be triggered if
> you specify a dependency directly within your POM that matches the
> groupId/artifactId of the info given in DependencyManagement. When  
> this
> happens, any specification in the original dependency will dominate  
> over
> the corresponding info in the DependencyManagement section.

This means I can use a parent pom to specify default dependency info  
which can be overridden by child poms. Nice.

Thanks,
-Ralph.

> Ralph Pöllath wrote:
> | Hi,
> |
> | I get the following warning when packaging my webapp project:
> |
> | [WARNING]
> |         Artifact javax.servlet:jsp-api:jar:2.0 has scope 'provided'
> | replaced with 'compile'
> |         as a dependency has given a broader scope. If this is not
> | intended, use -X to locate the dependency,
> |         or force the desired scope using dependencyManagement.
> |
> | Using -X tells me the dependency on javax.servlet:jsp-api-2.0 is
> | introduced by springframework:spring-web-1.2.5, so I tried to  
> exclude
> | it like this:
> |
> | <dependency>
> |     <groupId>springframework</groupId>
> |     <artifactId>spring-web</artifactId>
> |     <version>1.2.4</version>
> |     <exclusions>
> |         <exclusion>
> |             <groupId>javax.servlet</groupId>
> |             <artifactId>jsp-api</artifactId>
> |         </exclusion>
> |     </exclusions>
> | </dependency>
> |
> | But unfortunately, jsp-api-2.0.jar still ends up in my war file,
> | breaking my app.
> |
> | Now I'd like to "force the desired scope using  
> dependencyManagement"  as
> | mentioned in the warning, but cannot find any info on how to use   
> the
> | dependencyManagement section in the pom.
> |
> | I'd like to use it to tell m2 to always set the scope of
> | javax.servlet:jsp-api and javax.servlet:servlet-api to provided,  
> and  to
> | completely ignore some transitive dependencies like ojb and   
> toplink,
> | which are introduced by springframework:spring-orm, for  example.
> |
> | Is that possible?
> |
> | Cheers,
> | -Ralph.
> |
> |
> |
> |
> |  
> ---------------------------------------------------------------------
> | To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> | For additional commands, e-mail: users-help@maven.apache.org
> |
> |
> |
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.2.6 (GNU/Linux)
>
> iD8DBQFDO/f4K3h2CZwO/4URAhdxAJ9B0aNQT47F1Xz6sWXpqq5ix6c5SwCfTnwf
> wtBsedkBkFQDCfc0OeBL6R0=
> =HVC6
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> 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


Mime
View raw message