Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gradle, idea plugin and multi-project setup

I'm trying to setup a multi-module gradle project with idea support. It works until I'm adding project-wide gradle.properties to the mix. Here's an example:

gradle.properties:

javaVersion = 1.8

gradle.settings:

include 'module_a'

build.gradle:

allprojects {
  apply plugin: 'idea'
  idea {
    project {
      jdkName = javaVersion
    }
  }
}

module_a is an empty sub-folder.

gradle idea fails with this:

Build file 'project/build.gradle' line: 7

* What went wrong:
A problem occurred evaluating root project 'project'.
> Cannot set property 'jdkName' on null object

What could be the reason?

Question 2: can a sub-project make modifications to the global idea task, for instance

idea.module.generatedSourceDirs += file('srm/main/java.generated')

Will it only affect module_a if placed in module_a/build.gradle ?

Thanks

like image 515
eprst Avatar asked May 10 '16 00:05

eprst


1 Answers

You can't set "jdkName" on every subproject, it only should set on the root project like this:

idea {
  project {
    jdkName = "1.8"
    languageLevel = "1.8"
  }
  module {
    name = "My root project name"
  }
}

On the sub projects you can config other things like

idea.module.testSourceDirs = idea.module.testSourceDirs+idea.module.sourceDirs
idea.module.sourceDirs = [] as Set
like image 135
Carlos E. Feria Vila Avatar answered Nov 08 '22 18:11

Carlos E. Feria Vila