[Play 2.4.6][Scala] PlayLayoutPlugin and resource file locations using Dist task

120 views
Skip to first unread message

Joseph Lust

unread,
May 3, 2016, 8:57:39 AM5/3/16
to play-framework
We're having great success with Play, but like any project, we need to make sure it's broken into modules as it grows. So, we've refactored our Play code to the standard SBT layout, following the official docs.

However, while this works well for local running (sbt run) and testing (sbt test), when we build the universal distributable (sbt dist), all the resource files are placed into conf/, not the proper src/main/resources. This is a problem, because it means access to resource files when in dev mode (sbt run), is different than in dist mode, breaking code that needs config files.

How are other people handling this, to ensure resource files are in `src/main/resources` regardless of how a Play project is built?


Thanks,
Joe

Will Sargent

unread,
May 3, 2016, 9:20:12 AM5/3/16
to play-fr...@googlegroups.com
This is interesting -- it soundly like sbt native packager is configured for conf.  Have you looked at the sbt settings for deployment by turning.the sbt log level up to debug?

Will.
--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framewor...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/ca6b78f4-c698-4b11-9688-44dd554b268b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Joseph Lust

unread,
May 3, 2016, 10:37:59 AM5/3/16
to play-framework
Thanks, Will.

Running sbt dist in debug mode logging, no notable output is provided for that path. The resource directories are the only thing of note, and those are as expected. However, it doesn't make any mention of mapping to conf/.

[debug] Copy resource mappings: 
[debug]         (/home/joe/git/my-app/src/main/resources/logger.xml,/home/joe/git/my-app/target/scala-2.11/classes/logger.xml)
[debug]         (/home/joe/git/my-app/src/main/resources/application.conf,/home/joe/git/my-app/target/scala-2.11/classes/application.conf)
[debug]         (/home/joe/git/my-app/src/main/resources/routes,/home/joe/git/my-app/target/scala-2.11/classes/routes)
[debug]         (/home/joe/git/my-app/src/main/resources/api.json,/home/joe/git/my-app/target/scala-2.11/classes/api.json)


--Joe

Will Sargent

unread,
May 3, 2016, 12:49:53 PM5/3/16
to play-fr...@googlegroups.com, Joseph Lust
I think it might be 


 // Support for externalising resources
    mappings in Universal ++= {
      if (externalizeResources.value) {
        val resourceMappings = (playExternalizedResources in Compile).value
        resourceMappings.map {
          case (resource, path) => resource -> ("conf/" + path)
        }
      } else Nil
    },

Although I’m not certain (am just eyeballing this), it does seem like the Univeral scope mappings are where the hooks are.  Can do you do an inspect tree?


Will.
--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framewor...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages