You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Konrad Windszus (Jira)" <ji...@apache.org> on 2021/05/27 20:33:00 UTC

[jira] [Comment Edited] (MENFORCER-385) Enforce that transitive provided dependencies are contained in the runtime Maven classpath

    [ https://issues.apache.org/jira/browse/MENFORCER-385?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17352739#comment-17352739 ] 

Konrad Windszus edited comment on MENFORCER-385 at 5/27/21, 8:32 PM:
---------------------------------------------------------------------

The runtime classpath of Maven is completely irrelevant for WARs. But some libraries (=jars) are supposed to be used primarily in the context of servlet container (and therefore define servlet-api as 'provided') but in some use cases they are also used outside the usual container (i.e. from a Maven Mojo). In that case you have to make sure that the Maven runtime classpath contains all provided dependencies.

Another use case is OSGi bundles (with packaging "jar") where usually run time dependencies are given in "provided" scope. If used outside the OSGi container where the runtime classpath is relevant (e.g. a Maven Plugin) you must declare all those dependencies directly.


was (Author: kwin):
The runtime classpath of Maven is completely irrelevant for WARs. But some libraries are supposed to be used primarily in the context of servlet container (and therefore define servlet-api as 'provided') but in some use cases they are also used outside the usual container (i.e. from a Maven Mojo). In that case you have to make sure that the Maven runtime classpath contains all provided dependencies.

Another use case is OSGi bundles (with packaging "jar") where usually run time dependencies are given in "provided" scope. If used outside the OSGi container where the runtime classpath is relevant (e.g. a Maven Plugin) you must declare all those dependencies directly.

> Enforce that transitive provided dependencies are contained in the runtime Maven classpath
> ------------------------------------------------------------------------------------------
>
>                 Key: MENFORCER-385
>                 URL: https://issues.apache.org/jira/browse/MENFORCER-385
>             Project: Maven Enforcer Plugin
>          Issue Type: Improvement
>          Components: Standard Rules
>            Reporter: Konrad Windszus
>            Assignee: Robert Scholte
>            Priority: Major
>
> All dependencies with {{provided}} scope are not transitively inherited. While this isn't a problem usually during compile time it is a problem for Maven plugins at run time, as they use the Maven dependency classpath also at run time (https://maven.apache.org/guides/mini/guide-maven-classloading.html#3-plugin-classloaders). At run time they fail if the transitive provided dependency has not been declared explicitly.
> As manually specifying all transitive (but hidden) {{provided}} dependencies is a very error-prone process an enforcer rule for that would be highly beneficial. Especially as the transitive dependencies have to be rechecked once you upgrade to a newer version.
> Example:
> {code:java}
> My Maven Plugin "A" -> 3rd Party Library "B" -> Provided Dependency "C"{code}
> As "B" uses "C" at run time it needs to be declared as dependency of "A" as well otherwise you might see  {{java.lang.ClassNotFoundException}} when executing Maven plugin "A".



--
This message was sent by Atlassian Jira
(v8.3.4#803005)