SBT how to run InputTask

二次信任 提交于 2020-01-12 18:51:50

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/9352400/sbt-how-to-run-inputtask

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!