gradle / gradle/playframework

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

Open
#130 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
47
Forks
41
PR merge metrics
No merged PRs in 30d

Description

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:

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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.