Re: How to execute Task before update

29 views
Skip to first unread message

James Roper

unread,
May 8, 2013, 1:10:27 AM5/8/13
to simple-b...@googlegroups.com
I'm not 100% sure, except that the SBT guys have told me that

someTask <<= someTask.dependsOn(myTask)

won't always work.  Rather they say, there's usually some other setting lower down that you can (or should) configure that will do a much cleaner job.  So, what are you trying to achieve?

On Monday, May 6, 2013 3:18:22 AM UTC+10, Jaie Wilson wrote:
I'm trying to build a Plugin that executes a task prior to update running.

I can get my task to run prior to update if it's test:update or compile:update but if you execute the update command directly my task doesn't run.

objectMuPlugin extends Plugin {
 
 
object MyKeys {
    val myTask
= TaskKey[Unit]("my-task", "runs before update")
 
}

 
import MyKeys._

 
private def executeMyTask = (streams) map {
   
(out) => out.log.info("my task run")
 
}

 
def mytaskSettingsIn(conf: Configuration): Seq[Setting[_]] =
    inConfig
(conf)(Seq(
     
(update) <<= (update) dependsOn (myTask)
   
))

 
def mytaskSettings: Seq[Setting[_]] =
    mytaskSettingsIn
(Compile) ++
   
Seq[Setting[_]] (
      mytask
<<= executeMyTask,
      update
<<= update dependsOn (myTask)
   
)

}

I then load the settings in my other project and then running compile will execute myTask and then execute update. But If I just call update from the command line it won't run myTask before it.

Can anyone let me know what I need to change in order to do this?

Thanks,
Jaie
Reply all
Reply to author
Forward
0 new messages