简体   繁体   中英

How to use dependencies and modules in play-framework 2.0

Currently in playframework 1.2.4 there is a such thing like module and project , if a project depends on a module, user should put appropriate line in configuration, into dependecies.yml file.

Now, as I can see, reading exiting documentation, there is an idea if subprojects /<my_home>/play/documentation/manual/build/SBTSubProjects.md instead of modules??

Taking into consideration that now there is no 'dependecies.yml' file anymore, I would say that idea of suprojects is going to substitute the modules?

Then, what I do:

cd projects
play new newProject
mkdir modules
cd modules
play new project1
play new project2
play new common

vi /projects/newProject/project/Build.scala

editing it like this:

object ApplicationBuild extends Build {

  val appName = "newProject"
  val appVersion = "1.2"

  val common = PlayProject(
    appName + "-common", appVersion, path = file("modules/common")
  )

  val project1 = PlayProject(
    appName + "-project1", appVersion, path = file("modules/project1")
  ).dependsOn(common)

  val project2 = PlayProject(
    appName + "-project2", appVersion, path = file("modules/project2")
  ).dependsOn(common)

  val main = PlayProject(
    appName, appVersion
  ).dependsOn(
    project1, project2
  )
}

But, then ... if I try to run 'project1': cd /projects/newProject/module/project1

play run

It would know nothing about the dependency to 'common' project for 'project1' (i guess), because I did not modify project1/project/Build.scala ..

So, what I should do with that? How 'project1' would know about its dependencies in run-time?

我目前仅找到一种解决方案:只需在newProject/modules/project1/modules/common创建一个链接-> /newProject/modules/common

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM