Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How should I be declaring and exporting modules?

I'm using the secure and crud modules with my app, and I've added them to application.conf as described in the tutorial. However, when I start my app, it generates a warning:

Declaring modules in application.conf is deprecated. Use dependencies.yml instead. (module.crud)

The modules then work while in dev mode, but when I deploy to my server (with play war etc), I get this:

13:55:40,662 WARN ~ Declaring modules in application.conf is deprecated. Use dependencies.yml instead (module.crud)

13:55:40,662 ERROR ~ Module crud will not be loaded because /var/lib/apache-tomcat-6.0.32/webapps/pat/WEB-INF/modules/crud does not exist

So, two questions: why aren't my modules getting exported, and how do I declare them in dependencies.yml? I've looked at the dependency page in the docs, and I admit that I don't really get what's going on there.

Thanks!

like image 683
andronikus Avatar asked Aug 31 '11 18:08

andronikus


People also ask

Should I use module exports or exports?

When we want to export a single class/variable/function from one module to another module, we use the module. exports way. When we want to export multiple variables/functions from one module to another, we use exports way.

What is a module declaration?

3.2. 9 MODULE declarations. A module is an encapsulated collection of declarations. Once defined, a module can be reused as many times as necessary. Modules can also be so that each instance of a module can refer to different data values.

How do module exports work?

All functions related to a single module are contained in a file. Module exports are the instructions that tell Node. js which bits of code (functions, objects, strings, etc.) to export from a given file so that other files are allowed to access the exported code.


2 Answers

The easiest way to set up modules in play 1.2+ is to use the --with keyword when you create your app.

For example

play new myapp --with crud,secure 

The output of the generated dependencies.yml is

# Application dependencies

require:
    - play
    - play -> secure
    - play -> crud
like image 137
Codemwnci Avatar answered Oct 23 '22 13:10

Codemwnci


OK, solved it. I added

- play -> crud
- play -> secure

to dependencies.yml, and deleted the relevant lines in application.conf. Then I ran play dependencies to copy the modules into my app. Play starts without any warnings, and the modules export to the WAR file correctly. I hope this helps people!

like image 35
andronikus Avatar answered Oct 23 '22 12:10

andronikus