简体   繁体   English

玩框架应用程序,如何导入scala项目

[英]Play framework application, how to import scala project

I'm new with the Play framework, and looks everything very straightforward, I have just one issue still: Which are the ways to handle a multiproject dependence with it? 我是Play框架的新手,看上去一切都非常简单,但我仍然只有一个问题:使用哪种方法可以处理多项目依赖关系?

I've tried to follow this but I cannot use the import http://www.playframework.com/documentation/2.2.1/SBTSubProjects 我尝试遵循此步骤,但是无法使用导入http://www.playframework.com/documentation/2.2.1/SBTSubProjects

Something like this How to import custom package in JAVA in PLAY framework 像这样的东西如何在PLAY框架中导入JAVA中的自定义包

But I have to import development code, is there a way to avoid to compile it to JAR every time? 但是我必须导入开发代码,有没有办法避免每次都将其编译为JAR?

I would like to avoid to integrate this separate project in the code and I would like to keep it externally, maybe in a custom folder like lib, called "ext" or such. 我想避免将此单独的项目集成到代码中,并且希望将其保留在外部,例如保存在名为“ ext”之类的自定义文件夹中。

As already mentioned, I would like to know if there are different ways to handle such a thing, how would you do that? 如前所述,我想知道是否有不同的方式来处理这种事情,您将如何处理?

You have three options, none of them matches all your wishes: 您有三个选择,没有一个可以满足您的所有愿望:

  1. Do not separate the code, but avoid using 'clean compile' and instead let the incremental compilation in play help you by just compiling what is changed and what needs to be compiled as best as it can. 不要分开代码,而要避免使用“纯编译”,而让渐进式编译通过只编译所做的更改和需要最大程度地编译的内容来帮助您。 This option will not package the sources in a separate artifact. 此选项不会将源打包在单独的工件中。

  2. Separate the code into a play/sbt submodule, this will give you a separate project that generates an artifact (jar-file), you can use dependsOn and aggregate to make your main project autogenerate it when needed, and include it in the classpath of your main project. 将代码分成play / sbt子模块,这将为您提供一个生成工件(jar文件)的单独项目,您可以使用dependsOn并进行聚合以使您的主项目在需要时自动生成它,并将其包括在您的主要项目。 This option will make it so that you do not have to compile it unless you actually changed that subproject. 使用此选项可以使您不必编译它,除非您实际更改了该子项目。

  3. Separate the code into a totally separate project, using a modern build tool, sbt, maven or maybe gradle and let that tool publish the artifact and then depend on it just as you would with a third party dependency. 使用现代化的构建工具,sbt,maven或gradle将代码分离为一个完全独立的项目,并让该工具发布工件,然后像依赖第三方时一样依赖它。 This would allow you to build the project with any build tool, making it possible to make it a generic library that does not depend on play. 这将允许您使用任何构建工具来构建项目,从而可以使其成为不依赖于播放的通用库。

I would recommend you to spend some time reading the sbt docs or maybe even a book rather than trying to do this by trial and error. 我建议您花一些时间阅读sbt文档甚至一本书,而不是尝试通过反复试验来做到这一点。 The 'SBT in action' early access from Manning is pretty good for example, the sbt docs are also pretty good: http://www.scala-sbt.org 例如,曼宁(Manning)的“实际行动中的SBT”早期访问相当不错,sbt文档也相当不错: http : //www.scala-sbt.org

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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