5

can a sbt sub project have its own project directory? or only the root project can project directory with .scala helper files for the build?. Below is my current build scructure. The /my-project/sub-projects/sub-project-1/build.sbt is not able to access objects defined in /my-project/sub-projects/sub-project-1/SubProjectHelper.scala.

/my-project
  build.sbt
  /projects
    Helper.scala
  sub-projects
    sub-project-1
      build.sbt
      /projects
        SubProjectHelper.scala

Update: The below sbt definition in sub-project-1/build.sbt

lazy val localhost = (project in file(".")).settings (
    name := """localhost""",
    version := Common.version,
    scalaVersion := Common.scalaVersion,
    libraryDependencies ++= Common.dependencies,
    libraryDependencies ++= Localhost.dependencies
)

is failing with the below error

    libraryDependencies ++= Localhost.dependencies
                            ^
sbt.compiler.EvalException: Type error in expression
    at sbt.compiler.Eval.checkError(Eval.scala:384)
    at sbt.compiler.Eval.compileAndLoad(Eval.scala:183)
    at sbt.compiler.Eval.evalCommon(Eval.scala:152)
    at sbt.compiler.Eval.evalDefinitions(Eval.scala:122)
    at sbt.EvaluateConfigurations$.evaluateDefinitions(EvaluateConfigurations.scala:271)
    at sbt.EvaluateConfigurations$.evaluateSbtFile(EvaluateConfigurations.scala:109)
    at sbt.Load$.sbt$Load$$loadSettingsFile$1(Load.scala:712)

Common is defined in /my-project/projects/Common.scala and has no issues. But Localhost is defined in /my-project/sub-projects/sub-project-1/projects/SubProjectHelper.scala is not properly resolved in the sub-project-1 build.sbt

3 Answers 3

0

Yes, they can, and you even don't need to have sub-projects dir, just place sub-project-1 in my-project dir.

1
  • I have updated the question to add more info. can you let me know what went wrong?
    – rogue-one
    Feb 23, 2016 at 5:40
0

Usually (at least this is what scala/scala-seed.g8 ends up with) project subdirectory doesn't ends with an extra s like your directory structure.

You should rename projects to project.

0

The answer is no, unfortunately. As seen here

You cannot have a project subdirectory or project/*.scala files in the sub-projects. foo/project/Build.scala would be ignored.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.