开发者

Where to put dependent jars in its own folder in play framework project?

I have a situation where I need to place very large number of jars coming fro开发者_开发知识库m different third party sources under lib folder of play framework and that should work. But it would be much better if I can create subfolders under project_root/lib folder to organize and group together differnt jars belonging to different third party sources. This makes it much easier to manage and update jars in case new versions of third party projects comes out. Is it possible and how can I do that?


I try not to use the lib folder for jars since starting with Play! 1.2 it had it's own dependency management that uses that folder for resolved dependencies. So, what I do is create a folder called 'jars' and put them under there. You can then arrange the jars by org name in folders under that.

So if you put a jar in 'jars/my.org/my-module-1.2.jar' you would need this in your dependencies.yml file:

require:
  - play
  - my.org -> my-module 1.2

repositories:
  - local:
    type:       local
    artifact:   "${application.path}/jars/[organisation]/[artifact]-[revision].[ext]"
    contains:
      - my.org -> *

You will have to list each org under 'contains:' that you want resolved from the jars folder.


Just to bring a bit more to Aaron's answer. What was bugging me when directly referencing a jar file in the artifact line was not understanding that it seems possible to have multiple artifact lines. So for example, I was able to do this:

require:
  - play
  - my.org -> mylib 1.2
  - my.org2 -> mylib2 1.3

repositories:
  - custom-lib:
    type:       local
    artifact:   "${application.path}/jars/mylib-1.2.jar"
    artifact:   "${application.path}/jars/mylib2-1.3.jar"

    contains:
      - my.org -> *
      - my.org2 -> *

and when running play dependencies it put the jars in the lib directory and indicated that they both came from the custom-lib repository.

So it seemed to work for me through experimentation, but I'd be interested to know if this is really a valid way to do it as I have not seen in the doc anything saying you can have multiple artifact lines.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜