Root folder changes in production mode

55 views
Skip to first unread message

Jean Poncelet

unread,
Sep 18, 2017, 8:37:11 AM9/18/17
to Play Framework
Hello,

Play.current().path().getPath()

returns the "bin" folder path in production mode. Is there a way to get the the same path in development mode?

Thanks

Igmar Palsenberg

unread,
Sep 18, 2017, 11:24:48 AM9/18/17
to Play Framework
Play.current().path().getPath()

returns the "bin" folder path in production mode. Is there a way to get the the same path in development mode?

No, since that has no bin folder. Even if you could : Relying on this is a bad idea : It's the cwd when the application get's started, and
that path might change during runtime.

If you want it : Put it in the application.conf, and sed in the right value before the application starts.


Igmar

Manabu Tokunaga

unread,
Sep 18, 2017, 4:32:23 PM9/18/17
to Play Framework
We code ~/blah and do not rely on getPath(). This will result in the project root during the dev and bin during production for us.

Manabu Tokunaga

unread,
Sep 18, 2017, 4:33:21 PM9/18/17
to Play Framework
Correction,

./blah not ~/blah

alex s

unread,
Sep 18, 2017, 10:27:13 PM9/18/17
to Play Framework
понедельник, 18 сентября 2017 г., 18:24:48 UTC+3 пользователь Igmar Palsenberg написал:
Relying on this is a bad idea : It's the cwd when the application get's started, and
that path might change during runtime.

Not really. The first argument to the application startup script sets the application root path. It is immutable value and doesn't follow cwd changes.

alex s

unread,
Sep 18, 2017, 10:46:36 PM9/18/17
to Play Framework
понедельник, 18 сентября 2017 г., 23:33:21 UTC+3 пользователь Manabu Tokunaga написал:
./blah
 

Igmar Palsenberg

unread,
Sep 19, 2017, 3:00:28 AM9/19/17
to Play Framework


Op dinsdag 19 september 2017 04:27:13 UTC+2 schreef alex s:
It actually sets play.server.dir, which Environment uses as it's root path. You're right : That's a constant. resourceAsStream uses conf however, since that is in it's classpath. And running in dev mode
might yield different results. 

So, either use play.server.dir, or use absolute paths.


Igmar 
Reply all
Reply to author
Forward
0 new messages