使用 Gradle 在 IDE 之间切换

Using Gradle to Toggle Between IDEs

假设我有以下顶级 Gradle 构建文件:

plugins {
   id "idea"
   //id "eclipse"
}

apply from: "${rootDir}/gradleInclude/intellij.gradle"
//apply from: "${rootDir}/gradleInclude/eclipse.gradle"

subprojects {
  apply plugin: "idea"
  //apply from: "${rootDir}/gradleInclude/eclipse.gradle"
}

可以使用单个 line/variable 在 idea/intellij 和 eclipse 条目之间切换吗?

刚刚做了以下事情:

def ide = 'eclipse'
def ideBuildFile = 'eclipse.gradle'
//def ide = 'idea'
//def ideBuildFile = 'intellij.gradle'

plugins {
   id "${ide}"
}

apply from: "${rootDir}/gradleInclude/${ideBuildFile}"

subprojects {
   apply plugin: "${ide}"
}