Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove dependency from libraryDependencies that was added by plugin?

I have a very classic build.sbt for Play 2.3 Scala project with the following libraryDependencies setting:

libraryDependencies ++= Seq(
  "org.scalatestplus" % "play_2.10" % "1.1.0" % "test"
  "org.mockito" % "mockito-core" % "1.9.5" % "test"
)

lazy val portal = (project in file(".")).enablePlugins(PlayScala)

The PlayScala plugin adds specs2 dependency that "pollutes" classpath and makes good import harder in IDE.

How can I remove a dependency from libraryDependencies?

like image 895
Yann Le Moigne Avatar asked Jun 17 '14 20:06

Yann Le Moigne


People also ask

How do I remove a project dependencies?

On the Project menu, choose Project Dependencies. The Project Dependencies dialog box opens. On the Dependencies tab, select a project from the Project drop-down menu. In the Depends on field, clear the check boxes beside any other projects that are no longer dependencies of this project.

How to exclude dependencies in SBT?

We exclude dependencies in SBT by using either the exclude or excludeAll keywords. It's important to understand which one to use: excludeAll is more flexible but cannot be represented in a pom. xml. Therefore, we should use exclude if a pom.

Where are dependencies downloaded in SBT?

All new SBT versions (after 0.7. x ) by default put the downloaded JARS into the . ivy2 directory in your home directory. If you are using Linux, this is usually /home/<username>/.

Which is the correct way to add dependencies in SBT file?

If you have JAR files (unmanaged dependencies) that you want to use in your project, simply copy them to the lib folder in the root directory of your SBT project, and SBT will find them automatically.


1 Answers

I solved a similar problem by adding the following to my Build.scala:

def excludeSpecs2(module: ModuleID): ModuleID =
  module.excludeAll(ExclusionRule(organization = "org.specs2"))

val main = Project(appName, file("."))
  .enablePlugins(play.PlayScala)
  .settings(libraryDependencies ~= (_.map(excludeSpecs2)))
like image 199
Hugh Avatar answered Sep 28 '22 12:09

Hugh