Shared resources with different configurations and project types


(Josiah Haswell) #1

Hi all,

I’d like to share some common resources between several projects. I currently have a multi-module project that contains jar subprojects and war subprojects.

Here’s what I’d like to do specifically:

My project is:

top-level

-shared --src —main ----resources -----META-INF ------persistence.xml

//production JPA configuration --test —main ----resources ------META-INF -------persistence.xml //test JPA configuration -jar-project //For testing, I would like to include shared/test/persistence.xml //For production, I would like to include shared/main/persistence.xml

And then similar configurations for WEB-INF that I would like applied to WAR projects. Since these resources will be shared between many of the projects, I would like to avoid the jar { metaInf //… and war { webInf //… declarations everywhere. How would I do it?

Thanks!

Joe


(Peter Niederwieser) #2

I would like to avoid the jar { metaInf //… and war { webInf //… declarations everywhere.

Are you aware of configuration injection, which allows you to configure many tasks at once? If not, see the chapter on multi-project builds in the Gradle User Guide.


(Josiah Haswell) #3

Thanks! I guess I hadn’t read through it closely enough. I was looking for the configure() function!

Loving Gradle, btw. Keep up the great work!