mirror of https://github.com/sbt/sbt.git
Allow to manually add things in the classpath of launched apps
This commit is contained in:
parent
a50cb1bd85
commit
974dee8cf4
|
|
@ -75,6 +75,7 @@ object Util {
|
|||
class Helper(
|
||||
common: CommonOptions,
|
||||
rawDependencies: Seq[String],
|
||||
extraJars: Seq[File] = Nil,
|
||||
printResultStdout: Boolean = false,
|
||||
ignoreErrors: Boolean = false,
|
||||
isolated: IsolatedLoaderOptions = IsolatedLoaderOptions(),
|
||||
|
|
@ -648,7 +649,7 @@ class Helper(
|
|||
}
|
||||
|
||||
lazy val loader = new URLClassLoader(
|
||||
filteredFiles.map(_.toURI.toURL).toArray,
|
||||
(filteredFiles ++ extraJars).map(_.toURI.toURL).toArray,
|
||||
parentLoader
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package coursier
|
||||
package cli
|
||||
|
||||
import java.io.File
|
||||
import java.net.{ URL, URLClassLoader }
|
||||
|
||||
import caseapp._
|
||||
|
|
@ -114,6 +115,7 @@ case class Launch(
|
|||
val helper = new Helper(
|
||||
options.common,
|
||||
remainingArgs ++ options.isolated.rawIsolated.map { case (_, dep) => dep },
|
||||
extraJars = options.extraJars.map(new File(_)),
|
||||
isolated = options.isolated
|
||||
)
|
||||
|
||||
|
|
@ -123,8 +125,19 @@ case class Launch(
|
|||
else
|
||||
options.mainClass
|
||||
|
||||
val extraJars = options.extraJars.filter(_.nonEmpty)
|
||||
|
||||
val loader =
|
||||
if (extraJars.isEmpty)
|
||||
helper.loader
|
||||
else
|
||||
new URLClassLoader(
|
||||
extraJars.map(new File(_).toURI.toURL).toArray,
|
||||
helper.loader
|
||||
)
|
||||
|
||||
Launch.run(
|
||||
helper.loader,
|
||||
loader,
|
||||
mainClass,
|
||||
userArgs,
|
||||
options.common.verbosityLevel
|
||||
|
|
|
|||
|
|
@ -188,6 +188,9 @@ case class LaunchOptions(
|
|||
@Short("M")
|
||||
@Short("main")
|
||||
mainClass: String,
|
||||
@Short("J")
|
||||
@Help("Extra JARs to be added to the classpath of the launched application. Directories accepted too.")
|
||||
extraJars: List[String],
|
||||
@Recurse
|
||||
isolated: IsolatedLoaderOptions,
|
||||
@Recurse
|
||||
|
|
|
|||
Loading…
Reference in New Issue