Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8969043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:32:18+00:00 2026-06-15T17:32:18+00:00

I have a .scala build definition set up as follows: object build extends Build

  • 0

I have a .scala build definition set up as follows:

object build extends Build {
  lazy val root = Project("main", file(".")) aggregate(benchmark)
  lazy val benchmark = Project("benchmark", file("benchmark"))
}

I need to run re-start task on main project before running run task on benchmark (so I need to ensure that benchmark/run triggers main/re-start). Is there a way to specify such dependency?

EDIT: Seems I found the solution, so I will add it to this question in case somebody runs into the same problem. The idea is to create a custom version of reStart task, making it a Task instead of InputTask, since we don’t need to parse arguments. The full build.scala is as follows:

import sbt._
import Keys._
import cc.spray.revolver.RevolverPlugin.Revolver._
import cc.spray.revolver.Actions._
import cc.spray.revolver.AppProcess

object build extends Build {
  val noArgs = TaskKey[ExtraCmdLineOptions]("no-args")
  val noArgsTask = TaskKey[ExtraCmdLineOptions]("no-args") := { ExtraCmdLineOptions(Nil, Nil) }
  val reStartCustom = TaskKey[AppProcess]("re-start-custom")

  val reStartTask = reStartCustom <<= (streams, state, reForkOptions, mainClass in reStart, fullClasspath in Runtime, reStartArgs, noArgs in root)
    .map(restartApp)
    .updateState(registerAppProcess)
    .dependsOn(products in Compile)

  lazy val root: Project = Project("main", file("."), settings = Defaults.defaultSettings ++ Seq(noArgsTask, reStartTask)) aggregate(benchmark)
  lazy val benchmark: Project = Project("benchmark", file("benchmark"), settings = Defaults.defaultSettings ++ Seq(
    run in Compile <<= (reStartCustom in root, run in Compile in benchmark) {
      case (mainRestart, benchmarkRun) =>
        benchmarkRun.mapTask { runTask => mainRestart.flatMap(_ => runTask) }
    }
  ))
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T17:32:19+00:00Added an answer on June 15, 2026 at 5:32 pm

    There may be nicer ways to do it, but here is my take on it:

    import sbt._
    import Keys._
    
    object MyKeys {
      val restart = TaskKey[Unit]("re-start")
    }
    
    object build extends Build {
      import MyKeys._
      lazy val root: Project = Project("main",
        file("."),
        settings = Defaults.defaultSettings ++ Seq(
          restart := { println("***RESTART***") }
        )
      ) aggregate(benchmark)
      lazy val benchmark: Project = Project(
        "benchmark",
        file("benchmark"),
        settings = Defaults.defaultSettings ++ Seq(
          run  in Compile <<= (restart in root, run in Compile in benchmark){
            case (mainRestart, benchmarkRun) =>
              benchmarkRun.mapTask{ runTask => mainRestart.flatMap{ _ => runTask }
            }
          }
        )
      )
    }
    

    With this setup, sbt "project benchmark" run will first run the restart task on the main project, and then actually invoke the standard run command on project benchmark.

    Note that I added a restart TaskKey (and a dummy implementation in main) for illustration.

    As you can see, this looks a bit involved for such a simple requirement, but it is my (limited) experience that working with InputTasks/InputKeys (run being one) is always much more tricky than it ought to be (as opposed to plain Tasks/TaskKeys which are easier to handle).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a build.sbt file in my project root.. all my source files live
I have scala trait as follows trait Id { @javax.persistence.Id @GeneratedValue(strategy=GenerationType.IDENTITY) @BeanProperty var id:
I have a Scala/Java dual language project where I need to pass a Scala
I have a simple Scala project that runs without any problems inside Eclipse, however,
I have a project with mixed Java and Scala sources, following the instructions on
I'm trying to get SBT to build a project that could have more than
I am using buildr to build my scala project and suppose I want to
I am using SBT as my build tool for building a Scala project. My
I have a java maven project , i installed scala plugin for eclipse and
I have a scala object defined like the following: package com.example object Foo {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.