api / org.gradle.plugins.ide.idea.model

Package org.gradle.plugins.ide.idea.model

Types

Dependency

interface Dependency

Represents a dependency of an IDEA module.

FilePath

open class FilePath : Path

A Path that keeps the reference to the File

IdeaLanguageLevel

open class IdeaLanguageLevel

Java language level used by IDEA projects.

IdeaModel

open class IdeaModel

DSL-friendly model of the IDEA project information. First point of entry when it comes to customizing the IDEA generation.

See the examples in docs for IdeaModule or IdeaProject.

IdeaModule

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 } } } } 

IdeaModuleIml

open class IdeaModuleIml : XmlFileContentMerger

Models the generation/parsing/merging capabilities of an IDEA module.

For examples, see docs for IdeaModule.

IdeaProject

open class IdeaProject : IdeWorkspace

Enables fine-tuning project details (*.ipr file) of the IDEA plugin.

Example of use with a blend of all possible properties. Typically you don't have to configure IDEA module directly because Gradle configures it for you.

 import org.gradle.plugins.ide.idea.model.* apply plugin: 'java' apply plugin: 'idea' idea { project { //if you want to set specific jdk and language level jdkName = '1.6' languageLevel = '1.5' //you can update the source wildcards wildcards += '!?*.ruby' //you can configure the VCS used by the project vcs = 'Git' //you can change the modules of the *.ipr //modules = project(':someProject').idea.module //you can change the output file outputFile = new File(outputFile.parentFile, 'someBetterName.ipr') //you can add project-level libraries projectLibraries << new ProjectLibrary(name: "my-library", classes: [new File("path/to/library")]) } } 
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 Project object

Examples of advanced configuration:

 apply plugin: 'java' apply plugin: 'idea' idea { project { ipr { //you can tinker with the output *.ipr file before it's written out withXml { def node = it.asNode() node.appendNode('iLove', 'tinkering with the output *.ipr file!') } //closure executed after *.ipr content is loaded from existing file //but before gradle build information is merged beforeMerged { project -> //you can tinker with Project } //closure executed after *.ipr content is loaded from existing file //and after gradle build information is merged whenMerged { project -> //you can tinker with Project } } } } 

IdeaWorkspace

open class IdeaWorkspace

Enables fine-tuning workspace details (*.iws file) of the IDEA plugin.

At the moment, the only practical way of manipulating the resulting content is via the withXml hook:

 apply plugin: 'java' apply plugin: 'idea' idea.workspace.iws.withXml { provider -> provider.asNode().appendNode('gradleRocks', 'true') } 

JarDirectory

open class JarDirectory

Represents a jar directory element of an idea module library.

Jdk

open class Jdk

Represents information for the project Java SDK. This translates to attributes of the ProjectRootManager element in the ipr.

Module

open class Module : XmlPersistableConfigurationObject

Represents the customizable elements of an iml (via XML hooks everything of the iml is customizable).

ModuleDependency

open class ModuleDependency : Dependency

Represents an orderEntry of type module in the iml XML.

ModuleLibrary

open class ModuleLibrary : Dependency

Represents an orderEntry of type module-library in the iml XML.

Path

open class Path

Represents a path in a format as used often in ipr and iml files.

PathFactory

open class PathFactory

Path Factory.

Project

open class Project : XmlPersistableConfigurationObject

Represents the customizable elements of an ipr (via XML hooks everything of the ipr is customizable).

ProjectLibrary

open class ProjectLibrary

A project-level IDEA library.

SingleEntryModuleLibrary

open class SingleEntryModuleLibrary : ModuleLibrary

Single entry module library

Workspace

open class Workspace : XmlPersistableConfigurationObject

Represents the customizable elements of an ipr (via XML hooks everything of the ipr is customizable).