Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add a single file to gradle resources

I'm using the config var plugin for heroku (see https://devcenter.heroku.com/articles/config-vars).

It allows me to use a .env file which I do not push to source control to define the heroku environment.

So when I'm on heroku, I can access sensible information via System.properties.

In dev, I would like to read from this file so it would be best if it were on my classpath.

The .env file is at the root of my project so I cannot use something like this :

sourceSets {
    main {
        resources {
            srcDirs = ['src/main/resources', '/']
        }
    }
}

What is the simplest way to include a single file into gradle resources ?

like image 873
Geoffroy Warin Avatar asked Jun 13 '14 14:06

Geoffroy Warin


1 Answers

The earlier answers seemed more complicated than I was hoping for, so I asked on the gradle forums and got a reply from a Sterling Green who's one of the gradle core devs.

He suggested configuring processResources directly

processResources {
   from(".env") 
}

He also mentioned that it might be a bad idea to include the project root as an input directly.

like image 54
2 revs, 2 users 91% Avatar answered Dec 12 '22 18:12

2 revs, 2 users 91%