How to resolve packages when they don't follow the directories

Answered

Hi,

I'm writing a Play Framework app using sub-modules "a" and "b", by following the official doc. The routes files are based on package, so for example:

a.routes file

    POST   /action                      controllers.a.Controller.action()

b.routes files

    POST  /action                       controllers.b.Controller.action()

 

Each app has the same structure.

Module a:

app/
    controllers/
         Controller.java (package controllers.a;)
    models/
    views/
conf/
    a.routes

 

Module b:

app/
    controllers/
         Controller.java  (package controllers.b;)
    models/
    views/
conf/
    b.routes

 

How to resolve that with IntelliJ and make the imports work?

Thanks

4 comments
Comment actions Permalink

Hi,

This documentation is referring an obsolete version of Play Framework. Play Framework is now a simple SBT project using SBT CLI.
Moreover, my issue is not related to Play Framework. It is related to packages not strictly following a directory structure.

The package `controllers.a` doesn't refer to a `/controllers/a` directory but a `/controllers` directory located in an `a` app, which is totally good in Java and compiles perfectly. I think that what's supported by the language should be supported by the IDE too.

Regards

0
Comment actions Permalink

Could you please provide a demo project?

0
Comment actions Permalink

You can open this project example (it's not mine): https://github.com/josh-padnick/play-multiproject-template
Sub-modules (sub apps) are located in the /modules directory.
This part of the README is about the namespace structure of the project: https://github.com/josh-padnick/play-multiproject-template#namespace-conflicts

PS:

I noticed in this project that it adds additional directories. For example the `customer` module has a `/customer sub-directory in each directories so you have `customer/app/controllers/customer` directory, `customer/app/models/customer`, etc.
This could be a trick.

0

Please sign in to leave a comment.