0

I have a Gradle project which has a lot of resources in the /src/main/resources folder. For performance reasons, some resources have to be generated from other resources at build time. So I split everything up into sub-projects:

/MainProj/src/main/java - The application
/MainProj/src/main/resources
/InternalProj/src/main/java - Code for generating additional resources for MainProj
/InternalProj/src/main/resources

When I run InternalProj using a special Gradle task, it generates some files to /InternalProj/output which I then copy to /MainProj/src/main/resources. Needless to say, this is really ugly and I'd like to know how to do this in a better way. Should I put it somewhere into build or directly into /MainProj/src/main/resources? Maybe use a symlink?


Edit

I now use a relative symlink from /src/main/generated-resources to /build/something and so far it works fine. But now I have a different problem: I have task A that generates some resources and task B that depends on those resources and thus on A. If I run gradle B or gradle A B, B will still fail since the resources generated by A didn't get updated into its build folder. How can I force Gradle to update the resources?

piegames
  • 975
  • 12
  • 31

1 Answers1

0

You can add the output file to the main source set of the InternalProj:

Example Groovy Code:

sourceSets {
    main {
        resources {
            srcDirs "src/main/resources", "output"
        }
    }
}

Related answer: https://stackoverflow.com/a/38982006/3708426

Jonathan Leitschuh
  • 822
  • 1
  • 8
  • 29