[2.1.1-scala] How do you add a resource directory to classpath?

1,058 views
Skip to first unread message

bs...@tagged.com

unread,
Jun 19, 2013, 7:48:55 PM6/19/13
to play-fr...@googlegroups.com
Hi,

I'm trying to figure out how to provide resource files not in my base directory to my project during local testing.  I'm testing out play to see if I can get it working with the architecture we have now.  Currently our projects are in spring java, deploying to tomcat.  These resource files are configured to be available in tomcat already, so all I need is to be able to simulate that availability in play without actually putting those files into my project.  I've tested numerous methods of fiddling with the classpath configurations in the build file, but nothing seems to have any effect.  I'm definitely not sure I'm using these correctly, for example:

unmanagedClasspath += file("/etc/config")
unmanagedResourceDirectories += file("/etc/config")

Any help or tutorials on how to properly configure my project would be appreciated.

Thanks,
Brian

PS. Sorry for the double post, I forgot to tag scala in the title and thought I'd be able to remove the thread by deleting the post.

Shing Hing Man

unread,
Jun 20, 2013, 7:07:33 AM6/20/13
to play-fr...@googlegroups.com
I think you are missing "in compile" :


unmanagedResourceDirectories in compile  += file("/etc/config")

Shing

Shing Hing Man

unread,
Jun 20, 2013, 7:11:36 AM6/20/13
to play-fr...@googlegroups.com
Oohs !  c in compile should be upper case.

I think you are missing "in Compile" :


unmanagedResourceDirectories in Compile  += file("/etc/config")


Shing



On Thursday, June 20, 2013 12:48:55 AM UTC+1, bs...@tagged.com wrote:

bs...@tagged.com

unread,
Jun 20, 2013, 2:18:47 PM6/20/13
to play-fr...@googlegroups.com
That doesn't seem to work.  I've also tried in Runtime with no success.  To be more specific about the property files, they're being loaded using the resourceloader with the file expected to be in the top level of the classpath:

ResourceLoader().getResource("resourcefile.xml");

bs...@tagged.com

unread,
Jun 20, 2013, 2:44:37 PM6/20/13
to play-fr...@googlegroups.com
Forget what I said, you were correct about needing in Compile.  I finally figured out my issue.  I was using these lines outside of .settings(), like this:



unmanagedResourceDirectories in Compile += file("/etc/config")
val main = play.Project(appName, appVersion, appDependencies).settings(resolvers ++= Seq(...))

This doesn't cause a compile error, and intellij recognized the unmanagedResourceDirectories variable.  When I initially tried placing that code inside the same .settings() as the resolvers, it threw an error.  The correct way seems to be to provide the configuration with its own .settings() block, like this:

val main = play.Project(appName, appVersion, appDependencies).settings(resolvers ++= Seq(...)).settings(unmanagedResourceDirectories in Compile += file("/etc/config"))

Thanks for the help.
Reply all
Reply to author
Forward
0 new messages