maven-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tibor Digana (JIRA)" <j...@codehaus.org>
Subject [jira] (MNG-2205) "provided" scope dependencies must be transitive
Date Sat, 16 Nov 2013 22:15:20 GMT

    [ https://jira.codehaus.org/browse/MNG-2205?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=335779#comment-335779
] 

Tibor Digana edited comment on MNG-2205 at 11/16/13 4:14 PM:
-------------------------------------------------------------

I am using Maven 3.1.1
This bug is very important and needs to be fixed.
Especially in Java enterprise architecture the transitive scope of provided is used.
You have inheritance of modules + parent in reactor:

webapp module inherits(war) -> services(jar) -> dao(jar)

So the DAO is dependent on Hibernate. The own Hibernate's dependencies (like. hibernate-jpa-2.0-api,
...) should be excluded, but the same javax artifacts should be included with the scope provided.
The scope=provided on e.g. JPA API is necessary because we want to have own Hibernate's dependencie
in compile time and tests as well. Additionally, the WAR file should NOT have libraries with
javax packages in WEB-INF/lib.

If you compile DAO module only, it succeeds.
In reality you compile the parent POM in reactor, the build fails in module "services". The
class from provided artifact was not inherited by the module "services". The webapp module
wouldn't inherit it either.
So the people make a workaround so that they put the same dependency with provided scope in
module services or all modules. 

This is terrible because:
+ the inheritance in Maven is then useless
+ you duplicated the same dependencies with same scope
+ more work when maintaining the modules
+ the POM files are huge

So the temporary workaround would be to create parents Services-BOM and DAO-BOM with packaging=pom.
Inheritance:
Services-BOM -> DAO-BOM -> reactor's POM
The DAO will have parent DAO-BOM with provided artifacts, and services will have parent Services-BOM.
The problem with this impractical workaround is that you cannot use profiles otherwise you
are on the beginning again.
Services-BOM -> DAO-BOM have no noition of profiles in Maven 3.1.1.
You need the profile bacause the build needs to be customized for different appication servers
and anything else.

Thx
                
      was (Author: tibor17):
    I am using Maven 3.1.1
This bug is very important and needs to be fixed.
Especially in Java enterprise architecture the transitive scope of provided is used.
You have inheritance of modules + parent in reactor:

webapp module inherits(war) -> services(jar) -> dao(jar)

So the DAO is dependent on Hibernate. The own Hibernate's dependencies (like. hibernate-jpa-2.0-api,
...) should be excluded, but the same javax artifacts should be included with the scope provided.
The scope=provided on e.g. JPA API is necessary because we want to have own Hibernate's dependencie
in compile time and tests as well. Additionally, the WAR file should NOT have libraries with
javax packages in WEB-INF/lib.

If you compile DAO module only, it succeeds.
In reality you compile the parent POM in reactor, the build fails in module "services". The
class from provided artifact was not inherited by the module "services". The webapp module
wouldn't inherit it either.
So the people make a worakaround so that they put the same dependency with provided scope
in module services or all modules. 

This is terrible because:
+ the inheritance in Maven is then useless
+ you duplicated the same dependencies with same scope
+ more work when maintaining the modules
+ the POM files are huge

So the temporary workaround would be to create parents Services-BOM and DAO-BOM with packaging=pom.
Inheritance:
Services-BOM -> DAO-BOM -> reactor's POM
The DAO will have parent DAO-BOM with provided artifacts, and services will have parent Services-BOM.
The problem with this impractical workaround is that you cannot use profiles otherwise you
are on the beginning again.
Services-BOM -> DAO-BOM have no noition of profiles in Maven 3.1.1.
You need the profile bacause the build needs to be customized for different appication servers
and anything else.

Thx
                  
> "provided" scope dependencies must be transitive
> ------------------------------------------------
>
>                 Key: MNG-2205
>                 URL: https://jira.codehaus.org/browse/MNG-2205
>             Project: Maven 2 & 3
>          Issue Type: Bug
>          Components: Dependencies
>            Reporter: David Boden
>            Priority: Critical
>             Fix For: 3.x / Backlog
>
>         Attachments: transitivetest.zip
>
>
> A provided scope dependency can also be thought of as "compile-only".
> Project A requires Sybase JConnect on the runtime classpath. Project A declares a "provided"
dependency on Sybase JConnect.
> Project B depends upon Project A. Project B declares a "compile" dependency on Project
A.
> Project C depends upon Project B. Project C declares a "compile" dependency on Project
B.
> C
> | - compile dependency
> B
> | - compile dependency
> A
> | - provided dependency
> Sybase JConnect
> So, does Project C transitively depend on Sybase JConnect. Yes, of course! The "provided"
dependency needs to be transitive.
> Ultimately, when Project C gets deployed, Sybase JConnect needs to be somewhere on the
runtime classpath in order for the application to function. It's valid for Project C to assume
that Sybase JConnect is available and use JDBC all over the Project C code. Project C is safe
to do this because it can happily deduce that Sybase JConnect will be there in the runtime
environment because Project A NEEDS IT.
> I've got Use Cases all over my aggregated build which make it absolutely critical and
common sense that provided scope dependencies are transitive. For the (very rare) odd case
where you don't want to inherit provided dependencies, you can <exclude/> them.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message