0

This question is related to Apply same configurations to different tasks

In gradle, I have this piece of configuration:

idea {
    module {
        excludeDirs -= file("$buildDir/")
        sourceDirs += file(generatedSrcDir)
    } 
}

I have another one for eclipse with same code.

Question:

idea, eclipse {
    module {
        excludeDirs -= file("$buildDir/")
        sourceDirs += file(generatedSrcDir)
    }
}

is this possible ?

Community
  • 1
  • 1
smilyface
  • 5,021
  • 8
  • 41
  • 57

1 Answers1

1

What you need to do would be written as the following:

apply plugin: 'idea'
apply plugin: 'eclipse'

ext.generatedSrcDir = project.file('.')

[idea, eclipse].each {
    configure(it) {
        module {
            excludeDirs -= file("$buildDir/")
            sourceDirs += file(generatedSrcDir)
        }
    }
}

but since eclipse extension does not expose module method/field it will not work. Unfortunately you need to configure both idea and eclipse separately. Here is a question on configuring additional source folder for eclipse.

Community
  • 1
  • 1
Opal
  • 81,889
  • 28
  • 189
  • 210
  • yea.. you are right. It is not working for eclipse as it does not have module. Thank you for the new link. That was a new learning. – smilyface Oct 09 '15 at 07:17
  • @smilyface, if you found my answer helpful, please accept it :) – Opal Oct 09 '15 at 07:18