Package org.gradle.plugins.ide.eclipse.model

## Class EclipseProject

- java.lang.Object
- - org.gradle.plugins.ide.eclipse.model.EclipseProject

-     public class EclipseProject
      extends java.lang.Object

  Enables fine-tuning project details (.project file) of the Eclipse plugin

  Example of use with a blend of all possible properties. Bear in mind that usually you don't have configure eclipse project directly because Gradle configures it for free!

       plugins {
           id 'java'
           id 'eclipse'
       }

       eclipse {
         project {
           //if you don't like the name Gradle has chosen
           name = 'someBetterName'

           //if you want to specify the Eclipse project's comment
           comment = 'Very interesting top secret project'

           //if you want to append some extra referenced projects in a declarative fashion:
           referencedProjects 'someProject', 'someOtherProject'
           //if you want to assign referenced projects
           referencedProjects = ['someProject'] as Set

           //if you want to append some extra natures in a declarative fashion:
           natures 'some.extra.eclipse.nature', 'some.another.interesting.nature'
           //if you want to assign natures in a groovy fashion:
           natures = ['some.extra.eclipse.nature', 'some.another.interesting.nature']

           //if you want to append some extra build command:
           buildCommand 'buildThisLovelyProject'
           //if you want to append a build command with parameters:
           buildCommand 'buildItWithTheArguments', argumentOne: "I'm first", argumentTwo: "I'm second"

           //if you want to create an extra link in the eclipse project,
           //by location uri:
           linkedResource name: 'someLinkByLocationUri', type: 'someLinkType', locationUri: 'file://someUri'
           //by location:
           linkedResource name: 'someLinkByLocation', type: 'someLinkType', location: '/some/location'

           //if you don't want any node_modules folder to appear in Eclipse, you can filter it out:
           resourceFilter {
             appliesTo = 'FOLDERS'
             type = 'EXCLUDE_ALL'
             matcher {
               id = 'org.eclipse.ui.ide.multiFilter'
               arguments = '1.0-name-matches-false-false-node_modules'
             }
           }
         }
       }

  For tackling edge cases users can perform advanced configuration on resulting XML file. It is also possible to affect the way eclipse plugin merges the existing configuration via beforeMerged and whenMerged closures.

  beforeMerged and whenMerged closures receive `Project` object

  Examples of advanced configuration:

       plugins {
           id 'java'
           id 'eclipse'
       }

       eclipse {
         project {

           file {
             //if you want to mess with the resulting XML in whatever way you fancy
             withXml {
               def node = it.asNode()
               node.appendNode('xml', 'is what I love')
             }

             //closure executed after .project content is loaded from existing file
             //but before gradle build information is merged
             beforeMerged { project ->
               //if you want skip merging natures... (a very abstract example)
               project.natures.clear()
             }

             //closure executed after .project content is loaded from existing file
             //and after gradle build information is merged
             whenMerged { project ->
               //you can tinker with the Project here
             }
           }
         }
       }

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static com.google.common.collect.ImmutableSet<java.lang.String>` | `VALID_LINKED_RESOURCE_ARGS` |

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `EclipseProject​(XmlFileContentMerger file)` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `buildCommand​(java.lang.String buildCommand)` | Adds a build command to the eclipse project.
    `void` | `buildCommand​(java.util.Map<java.lang.String,​java.lang.String> args, java.lang.String buildCommand)` | Adds a build command with arguments to the eclipse project.
    `void` | `file​(Closure closure)` | Enables advanced configuration like tinkering with the output XML or affecting the way existing .project content is merged with gradle build information
    `void` | `file​(Action<? super XmlFileContentMerger> action)` | Enables advanced configuration like tinkering with the output XML or affecting the way existing .project content is merged with gradle build information.
    `java.util.List<BuildCommand>` | `getBuildCommands()` |
    `java.lang.String` | `getComment()` |
    `XmlFileContentMerger` | `getFile()` | See `file(Action)`
    `java.util.Set<Link>` | `getLinkedResources()` |
    `java.lang.String` | `getName()` |
    `java.util.List<java.lang.String>` | `getNatures()` |
    `java.util.Set<java.lang.String>` | `getReferencedProjects()` |
    `java.util.Set<ResourceFilter>` | `getResourceFilters()` | The resource filters of the eclipse project.
    `void` | `linkedResource​(java.util.Map<java.lang.String,​java.lang.String> args)` | Adds a resource link (aka 'source link') to the eclipse project.
    `void` | `mergeXmlProject​(Project xmlProject)` |
    `void` | `natures​(java.lang.String... natures)` | Appends natures entries to the eclipse project.
    `void` | `referencedProjects​(java.lang.String... referencedProjects)` | The referenced projects of this Eclipse project (*not*: java build path project references).
    `ResourceFilter` | `resourceFilter​(Closure configureClosure)` | Adds a resource filter to the eclipse project.
    `ResourceFilter` | `resourceFilter​(Action<? super ResourceFilter> configureAction)` | Adds a resource filter to the eclipse project.
    `void` | `setBuildCommands​(java.util.List<BuildCommand> buildCommands)` | The build commands to be added to this Eclipse project.
    `void` | `setComment​(java.lang.String comment)` | A comment used for the eclipse project.
    `void` | `setLinkedResources​(java.util.Set<Link> linkedResources)` | The linked resources to be added to this Eclipse project.
    `void` | `setName​(java.lang.String name)` | Configures eclipse project name.
    `void` | `setNatures​(java.util.List<java.lang.String> natures)` | The natures to be added to this Eclipse project.
    `void` | `setReferencedProjects​(java.util.Set<java.lang.String> referencedProjects)` | The referenced projects of this Eclipse project (*not*: java build path project references).

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### VALID_LINKED_RESOURCE_ARGS

          public static final com.google.common.collect.ImmutableSet<java.lang.String> VALID_LINKED_RESOURCE_ARGS

  - ### Constructor Detail

    - #### EclipseProject

          @Inject
          public EclipseProject​(XmlFileContentMerger file)

  - ### Method Detail

    - #### getName

          public java.lang.String getName()

    - #### setName

          public void setName​(java.lang.String name)

      Configures eclipse project name. It is 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 moduleName is unique in the scope of a multi-module build. The 'uniqueness' of a module name is required for correct import into Eclipse and the task will make sure the name is unique.

      The logic that makes sure project names are unique is available since 1.0-milestone-2

      If your project has problems with unique names it is recommended to always run gradle eclipse from the root, e.g. for all subprojects, including generation of .classpath. If you run the generation of the eclipse project only for a single subproject then you may have different results because the unique names are calculated based on eclipse projects that are involved in the specific build run.

      If you update the project names then make sure you run gradle eclipse from the root, e.g. for all subprojects. The reason is that there may be subprojects that depend on the subproject with amended eclipse project name. So you want them to be generated as well because the project dependencies in .classpath need to refer to the amended project name. Basically, for non-trivial projects it is recommended to always run gradle eclipse from the root.

      For example see docs for `EclipseProject`

    - #### getComment

          public java.lang.String getComment()

    - #### setComment

          public void setComment​(java.lang.String comment)

      A comment used for the eclipse project. By default it will be configured to project.description

      For example see docs for `EclipseProject`

    - #### getReferencedProjects

          public java.util.Set<java.lang.String> getReferencedProjects()

    - #### setReferencedProjects

          public void setReferencedProjects​(java.util.Set<java.lang.String> referencedProjects)

      The referenced projects of this Eclipse project (*not*: java build path project references).

      Referencing projects does not mean adding a build path dependencies between them! If you need to configure a build path dependency use Gradle's dependencies section or eclipse.classpath.whenMerged { classpath -> ... to manipulate the classpath entries

      For example see docs for `EclipseProject`

    - #### referencedProjects

          public void referencedProjects​(java.lang.String... referencedProjects)

      The referenced projects of this Eclipse project (*not*: java build path project references).

      Referencing projects does not mean adding a build path dependencies between them! If you need to configure a build path dependency use Gradle's dependencies section or eclipse.classpath.whenMerged { classpath -> ... to manipulate the classpath entries

      Parameters:
        `referencedProjects` - The name of the project references.

    - #### getNatures

          public java.util.List<java.lang.String> getNatures()

    - #### setNatures

          public void setNatures​(java.util.List<java.lang.String> natures)

      The natures to be added to this Eclipse project.

      For example see docs for `EclipseProject`

    - #### natures

          public void natures​(java.lang.String... natures)

      Appends natures entries to the eclipse project.

      For example see docs for `EclipseProject`

      Parameters:
        `natures` - the nature names

    - #### getBuildCommands

          public java.util.List<BuildCommand> getBuildCommands()

    - #### setBuildCommands

          public void setBuildCommands​(java.util.List<BuildCommand> buildCommands)

      The build commands to be added to this Eclipse project.

      For example see docs for `EclipseProject`

    - #### buildCommand

          public void buildCommand​(java.util.Map<java.lang.String,​java.lang.String> args,
                                   java.lang.String buildCommand)

      Adds a build command with arguments to the eclipse project.

      For example see docs for `EclipseProject`

      Parameters:
        `args` - A map with arguments, where the key is the name of the argument and the value the value.
        `buildCommand` - The name of the build command.
      See Also:
        `buildCommand(String)`

    - #### buildCommand

          public void buildCommand​(java.lang.String buildCommand)

      Adds a build command to the eclipse project.

      For example see docs for `EclipseProject`

      Parameters:
        `buildCommand` - The name of the build command
      See Also:
        `buildCommand(Map, String)`

    - #### getLinkedResources

          public java.util.Set<Link> getLinkedResources()

    - #### setLinkedResources

          public void setLinkedResources​(java.util.Set<Link> linkedResources)

      The linked resources to be added to this Eclipse project.

      For example see docs for `EclipseProject`

    - #### linkedResource

          public void linkedResource​(java.util.Map<java.lang.String,​java.lang.String> args)

      Adds a resource link (aka 'source link') to the eclipse project.

      For example see docs for `EclipseProject`

      Parameters:
        `args` - A maps with the args for the link. Legal keys for the map are name, type, location and locationUri.

    - #### getResourceFilters

          public java.util.Set<ResourceFilter> getResourceFilters()

      The resource filters of the eclipse project.
      Since:
        3.5

    - #### resourceFilter

          public ResourceFilter resourceFilter​(@DelegatesTo(value=ResourceFilter.class,strategy=1)
                                               Closure configureClosure)

      Adds a resource filter to the eclipse project.

      For examples, see docs for `ResourceFilter`

      Parameters:
        `configureClosure` - The closure to use to configure the resource filter.
      Since:
        3.5

    - #### resourceFilter

          public ResourceFilter resourceFilter​(Action<? super ResourceFilter> configureAction)

      Adds a resource filter to the eclipse project.

      For examples, see docs for `ResourceFilter`

      Parameters:
        `configureAction` - The action to use to configure the resource filter.
      Since:
        3.5

    - #### file

          public void file​(@DelegatesTo(XmlFileContentMerger.class)
                           Closure closure)

      Enables advanced configuration like tinkering with the output XML or affecting the way existing .project content is merged with gradle build information

      The object passed to whenMerged{} and beforeMerged{} closures is of type `Project`

      For example see docs for `EclipseProject`

    - #### file

          public void file​(Action<? super XmlFileContentMerger> action)

      Enables advanced configuration like tinkering with the output XML or affecting the way existing .project content is merged with gradle build information. For example see docs for `EclipseProject`
      Since:
        3.5

    - #### getFile

          public final XmlFileContentMerger getFile()

      See `file(Action)`

    - #### mergeXmlProject

          public void mergeXmlProject​(Project xmlProject)