scala - Running a sub-project main class -
i have built.sbt
references child project's main class own main class:
lazy val akka = (project in file(".")) .aggregate(api) .dependson(api) .enableplugins(javaapppackaging) lazy val api = project in file("api") scalaversion := "2.11.6" // referencing api code mainclass in (compile, run) := some("maslow.akka.cluster.node.clusternode") artifactname := { (sv: scalaversion, module: moduleid, artifact: artifact) => s"""${artifact.name}.${artifact.extension}""" } name in universal := name.value packagename in universal := name.value
however, each time run sbt run
following error:
> run [info] updating {file:/users/mark/dev/maslow-akka/}api... [info] resolving jline#jline;2.12.1 ... [info] done updating. [info] updating {file:/users/mark/dev/maslow-akka/}akka... [info] resolving jline#jline;2.12.1 ... [info] done updating. [info] running maslow.akka.cluster.node.clusternode [error] (run-main-0) java.lang.classnotfoundexception: maslow.akka.cluster.node.clusternode java.lang.classnotfoundexception: maslow.akka.cluster.node.clusternode @ java.lang.classloader.findclass(classloader.java:530)
as i've been doing research problem, first switched project api
akka
, opened console. there, can't find maslow
package though exists. after that, went api
folder , ran sbt console
, accessed aforementioned package fine. after this, sbt run
akka project works. why?
the folder api
pulled in via git read-tree
. there shouldn't special it. i'm using sbt 0.13.5
i think in multi-project build global line such as
mainclass in (compile, run) := ...
will swallowed without consequences, doesn't refer project.
probably following works:
mainclass in (compile, run) in thisbuild := ...
or add root project's settings:
lazy val akka = (project in file(".")) .aggregate(api) .dependson(api) .enableplugins(javaapppackaging) .settings( mainclass in (compile, run) := ... )
Comments
Post a Comment