简体   繁体   中英

In the Play Route's file, how can indicate to use routes from a module?

Currently trying to follow Manning's Play for Scala, specifically the section on testing a module before publishing.

I've created a module named "Ean2BarcodePlayModule" with organization "net.nowhereatall.playforscala".

I've used activator to publish local to ~/.ivy2/local

In my test project, I've added the library dependency:

"net.nowhereatall.playforscala" %% "ean2barcodeplaymodule" % "1.0-SNAPSHOT"

Now, I'd like to modify my routes file to indicate

->      /barcode                    Ean2BarcodePlayModule.Routes

but this results in:

 [error] D:\Tutorials\Workspaces\Scala\Ean2BarcodePlayModule-Test\conf\routes:10:
 not found: value Ean2BarcodePlayModule
[error] ->      /barcode                    Ean2BarcodePlayModule.Routes
[error] D:\Tutorials\Workspaces\Scala\Ean2BarcodePlayModule-Test\conf\routes: no
t found: value Ean2BarcodePlayModule
[error] D:\Tutorials\Workspaces\Scala\Ean2BarcodePlayModule-Test\conf\routes: va
lue setPrefix is not a member of Any
[error] D:\Tutorials\Workspaces\Scala\Ean2BarcodePlayModule-Test\conf\routes:10:
 not found: value Ean2BarcodePlayModule
[error] ->      /barcode                    Ean2BarcodePlayModule.Routes
[error] four errors found
[error] (compile:compile) Compilation failed
[error] Total time: 4 s, completed Mar 12, 2015 1:36:34 PM

alternatively, if I try:

Now, I'd like to modify my routes file to indicate

->      /barcode                    net.nowhereatall.playforscala.Ean2BarcodePlayModule.Routes

the result is:

[error] D:\Tutorials\Workspaces\Scala\Ean2BarcodePlayModule-Test\conf\routes:10:
 object nowhereatall is not a member of package net
[error] ->      /barcode                    net.nowhereatall.playforscala.Ean2Ba
rcodePlayModule.Routes
[error] D:\Tutorials\Workspaces\Scala\Ean2BarcodePlayModule-Test\conf\routes: ob
ject nowhereatall is not a member of package net
[error] D:\Tutorials\Workspaces\Scala\Ean2BarcodePlayModule-Test\conf\routes: va
lue setPrefix is not a member of Any
[error] D:\Tutorials\Workspaces\Scala\Ean2BarcodePlayModule-Test\conf\routes:10:
 object nowhereatall is not a member of package net
[error] ->      /barcode                    net.nowhereatall.playforscala.Ean2Ba
rcodePlayModule.Routes
[error] four errors found
[error] (compile:compile) Compilation failed
[error] Total time: 6 s, completed Mar 12, 2015 1:35:56 PM

What is the correct way to do this?

With thanks to @Sarvesh Kumar Singh for directing me to the page on "SubProjects", the solution was relatively simple.

  1. Rename "routes" in the the module source to "barcode.routes".

  2. Redo activator publish-local.

  3. In the "Test" project route file, include the required line as

    -> /barcode barcode.Routes

(Note the last "R" in "Routes" is capital. That seems to be important!)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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