maven dependency scopes


Does does IDEA handle dependency scopes when a project is synchronized with pom.xml? In other words, how would IDEA set up a jar that is only needed during compilation but is provided by the environment at run-time or a jar that is only needed when running unit tests.



I don't think IDEA supports scopes. Here is my JIRA issue about it:


just voted for the issue. thanks


I just voted for this fix as well.


My experience is limited to Web projects (WAR files) and as far as I can tell IDEA works fine.

If I have a dependency in my Maven module with scope 'provided' or 'test', IDEA automatically configures these as 'Do not package' for the Web module.

Am I misunderstanding something?


It appears that Web modules export values are set properly sometimes. However for a regular java module, that is not the case.

For example I have a java module with the following dependencies scope defined with test and provided

junit junit 3.8.1 test log4j log4j 1.2.13 provided ]]>

After importing the master pom file, the sub-module is exporting both junit and log4j. Even if I open the sub-module pom file as it's own project, it is still exporting both of these jars. This is different behavior than what the maven build project would do.

The workaround is to manually uncheck the jars that should not be exported, but that can get really hairy when you're dealing with spring or hibernate libraries which have dozens of dependent jars, some with conflicting versions of the same jar.


Please sign in to leave a comment.