open class IdeaModule
Enables fine-tuning module details (*.iml file) of the IDEA plugin.
Example of use with a blend of most possible properties. Typically you don't have to configure this model directly because Gradle configures it for you.
apply plugin: 'java' apply plugin: 'idea' //for the sake of this example, let's introduce a 'performanceTestCompile' configuration configurations { performanceTestCompile performanceTestCompile.extendsFrom(testCompile) } dependencies { //performanceTestCompile "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 resource dirs resourceDirs += file('some-extra-resource-dir') //and some extra test resource dirs testResourceDirs += file('some-extra-test-resource-dir') //and hint to mark some of existing source dirs as generated sources generatedSourceDirs += file('some-extra-source-folder') //and some extra dirs that should be excluded by IDEA excludeDirs += file('some-extra-exclude-dir') //if you don't like the name Gradle has 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 the one inherited from IDEA project jdkName = '1.6' //put our custom test dependencies onto IDEA's TEST scope scopes.TEST.plus += [ configurations.performanceTestCompile ] //if 'content root' (as IDEA calls it) of the module is different contentRoot = file('my-module-content-root') //if you love browsing Javadoc downloadJavadoc = true //and hate reading sources :) downloadSources = false } }
For tackling edge cases, users can perform advanced configuration on the resulting XML file. It is also possible to affect the way the IDEA plugin merges the existing configuration via beforeMerged and whenMerged closures.
beforeMerged and whenMerged closures receive a Module parameter
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 } } } }
IdeaModule(project: Project, iml: IdeaModuleIml) |
open fun getContentRoot(): File
The content root directory of the module. For example see docs for IdeaModule |
|
open fun getExcludeDirs(): MutableSet<File>
Directories to be excluded. For example see docs for IdeaModule |
|
open fun getGeneratedSourceDirs(): MutableSet<File>
The directories containing the generated sources (both production and test sources). For example see docs for IdeaModule |
|
open fun getIml(): IdeaModuleIml
See |
|
open fun getInheritOutputDirs(): Boolean
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 For example see docs for IdeaModule |
|
open fun getJdkName(): String
The JDK to use for this module. If For example see docs for IdeaModule |
|
open fun getLanguageLevel(): IdeaLanguageLevel
The module specific language Level to use for this module. When The Idea module language level is based on the |
|
open fun getName(): String
Configures module name, that is the name of the *.iml file. 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 'uniqueness' of a module name is required for correct import into 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, i.e. 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 |
|
open fun getOutputDir(): File
The output directory for production classes. If For example see docs for IdeaModule |
|
open fun getOutputFile(): File
Configures output *.iml file. It's optional because the task should configure it correctly for you (including making sure it is unique in the multi-module build). If you really need to change the output file name (or the module name) it is much easier to do it via the moduleName property! Please refer to documentation on moduleName property. In IntelliJ IDEA the module name is the same as the name of the *.iml file. |
|
open fun getPathFactory(): PathFactory |
|
open fun getPathVariables(): MutableMap<String, File>
The variables to be used for replacing absolute paths in the iml entries. For example, you might add a For example see docs for IdeaModule |
|
open fun getProject(): Project
An owner of this IDEA module. If IdeaModule requires some information from gradle this field should not be used for this purpose. IdeaModule instances should be configured with all necessary information by the plugin or user. |
|
open fun getResourceDirs(): MutableSet<File>
The directories containing resources. For example see docs for IdeaModule |
|
open fun getScalaPlatform(): ScalaPlatform
The Scala version used by this module. |
|
open fun getScopes(): MutableMap<String, MutableMap<String, MutableCollection<Configuration>>>
The keys of this map are the IDEA scopes. Each key points to another map that has two keys, plus and minus. The values of those keys are collections of org.gradle.api.artifacts.Configuration objects. The files of the plus configurations are added minus the files from the minus configurations. See example below... Example how to use scopes property to enable 'performanceTestCompile' dependencies in the output *.iml file:
|
|
open fun getSingleEntryLibraries(): MutableMap<String, MutableIterable<File>> |
|
open fun getSourceDirs(): MutableSet<File>
The directories containing the production sources. For backward-compatibility it is set of directories containing the production sources from project.sourceSets.main.allSource. Starting with Gradle 5.0 it is set of directories containing the production sources from project.sourceSets.main.allJava. For example see docs for IdeaModule |
|
open fun getTargetBytecodeVersion(): JavaVersion
The module specific bytecode version to use for this module. When The Idea module bytecode version is based on the |
|
open fun getTestOutputDir(): File
The output directory for test classes. If For example see docs for IdeaModule |
|
open fun getTestResourceDirs(): MutableSet<File>
The directories containing the test resources. For example see docs for IdeaModule |
|
open fun getTestSourceDirs(): MutableSet<File>
The directories containing the test sources. For backward-compatibility it is set of directories containing the test sources from project.sourceSets.test.allSource. Starting with Gradle 5.0 it is set of directories containing the test sources from project.sourceSets.test.allJava. For example see docs for IdeaModule |
|
open fun iml(closure: Closure<Any>): Unit open fun iml(action: Action<in IdeaModuleIml>): Unit
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. |
|
open fun isDownloadJavadoc(): Boolean
Whether to download and add javadoc associated with the dependency jars. For example see docs for IdeaModule |
|
open fun isDownloadSources(): Boolean
Whether to download and add sources associated with the dependency jars. For example see docs for IdeaModule |
|
open fun isOffline(): Boolean
If true then external artifacts (e.g. those found in repositories) will not be included in the resulting classpath (only project and local file dependencies will be included). |
|
open fun mergeXmlModule(xmlModule: Module): Unit |
|
open fun resolveDependencies(): MutableSet<Dependency>
Resolves and returns the module's dependencies. |
|
open fun setContentRoot(contentRoot: File): Unit |
|
open fun setDownloadJavadoc(downloadJavadoc: Boolean): Unit |
|
open fun setDownloadSources(downloadSources: Boolean): Unit |
|
open fun setExcludeDirs(excludeDirs: MutableSet<File>): Unit |
|
open fun setGeneratedSourceDirs(generatedSourceDirs: MutableSet<File>): Unit |
|
open fun setInheritOutputDirs(inheritOutputDirs: Boolean): Unit |
|
open fun setJdkName(jdkName: String): Unit |
|
open fun setLanguageLevel(languageLevel: IdeaLanguageLevel): Unit |
|
open fun setName(name: String): Unit |
|
open fun setOffline(offline: Boolean): Unit |
|
open fun setOutputDir(outputDir: File): Unit |
|
open fun setOutputFile(newOutputFile: File): Unit |
|
open fun setPathFactory(pathFactory: PathFactory): Unit |
|
open fun setPathVariables(pathVariables: MutableMap<String, File>): Unit |
|
open fun setResourceDirs(resourceDirs: MutableSet<File>): Unit
Sets the directories containing resources. For example see docs for IdeaModule |
|
open fun setScalaPlatform(scalaPlatform: ScalaPlatform): Unit |
|
open fun setScopes(scopes: MutableMap<String, MutableMap<String, MutableCollection<Configuration>>>): Unit |
|
open fun setSingleEntryLibraries(singleEntryLibraries: MutableMap<String, MutableIterable<File>>): Unit |
|
open fun setSourceDirs(sourceDirs: MutableSet<File>): Unit |
|
open fun setTargetBytecodeVersion(targetBytecodeVersion: JavaVersion): Unit |
|
open fun setTestOutputDir(testOutputDir: File): Unit |
|
open fun setTestResourceDirs(testResourceDirs: MutableSet<File>): Unit
Sets the directories containing the test resources. For example see docs for IdeaModule |
|
open fun setTestSourceDirs(testSourceDirs: MutableSet<File>): Unit |