Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When using -Dconfig.resource=... files are not discovered in conf/ directory #130

Open
spingel opened this issue Feb 6, 2020 · 1 comment

Comments

@spingel
Copy link

spingel commented Feb 6, 2020

The play documentation on https://www.playframework.com/documentation/2.6.x/ProductionConfiguration states:

Using -Dconfig.resource
This will search for an alternative configuration file in the application classpath (you usually provide
these alternative configuration files into your application conf/ directory before packaging).
Play will look into conf/ so you don’t have to add conf/.

Play applications created by gradle embed all conf/ files in the application jar and will only load config files from the classpath. This is not consistent with the documentation and gets even more confusing since config files are also packaged in the conf/ directory but ignored when running the application.

Looking at applications built by sbt the layout is different. Files from conf/ are not packaed inside jars but the launcher jar has a Class-Path entry in the manifest.mf that add the conf/ directory to the class path:

Class-Path: ../conf/ my-application.jar dependencies.jar...

As a work-around, the same behavior can be achieved by including the following snippet in the build file:

def classPath = tasks.createMainDistributionJar.manifest.attributes.get('Class-Path')
tasks.createMainDistributionJar.manifest.attributes([ 'Class-Path': "../conf/ ${-> classPath}"])
@mkurz
Copy link

mkurz commented Feb 6, 2020

Just a note: Play 2.8.0 had a bug where reading config.file/config.resource from devSettings and sys properties wasn't working. Fixed in Play 2.8.1. playframework/playframework#10010

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants