|
Groovy Documentation | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | PROPERTY | CONSTR | METHOD | DETAIL: FIELD | PROPERTY | CONSTR | METHOD |
java.lang.Object org.gradle.plugins.ide.idea.model.IdeaModule
class IdeaModule extends java.lang.Object
Enables fine-tuning module details (*.iml file) of the Idea plugin
Example of use with a blend of all possible properties. Bear in mind that usually you don't have configure this model directly because Gradle configures it for free!
apply plugin: 'java' apply plugin: 'idea' //for the sake of the example lets have a 'provided' dependency configuration configurations { provided provided.extendsFrom(compile) } dependencies { //provided "some.interesting:dependency:1.0" } idea { //if you want parts of paths in resulting files (*.iml, etc.) to be replaced by variables (Files) pathVariables GRADLE_HOME: file('~/cool-software/gradle') module { //if for some reason you want to add an extra sourceDirs sourceDirs += file('some-extra-source-folder') //and some extra test source dirs testSourceDirs += file('some-extra-test-dir') //and some extra dirs that should be excluded by IDEA excludeDirs += file('some-extra-exclude-dir') //if you don't like the name Gradle have chosen name = 'some-better-name' //if you prefer different output folders inheritOutputDirs = false outputDir = file('muchBetterOutputDir') testOutputDir = file('muchBetterTestOutputDir') //if you prefer different sdk than inherited from IDEA project jdkName = '1.6' //if you need to put provided dependencies on the classpath scopes.PROVIDED.plus += configurations.provided //if 'content root' (as IDEA calls it) of the module is different contentRoot = file('my-module-content-root') //if you love browsing javadocs downloadJavadoc = true //and hate reading sources :) downloadSources = false } }For tackling edge cases users can perform advanced configuration on resulting xml file. It is also possible to affect the way idea plugin merges the existing configuration via beforeMerged and whenMerged closures.
beforeMerged and whenMerged closures receive Module object
Examples of advanced configuration:
apply plugin: 'java' apply plugin: 'idea' idea { module { iml { //if you like to keep *.iml in a secret folder generateTo = file('secret-modules-folder') //if you want to mess with the resulting xml in whatever way you fancy withXml { def node = it.asNode() node.appendNode('iLoveGradle', 'true') node.appendNode('butAlso', 'I find increasing pleasure tinkering with output *.iml contents. Yeah!!!') } //closure executed after *.iml content is loaded from existing file //but before gradle build information is merged beforeMerged { module -> //if you want skip merging exclude dirs module.excludeFolders.clear() } //closure executed after *.iml content is loaded from existing file //and after gradle build information is merged whenMerged { module -> //you can tinker with Module } } } }
Property Summary | |
---|---|
java.io.File |
contentRoot
The content root directory of the module. |
boolean |
downloadJavadoc
Whether to download and add javadoc associated with the dependency jars. |
boolean |
downloadSources
Whether to download and add sources associated with the dependency jars. |
java.util.Set |
excludeDirs
ConventionProperty for the directories to be excluded. |
IdeaModuleIml |
iml
See iml(Closure) |
java.lang.Boolean |
inheritOutputDirs
If true, output directories for this module will be located below the output directory for the project; otherwise, they will be set to the directories specified by #outputDir and #testOutputDir. |
java.lang.String |
jdkName
The JDK to use for this module. |
java.lang.String |
name
Configures module name, that is the name of the *.iml file. |
java.io.File |
outputDir
The output directory for production classes. |
PathFactory |
pathFactory
|
java.util.Map |
pathVariables
The variables to be used for replacing absolute paths in the iml entries. |
java.lang.Object |
project
|
java.util.Map |
scopes
The keys of this map are the IDEA scopes. |
java.util.Map |
singleEntryLibraries
|
java.util.Set |
sourceDirs
The directories containing the production sources. |
java.io.File |
testOutputDir
The output directory for test classes. |
java.util.Set |
testSourceDirs
The directories containing the test sources. |
Constructor Summary | |
IdeaModule(java.lang.Object project, IdeaModuleIml iml)
|
Method Summary | |
---|---|
java.io.File
|
getOutputFile()
Configures output *.iml file. |
void
|
iml(groovy.lang.Closure closure)
Enables advanced configuration like tinkering with the output xml or affecting the way existing *.iml content is merged with gradle build information For example see docs for IdeaModule |
void
|
mergeXmlModule(Module xmlModule)
|
void
|
setOutputFile(java.io.File newOutputFile)
|
Methods inherited from class java.lang.Object | |
---|---|
java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Property Detail |
---|
java.io.File contentRoot
For example see docs for IdeaModule
boolean downloadJavadoc
For example see docs for IdeaModule
boolean downloadSources
For example see docs for IdeaModule
java.util.Set excludeDirs
For example see docs for IdeaModule
final IdeaModuleIml iml
java.lang.Boolean inheritOutputDirs
For example see docs for IdeaModule
java.lang.String jdkName
inherited
, the project SDK is used. Otherwise the SDK for the corresponding
value of java version is used for this module
For example see docs for IdeaModule
java.lang.String name
It's optional because the task should configure it correctly for you. By default it will try to use the project.name or prefix it with a part of a project.path to make sure the module name is unique in the scope of a multi-module build. The 'uniqeness' of a module name is required for correct import into IntelliJ IDEA and the task will make sure the name is unique.
since 1.0-milestone-2
If your project has problems with unique names it is recommended to always run gradle idea from the root, e.g. for all subprojects. If you run the generation of the idea module only for a single subproject then you may have different results because the unique names are calculated based on idea modules that are involved in the specific build run.
If you update the module names then make sure you run gradle idea from the root, e.g. for all subprojects, including generation of idea project. The reason is that there may be subprojects that depend on the subproject with amended module name. So you want them to be generated as well because the module dependencies need to refer to the amended project name. Basically, for non-trivial projects it is recommended to always run gradle idea from the root.
For example see docs for IdeaModule
java.io.File outputDir
For example see docs for IdeaModule
PathFactory pathFactory
java.util.Map pathVariables
For example see docs for IdeaModule
final java.lang.Object project
java.util.Map scopes
Example how to use scopes property to enable 'provided' dependencies in the output *.iml file:
apply plugin: 'java' apply plugin: 'idea' configurations { provided provided.extendsFrom(compile) } dependencies { //provided "some.interesting:dependency:1.0" } idea { module { scopes.PROVIDED.plus += configurations.provided } }
java.util.Map singleEntryLibraries
java.util.Set sourceDirs
For example see docs for IdeaModule
java.io.File testOutputDir
For example see docs for IdeaModule
java.util.Set testSourceDirs
For example see docs for IdeaModule
Constructor Detail |
---|
IdeaModule(java.lang.Object project, IdeaModuleIml iml)
Method Detail |
---|
java.io.File getOutputFile()
Please refer to documentation on moduleName property. In IntelliJ IDEA the module name is the same as the name of the *.iml file.
void iml(groovy.lang.Closure closure)
For example see docs for IdeaModule
void mergeXmlModule(Module xmlModule)
void setOutputFile(java.io.File newOutputFile)
Groovy Documentation