1

I am trying to add a non-play Java project as a sub-project. The main project is a Play Java Application and the sub-project is in the same directory as the main-project. I am following instruction given here. My build.sbt looks like

import play.Project._

name := "main-project"

version := "1.0"

libraryDependencies ++= Seq(javaJdbc, javaEbean)

playJavaSettings

lazy val mainProject = project.in(file("."))
    .aggregate(subProject)
    .depends(subProject)

lazy val subProject = project.in(file("../sub-projects/sub-project-1"))

Here is my directory structure

D:
|-- projects
|   |-- main-project
|   |-- sub-projects
|   |   |   |-- sub-project-1
|   |   |   |-- sub-project-2

When I try to compile the main project, I get the following error.

[info] Loading project definition from D:\projects\main-project\project
D:\projects\main-project\build.sbt:13: error: value depends is not a member of sbt.Project
possible cause: maybe a semicolon is missing before `value depends'?
.depends(subProject)
 ^
[error] sbt.compiler.EvalException: Type error in expression
[error] Use 'last' for the full log.
waqas
  • 124
  • 1
  • 10
  • 1
    I've submitted a pull request to fix the broken documentation example: https://github.com/playframework/playframework/pull/2453 – Ben McCann Mar 06 '14 at 05:47

1 Answers1

1

It should be dependsOn not depends.

You should also point to both projects from the folder root:

name := "java-test"

version := "1.0-SNAPSHOT"

playJavaSettings

lazy val mainProject = project.in(file("."))
    .aggregate(subProject, playProject)
    .dependsOn(subProject, playProject)


lazy val subProject = project.in(file("sub-projects/sub-project-1"))

//play project depends on subProject...
lazy val playProject = project.in(file("play-project")).dependsOn(subProject)
ed.
  • 2,696
  • 3
  • 22
  • 25
  • It solves the error that I have posted. But the project still doesn't compile. I use a sub-project package in the main project and when I compile, it says, "package org.subproject.package does not exist". Are there further changes to be made in built.sbt? – waqas Feb 17 '14 at 14:16
  • if `playProject` needs something in `subProject` you'll need to define that dependency: `playProject = project.in(...).dependsOn(subProject)`. I've updated the answer. – ed. Feb 19 '14 at 11:57
  • Doesn't work. I am getting the same error. Another thing that there is no "java-test". Just two project. Play project and another non-play project. The Play project uses classes from the non-play project. The non-play project is a standard eclipse project with no build.sbt. – waqas Feb 19 '14 at 13:31
  • 1
    I misunderstood - if the other project is not using sbt, you'll need to create the jar and either publish it to an Ivy repository or add the library to the `libs` folder of your sbt project. see the sbt docs on library dependencies: http://www.scala-sbt.org/release/docs/Getting-Started/Library-Dependencies. – ed. Feb 19 '14 at 14:12