Problem with 'Provided' scope

Hi everyone,

I'm just trying the latest Intellij 9.0.2 version (I was previously using the 8.0.3 version) and I just found that it is now possible to set the dependencies scope to either Compile/Test/Runtime/Provided. Concerning the 'Provided' scope, the documentation says that "Provided: If this option is selected, the dependency is resolved and is available in classpath during the compilation, but is not included in classpath at runtime".

I've created a module with a single jar file (commons-lang.jar) as a dependency and then set the scope of this jar file to 'Provided'. I then created a single class that is using a class from the previous jar.

I was expecting the compilation to succeed and the execution of this class to fail... since the 'Provided' scope should have excluded the required jar at runtime. However, both the compilation and the execution succeeded.

When checking the command line generated by Intellij in the "Run" window, I saw my jar file in the -classpath section, which explains why the execution was successfull... although I was expecting the jar file to be missing here.

It looks like there is no difference between the 'Compile' and the 'Provided' scope... did I miss something ?

2 comments
Comment actions Permalink

It's a bug. Looks like 'provided' libraries are excluded from runtime classpath only for Maven projects. Could you please create an issue in our
tracker (http://youtrack.jetbrains.net/issues/IDEA)?

Hi everyone,

I'm just trying the latest Intellij 9.0.2 version (I was previously using the 8.0.3 version) and I just found that it is now possible to set the dependencies scope to either Compile/Test/Runtime/Provided. Concerning the 'Provided' scope, the documentation says that "Provided: If this option is selected, the dependency is resolved and is available in classpath during the compilation, but is not included in classpath at runtime".

I've created a module with a single jar file (commons-lang.jar) as a dependency and then set the scope of this jar file to 'Provided'. I then created a single class that is using a class from the previous jar.

I was expecting the compilation to succeed and the execution of this class to fail... since the 'Provided' scope should have excluded the required jar at runtime. However, both the compilation and the execution succeeded.

When checking the command line generated by Intellij in the "Run" window, I saw my jar file in the -classpath section, which explains why the execution was successfull... although I was expecting the jar file to be missing here.

It looks like there is no difference between the 'Compile' and the 'Provided' scope... did I miss something ?

---
Original message URL: http://devnet.jetbrains.net/message/5265996#5265996



--
Nikolay Chashnikov
Software Developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

0
Comment actions Permalink

IDEA-55925 'Provided' scope doesn't work

(thanks for confirming this is a bug Nikolay)

0

Please sign in to leave a comment.