How do you prevent the classpath of subprojects to be included in the classpath of the top-level project?
I inherited a project that has a number of subprojects. During development, you can start the actual product by calling run
on the top-level project. However, for running the product, you don't need the classpath of all subprojects to be included. In fact, some subprojects have a classpath that should definitely not be included in the top-level runClasspath
. How can you do that? How can you explicitly exclude the classpath of a subpr开发者_运维问答oject from the top-level classpath?
I'll answer my own question first. I don't feel it's the right approach, but it seems to work. Suppose that you defined a subproject like this:
lazy val fooSub = project(....)
... then it seems to be possible to prevent the fooSub
's classpath to be included in the top-level classpath by adding this to the definition of your top-level project:
override def topologicalSort = super.topologicalSort.filter(_ != fooSub)
This works, because fullClasspath
seems to use topologicalSort
to find all subprojects, to include their classpaths to its own classpath. It seems a little too aggressive for my taste though. Hard to tell if it breaks somewhere else.
精彩评论