How to dynamically generate the dependencies list from an input file?


(techgolfer) #1

Hi, presently I have a build.gradle script and a gradle.properties file.

In the gradle.properties file, it contains a list of dependencies as such: list = ‘servletapi, json, log4j’ servletapi = ‘servletapi:servlet-api:2.4’ json = ‘org.json:json:20090211’ log4j = ‘log4j:log4j:1.2.16’

In my build.gradle script, I have the following in the dependencies section: dependencies {

def mylist = list

for (mydep in mylist) {

runtime mydep

} }

Doing so, will generate “A problem occurred evaluating root project ‘0’.”

The goal is to have a common build.gradle script which will get its input from a gradle.properties file so that I can generate different WAR file for deployment.

Please let me know if this is the correct approach or if you have other suggestions I am all ears.

thanks, Chris


(techgolfer) #2

I am presently using 1.0-m7 for this.


(Peter Niederwieser) #3

It will require more coding than that. I’d consider putting everything into the build.gradle. For example:

if (project.hasProperty("deployment")) {
  dependencies { ... }
} else {
  dependencies { ... }
}