Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SBT how to run InputTask

Tags:

scala

sbt

I am creating some custom tasks in my SBT project and need to call other tasks for that.

How can i call inputTasks from inside my tasks and support them some input?

like image 576
Alex Avatar asked Feb 19 '12 19:02

Alex


1 Answers

Since you can factor your own tasks around this I'm assuming you're trying to use the run task. It took a bit of digging, but I've finally made it work; in a nutshell, this is what you do (assuming your task is named deployTask, tweak to match your needs):

deployTask <<= ( fullClasspath in Compile, runner ) map { ( classpath, runner ) =>
        val logger = ConsoleLogger()    // Not sure this is optimal
        Run.executeTrapExit( {
            Run.run( "com.sample.MainClass", 
                     classpath map { _.data }, 
                     Seq( "option1", "option2", "..." ),  // <-- Options go here
                     logger )( runner )
        }, logger )
    }

This doesn't invoke the InputTask directly (I haven't found a way to do that yet), but it at least lets you run arbitrary Java code.

like image 107
Tomer Gabel Avatar answered Oct 05 '22 18:10

Tomer Gabel