anchor.diff:  
   ++++
   <sample id="useIdeaPlugin" dir="idea" title="Using the IDEA plugin">
  -            <sourcefile file="build.gradle" snippet="use-plugin"/>
  -        </sample>
  +    <sourcefile file="build.gradle" snippet="use-plugin"/>
  +</sample>
   ++++
   
   The IDEA plugin adds a number of tasks to your project. The `idea` task generates an IDEA module file for the project. When the project is the root project, the `idea` task also generates an IDEA project and workspace. The IDEA project includes modules for each of the projects in the Gradle build.
  
positive.code: ===== Modifying the fully populated domain objects
  
  The `whenMerged` hook allows you to manipulate the fully populated domain objects. Often this is the preferred way to customize IDEA files. Here is how you would export all the dependencies of an IDEA module:
  ++++
  <sample id="exportDependencies" dir="idea" title="Export Dependencies">
                          <sourcefile file="build.gradle" snippet="module-when-merged"/>
                      </sample>
  ++++
  
  
  
negative.code: 
  The plugin provides objects modeling the sections of the metadata files that are generated by Gradle. The generation lifecycle is as follows:
  
   1. The file is read; or a default version provided by Gradle is used if it does not exist
   2. The `beforeMerged` hook is executed with a domain object representing the existing file
   3. The existing content is merged with the configuration inferred from the Gradle build or defined explicitly in the eclipse DSL
   4. The `whenMerged` hook is executed with a domain object representing contents of the file to be persisted
   5. The `withXml` hook is executed with a raw representation of the XML that will be persisted
   6. The final XML is persisted
  
  The following are the domain objects used for each of the model types:
  
  [[idea-hooks]]
  api:org.gradle.plugins.ide.idea.model.IdeaProject[]::
  +
   * `beforeMerged { api:org.gradle.plugins.ide.idea.model.Project[] arg \-> ... }`
   * `whenMerged { api:org.gradle.plugins.ide.idea.model.Project[] arg \-> ... }`
   * `withXml { api:org.gradle.api.XmlProvider[] arg \-> ... }`
  
  api:org.gradle.plugins.ide.idea.model.IdeaModule[]::
   * `beforeMerged { api:org.gradle.plugins.ide.idea.model.Module[] arg \-> ... }`
   * `whenMerged { api:org.gradle.plugins.ide.idea.model.Module[] arg \-> ... }`
   * `withXml { api:org.gradle.api.XmlProvider[] arg \-> ... }`
  
  api:org.gradle.plugins.ide.idea.model.IdeaWorkspace[]::
   * `beforeMerged { api:org.gradle.plugins.ide.idea.model.Workspace[] arg \-> ... }`
   * `whenMerged { api:org.gradle.plugins.ide.idea.model.Workspace[] arg \-> ... }`
   * `withXml { api:org.gradle.api.XmlProvider[] arg \-> ... }`
  
  
  [[sec:partial-rewrite]]
  ===== Partial rewrite of existing content
  
  A <<sec:complete-rewrite,complete rewrite>> causes all existing content to be discarded, thereby losing any changes made directly in the IDE. The `beforeMerged` hook makes it possible to overwrite just certain parts of the existing content. The following example removes all existing dependencies from the `Module` domain object:
  
  ++++
  <sample id="partialRewrites" dir="idea" title="Partial Rewrite for Module">
      <sourcefile file="build.gradle" snippet="module-before-merged"/>
  </sample>
  ++++
  
  The resulting module file will only contain Gradle-generated dependency entries, but not any other dependency entries that may have been present in the original file. (In the case of dependency entries, this is also the default behavior.) Other sections of the module file will be either left as-is or merged. The same could be done for the module paths in the project file:
  
  ++++
  <sample id="partialRewritesProject" dir="idea" title="Partial Rewrite for Project">
      <sourcefile file="build.gradle" snippet="project-before-merged"/>
  </sample>
  ++++
  
  
  