Take the 2-minute tour ×

I've got 2 projects using Maven. The first one is a library containing utility classes and methods. The second project is an actual application that has the library as a dependency. My library uses internally a third-party library.

So these are the dependencies: - My library: depends on the third-party library - My application: depends on my library.

However, I don't want the third-party library classes to be available at compile time in my application. This is because the application is supported by a large team and I want to prevent people from accidentally using methods from the third-party library in the application given that some class names and some method names are similar between the two. Of course the third-par ty library will have to be available in my application at runtime.

If the scope for all my dependencies was compile, it wouldn't achieve my goal. Is there a way to achieve this in Maven 3?

share|improve this question
add comment

1 Answer

up vote 7 down vote accepted

Very good question and unfortunately you can't do this using Maven 3, or 2, or any other version, because of its fundamental design. What you're asking about is actually a desired and ideal behaviour since in fact any artifact's compile dependencies should be transitive with runtime scope. However, design like this leads to some problems. As you can read at Maven's Introduction to the Dependency Mechanism about compile scope:


So, as you see, what you require is actually the proper design of this behaviour which is unfortunately impossible to implement.

share|improve this answer
I was hoping there was a way to do it. Thanks for your answer, Michal. –  Juanal Flores Jun 27 '12 at 8:00
add comment

Your Answer


