What is the difference between plugins, dependencies, modules and sub-projects in play 2.4?
Asked Answered
B

1

5

I am new to the playframework and just learning.I am a little confused between dependencies, modules, plugins and sub-projects. How do they differ from each other?

Here's what i have understood, i may be wrong.

dependencies - are all the libraries needed for a play application to run. sub-project - is a play application inside another parent application. Not sure about 'plugin' and 'modules'.

Can someone please explain how they differ?

Note: I am working with Play 2.4 and play-java, not sure if the definitions change with play-scala.

Bluefarb answered 18/11, 2015 at 3:23 Comment(0)
E
10

Your initial explanation is pretty much correct.

Dependencies are indeed libraries, more strictly, they are jar files (a fancy name for a zip file that contains java classes) that are distributed through a repository (the biggest repo is called Maven central) and downloaded by SBT.

Sub projects are best seen as libraries that are embedded directly into your build. If you run publishLocal, your subproject will be packaged up into a jar and deployed to your local repository. If you have configured your build to publish to a particular public (or private) repository, when you run publish, the jar and its metadata will be pushed there, where other projects can declare it in their dependencies. In fact, every project in an SBT build fits into this category. Your play project is in fact a library that could be depended on by something else.

Plugins and modules are grey terms that mean different things in different contexts.

For one, there are sbt plugins, these are declared in your project/plugins.sbt, and these add new behaviour to your build, such as the ability to compile less files. Play's dev mode is part implemented by an sbt plugin.

But then there's plugins to the Play runtime. We're currently phasing out this terminology, in favour of the word module, but it still does have some use.

We have some documentation already published on what a module is here:

https://www.playframework.com/documentation/2.4.x/Modules

So a module and a dependency may be one in the same thing, or they may not, a dependency may provide many modules, a single module could be provided by many transitive dependencies.

Episcopalian answered 18/11, 2015 at 4:0 Comment(2)
Thank you! That was helpful. I am not totally clear on modules, but I am hoping I will have a better understanding after I have looked at the documentation you have referred to.Bluefarb
Rather than describing what modules are, it may be useful to simply state some examples of modules. If you want to connect to MongoDB, you would use a mongodb module for that. You might use a module like deadbolt for authentication/authorization in Play. Internally, Play provides an HTTP client called WS, this is a module too, that you might use. In practice in your code, you usually won't see the word module, you just use the mongodb client/authentication framework/WS API according to the documentation.Episcopalian

© 2022 - 2024 — McMap. All rights reserved.