2

I have Java application that uses Gradle. Currently my resources directory contains Typesafe Config and Log4J configuration files.

Both of these files would have different settings based on whether my application is built for dev or production. For example, I would want Log4J to only log at the INFO level in production.

I am unable to use environment variables to swap these settings, and my only option is doing it through these resource files.

Ideally I'd like to be able to have 2 source sets in my Gradle config--one for dev (main) and one for prod--and have Gradle build a jar for each of these source sets. The main source set would continue to use src/main/resources as the resource directory, and the prod source set would use src/main/resources-prod as the resource directory.

I'm fine with these resource directories are in other locations--the above is just an example.

Right now, the only custom portions of my Gradle config are the following (outside of adding compile dependencies):

task buildZip(type: Zip) {
    from compileJava
    from processResources
    into('lib') {
        from configurations.runtime
    }
}

build.dependsOn buildZip

Does anyone know how to achieve this?

vegasje
  • 218
  • 1
  • 7

0 Answers0