I have a legacy war project that depends on a jar project, the jar project needs to add a few unmanaged jars to the classpath for compilation. But these jars should not be packaged in the war. So my question is how do I remove these entries from the fullClasspath. The following won’t work:
val excludeFilter = "(servlet-api.jar)|(gwt-dev.jar)|(gwt-user.jar)"
val filteredCP = cp.flatMap({ entry =>
val jar = entry.data.getName()
if (jar.matches(excludeFilter)) {
Nil
} else {
Seq(entry)
}
})
fullClasspath in Runtime = filteredCP
I am pretty sure there must be simple way to do this but so far it has eluded me.
Edit: Based on Pablo’s sugestion to use the managed classpath instead of the unmanaged I can rephrase the question as: how do you add local jars to the managedClasspath. My jars are placed in a local folder with a (very) nonstandard layout:
lib/testng.jar
lib/gwt/2.3/gwt-user.jar
lib/jetty/servlet.jar
So basically I am looking for something like:
libraryDependencies += "testng" % "provided->test"
libraryDependencies += "gwt" % "2.3" % "gwt-user" % "provided->compile"
libraryDependencies += "jetty" % "servlet" % "provided->default"
allowing me to grab jars from my own local lib folder.
Some information is provided on the Classpaths page, but it is not very clear or detailed. The information is also available using the
inspectcommand, described on the Inspecting Settings page.Basically, for a configuration X, in a short-hand notation:
So, normally, when you want to add unmanaged libraries, you add them to
unmanagedJars. For example, if you add libraries tounmanagedJars in Compile, then sbt will correctly include the libraries on theunmanagedClasspathforCompile,Runtime, andTest.However, you want explicit control here. Add the libraries only to the
unmanagedClasspathyou want the jars on, which isunmanagedClasspath in Compile. For example, in sbt 0.11.0+:Assuming the war plugin uses the Runtime classpath, those jars will only show up on the compile classpath and not in the war.