aboutsummaryrefslogtreecommitdiff
path: root/stage2/BasicBuild.scala
diff options
context:
space:
mode:
authorChristopher Vogt <oss.nsp@cvogt.org>2016-10-02 11:52:13 -0400
committerChristopher Vogt <oss.nsp@cvogt.org>2016-10-02 13:39:53 -0400
commitdde9ac16434e7ddb7f24504c864c78a87e043553 (patch)
tree11e06767cbf07ff1717f3ed735dea6f4520a4c21 /stage2/BasicBuild.scala
parent6b82f1ec42222b7e757ed8b79d56f30aabae96e6 (diff)
downloadcbt-dde9ac16434e7ddb7f24504c864c78a87e043553.tar.gz
cbt-dde9ac16434e7ddb7f24504c864c78a87e043553.tar.bz2
cbt-dde9ac16434e7ddb7f24504c864c78a87e043553.zip
clean up main class discovery mechanism and offer interactive choice
if multiple main classes are found
Diffstat (limited to 'stage2/BasicBuild.scala')
-rw-r--r--stage2/BasicBuild.scala14
1 files changed, 8 insertions, 6 deletions
diff --git a/stage2/BasicBuild.scala b/stage2/BasicBuild.scala
index baa6d26..98deddc 100644
--- a/stage2/BasicBuild.scala
+++ b/stage2/BasicBuild.scala
@@ -136,13 +136,15 @@ trait BaseBuild extends DependencyImplementation with BuildInterface with Trigge
)
}
- def runClass: String = lib.mainClasses ( compileTarget, classLoader(context.classLoaderCache) ) match {
- case f if f.length == 1 => f.head
- case f if f.length > 2 => System.err.println( " Multiple main classes defined in project." ); "None"
- case _ => "Main"
- }
+
+ def mainClasses: Seq[Class[_]] = compile.toSeq.flatMap( lib.mainClasses( _, classLoader(classLoaderCache) ) )
- def run: ExitCode = lib.runMainIfFound( runClass, context.args, classLoader(context.classLoaderCache) )
+ def runClass: Option[String] = lib.runClass( mainClasses ).map( _.getName )
+
+ def run: ExitCode = runClass.map( lib.runMain( _, context.args, classLoader(context.classLoaderCache) ) ).getOrElse{
+ logger.task( "No main class found for " ++ projectDirectory.string )
+ ExitCode.Success
+ }
def clean = {
lib.clean(