CrystalBlue
CrystalBlue

Reputation: 1863

Access parent project files in gradle from sub projects

I have one main java project using gradle right now (let's call it parentProject). I then have four sub projects in that parent (sub1, sub2, sub3, sub4). The structure looks a little something like this:

parentProject
-->sub1
---->src
------>main
-------->java
-------->resources
------>test
-------->java
-------->resources
etc...

Each subproject uses the same config file (which is in Resources) to connect to different systems. I don't want to replicate the config file over and over, I just want to use one 'master' config and distribute it to the sub projects.

Is there a way to do this?

Upvotes: 3

Views: 4165

Answers (1)

RaGe
RaGe

Reputation: 23707

Create a common resources folder, location doesn't really matter, but I think it is logical to keep it under parentProject. And then add it as a resource folder under subprojects section of your root build.gradle:

subProjects{
    sourceSets.main.resources{
        srcDir '../commonResources'
    }
}

Upvotes: 4

Related Questions