gradle
8.3

# EclipseProject

abstract class EclipseProject

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

Content copied to clipboard
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
          }
        }
      }
    }

Content copied to clipboard

## Constructors

EclipseProject
Link copied to clipboard
@Inject
constructor(file: XmlFileContentMerger)

## Functions

buildCommand
Link copied to clipboard
open fun buildCommand(buildCommand: String)
Adds a build command to the eclipse project.
open fun buildCommand(args: Map<String, String>, buildCommand: String)
Adds a build command with arguments to the eclipse project.
file
Link copied to clipboard
open fun file(@DelegatesTo(value = XmlFileContentMerger::class) closure: Closure)
Enables advanced configuration like tinkering with the output XML or affecting the way existing .
open fun file(action: Action<out Any>)
Enables advanced configuration like tinkering with the output XML or affecting the way existing .project content is merged with gradle build information.
linkedResource
Link copied to clipboard
open fun linkedResource(args: Map<String, String>)
Adds a resource link (aka 'source link') to the eclipse project.
mergeXmlProject
Link copied to clipboard
open fun mergeXmlProject(xmlProject: Project)
natures
Link copied to clipboard
open fun natures(natures: Array<String>)
Appends natures entries to the eclipse project.
referencedProjects
Link copied to clipboard
open fun referencedProjects(referencedProjects: Array<String>)
The referenced projects of this Eclipse project (*not*: java build path project references).
resourceFilter
Link copied to clipboard
open fun resourceFilter(@DelegatesTo(value = ResourceFilter::class, strategy = Closure.DELEGATE_FIRST) configureClosure: Closure): ResourceFilter
open fun resourceFilter(configureAction: Action<out Any>): ResourceFilter
Adds a resource filter to the eclipse project.

## Properties

buildCommands
Link copied to clipboard
open var buildCommands: List<BuildCommand>
comment
Link copied to clipboard
open var comment: String
file
Link copied to clipboard
val file: XmlFileContentMerger
linkedResources
Link copied to clipboard
open var linkedResources: Set<Link>
name
Link copied to clipboard
open var name: String
natures
Link copied to clipboard
open var natures: List<String>
referencedProjects
Link copied to clipboard
open var referencedProjects: Set<String>
resourceFilters
Link copied to clipboard
open val resourceFilters: Set<ResourceFilter>
VALID_LINKED_RESOURCE_ARGS
Link copied to clipboard
val VALID_LINKED_RESOURCE_ARGS: ImmutableSet<String>