Task-based dependencies

(rayman7718) #1

I have a simple java project that I use gradle for. Currently, I have specified all my library dependencies as one project dependencies tag. Is there a way for me to enable gradle to selectively choose only certain dependencies from the tag based on the compile task that is being run?

I have one compile task that builds the project for ARM, x64, x86, etc. And when running each task I would like the corresponding library dependency to be linked. Also, I would like to specify an All Task, that runs each task successively and builds the target for each platform.

Any suggestions?

(Chris Doré) #2

It may be a bit early for you to adopt, but have you looked at the upcoming Java support in the new software model?


Depending on what other plugins you want to use, they may not have any support for the new Java model.

(Chris Doré) #3

Hmm, sorry, it sounds like Gradle has put development of the new Java software model support on hold. I did not know this until I read @st_oehme’s post here.

(rayman7718) #4

Thanks! I had not realize it was early for us to adopt gradle.

For now, I simply use the project.gradle.startParameter.taskNames
inside dependencies tag to decide which compile statements to issue.

List tasksRunning = new ArrayList();
for (String s : project.gradle.startParameter.taskNames)
compile fileTree(dir: ‘lib’, include: [’/x86-*.jar’])
else if (tasksRunning.contains(“arm-shit”))
compile fileTree(dir: ‘lib’, include: [’

(Stefan Oehme) #5

That’s not the case, Gradle is absolutely ready for you :slight_smile: @Chris_Dore only mentioned that we put the new Java software model on hold. But building Java projects with the “java” plugin is completely unaffected by this.

To answer your question: Just create a specific configuration for each of your target platforms:

configurations {
  arm {

dependencies {
  arm fileTree(dir: 'lib', include: ['*/ARM-.jar']) 

compileForArm.classpath = configurations.arm