mirror of https://github.com/sbt/sbt.git
Merge pull request #1694 from sbt/wip/mainClassBreakage
Fix the run logic so the mainClass setting is actually used when set.
This commit is contained in:
commit
ed0f3c9c95
|
|
@ -264,7 +264,7 @@ object Defaults extends BuildCommon {
|
|||
definedSbtPlugins <<= discoverPlugins,
|
||||
discoveredSbtPlugins <<= discoverSbtPluginNames,
|
||||
inTask(run)(runnerTask :: Nil).head,
|
||||
selectMainClass := pickMainClass(discoveredMainClasses.value) orElse askForMainClass(discoveredMainClasses.value),
|
||||
selectMainClass := mainClass.value orElse askForMainClass(discoveredMainClasses.value),
|
||||
mainClass in run := (selectMainClass in run).value,
|
||||
mainClass := pickMainClassOrWarn(discoveredMainClasses.value, streams.value.log),
|
||||
run <<= runTask(fullClasspath, mainClass in run, runner in run),
|
||||
|
|
|
|||
|
|
@ -0,0 +1,22 @@
|
|||
|
||||
|
||||
lazy val main = project.settings(
|
||||
organization := "org.scala-sbt.testsuite.example",
|
||||
name := "has-main",
|
||||
version := "1.0-SNAPSHOT"
|
||||
)
|
||||
|
||||
lazy val user = project.settings(
|
||||
fullResolvers := fullResolvers.value.filterNot(_.name == "inter-project"),
|
||||
libraryDependencies += (projectID in main).value,
|
||||
mainClass in Compile := Some("Test")
|
||||
)
|
||||
|
||||
// NOTE - This will NOT work, as mainClass must be scoped by Compile (and optionally task) to function correctly).
|
||||
lazy val user2 = project.settings(
|
||||
fullResolvers := fullResolvers.value.filterNot(_.name == "inter-project"),
|
||||
libraryDependencies += (projectID in main).value,
|
||||
mainClass := Some("Test")
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
object Test {
|
||||
def main(args: Array[String]): Unit = {
|
||||
println("SUCCESS")
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
> main/publishLocal
|
||||
> user/run
|
||||
-> user2/run
|
||||
Loading…
Reference in New Issue