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

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

Types

AbstractClasspathEntry

abstract class AbstractClasspathEntry : ClasspathEntry

Common superclass for all ClasspathEntry instances.

AbstractLibrary

abstract class AbstractLibrary : AbstractClasspathEntry

Common superclass for the library elements.

AccessRule

open class AccessRule

Access rule associated to a classpath entry.

BuildCommand

open class BuildCommand : Serializable

A build command.

Classpath

open class Classpath : XmlPersistableConfigurationObject

Represents the customizable elements of an eclipse classpath file. (via XML hooks everything is customizable).

ClasspathEntry

interface ClasspathEntry

Represents an entry in the Eclipse classpath.

Container

open class Container : AbstractClasspathEntry

A container classpath entry.

EclipseClasspath

open class EclipseClasspath

The build path settings for the generated Eclipse project. Used by the org.gradle.plugins.ide.eclipse.GenerateEclipseClasspath task to generate an Eclipse .classpath file.

The following example demonstrates the various configuration options. Keep in mind that all properties have sensible defaults; only configure them explicitly if the defaults don't match your needs.

 apply plugin: 'java' apply plugin: 'eclipse' configurations { provided someBoringConfig } eclipse { //if you want parts of paths in resulting file to be replaced by variables (files): pathVariables 'GRADLE_HOME': file('/best/software/gradle'), 'TOMCAT_HOME': file('../tomcat') classpath { //you can tweak the classpath of the Eclipse project by adding extra configurations: plusConfigurations += [ configurations.provided ] //you can also remove configurations from the classpath: minusConfigurations += [ configurations.someBoringConfig ] //if you want to append extra containers: containers 'someFriendlyContainer', 'andYetAnotherContainer' //customizing the classes output directory: defaultOutputDir = file('build-eclipse') //default settings for downloading sources and Javadoc: downloadSources = true downloadJavadoc = false } } 
For tackling edge cases, users can perform advanced configuration on the resulting XML file. It is also possible to affect the way that the Eclipse plugin merges the existing configuration via beforeMerged and whenMerged closures.

The beforeMerged and whenMerged closures receive a Classpath object.

Examples of advanced configuration:

 apply plugin: 'java' apply plugin: 'eclipse' eclipse { classpath { 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 .classpath content is loaded from existing file //but before gradle build information is merged beforeMerged { classpath -> //you can tinker with the Classpath here } //closure executed after .classpath content is loaded from existing file //and after gradle build information is merged whenMerged { classpath -> //you can tinker with the Classpath here } } } } 

EclipseJdt

open class EclipseJdt

Enables fine-tuning jdt details of the Eclipse plugin

 apply plugin: 'java' apply plugin: 'eclipse' eclipse { jdt { //if you want to alter the java versions (by default they are configured with gradle java plugin settings): sourceCompatibility = 1.6 targetCompatibility = 1.5 javaRuntimeName = "J2SE-1.5" file { //whenMerged closure is the highest voodoo //and probably should be used only to solve tricky edge cases. //the type passed to the closure is Jdt //closure executed after jdt file content is loaded from existing file //and after gradle build information is merged whenMerged { jdt //you can tinker with the Jdt here } //withProperties allows addition of properties not currently //modeled by Gradle withProperties { properties -> //you can tinker with the java.util.Properties here } } } } 

EclipseModel

open class EclipseModel

DSL-friendly model of the Eclipse project information. First point of entry for customizing Eclipse project generation.

 apply plugin: 'java' apply plugin: 'eclipse' apply plugin: 'eclipse-wtp' //for web projects only eclipse { pathVariables 'GRADLE_HOME': file('/best/software/gradle'), 'TOMCAT_HOME': file('../tomcat') project { //see docs for EclipseProject } classpath { //see docs for EclipseClasspath } wtp { //see docs for EclipseWtp } } 
More examples in docs for EclipseProject, EclipseClasspath, EclipseWtp

EclipseProject

open 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!

 apply plugin: 'java' apply plugin: '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:

 apply plugin: 'java' apply plugin: '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 } } } } 

EclipseWtp

open class EclipseWtp

Enables fine-tuning wtp/wst details of the Eclipse plugin

For projects applying the eclipse plugin and either one of the ear or war plugins, this plugin is auto-applied.

More interesting examples you will find in docs for EclipseWtpComponent and EclipseWtpFacet

 apply plugin: 'war' //or 'ear' or 'java' apply plugin: 'eclipse-wtp' eclipse { //if you want parts of paths in resulting file(s) to be replaced by variables (files): pathVariables 'GRADLE_HOME': file('/best/software/gradle'), 'TOMCAT_HOME': file('../tomcat') wtp { component { //for examples see docs for EclipseWtpComponent } facet { //for examples see docs for EclipseWtpFacet } } } 

EclipseWtpComponent

open class EclipseWtpComponent

Enables fine-tuning wtp component details of the Eclipse plugin

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

 apply plugin: 'war' //or 'ear' or 'java' apply plugin: 'eclipse-wtp' configurations { someInterestingConfiguration anotherConfiguration } eclipse { //if you want parts of paths in resulting file(s) to be replaced by variables (files): pathVariables 'GRADLE_HOME': file('/best/software/gradle'), 'TOMCAT_HOME': file('../tomcat') wtp { component { //you can configure the context path: contextPath = 'someContextPath' //you can configure the deployName: deployName = 'killerApp' //you can alter the wb-resource elements. //non-existing source dirs won't be added to the component file. sourceDirs += file('someExtraFolder') // dependencies to mark as deployable with lib folder deploy path libConfigurations += [ configurations.someInterestingConfiguration ] // dependencies to mark as deployable with root folder deploy path rootConfigurations += [ configurations.someInterestingConfiguration ] // dependencies to exclude from wtp deployment minusConfigurations << configurations.anotherConfiguration //you can add a wb-resource elements; mandatory keys: 'sourcePath', 'deployPath': //if sourcePath points to non-existing folder it will *not* be added. resource sourcePath: 'extra/resource', deployPath: 'deployment/resource' //you can add a wb-property elements; mandatory keys: 'name', 'value': property name: 'moodOfTheDay', value: ':-D' } } } 
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 WtpComponent object

Examples of advanced configuration:

 apply plugin: 'war' apply plugin: 'eclipse-wtp' eclipse { wtp { component { 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 wtp component file content is loaded from existing file //but before gradle build information is merged beforeMerged { wtpComponent -> //tinker with WtpComponent here } //closure executed after wtp component file content is loaded from existing file //and after gradle build information is merged whenMerged { wtpComponent -> //you can tinker with the WtpComponent here } } } } } 

EclipseWtpFacet

open class EclipseWtpFacet

Enables fine-tuning wtp facet details of the Eclipse plugin

Advanced configuration closures beforeMerged and whenMerged receive WtpFacet object as parameter.

 apply plugin: 'war' //or 'ear' or 'java' apply plugin: 'eclipse-wtp' eclipse { wtp { facet { //you can add some extra wtp facets; mandatory keys: 'name', 'version': facet name: 'someCoolFacet', version: '1.3' 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') } //beforeMerged and whenMerged closures are the highest voodoo for the tricky edge cases. //the type passed to the closures is WtpFacet //closure executed after wtp facet file content is loaded from existing file //but before gradle build information is merged beforeMerged { wtpFacet -> //tinker with WtpFacet here } //closure executed after wtp facet file content is loaded from existing file //and after gradle build information is merged whenMerged { wtpFacet -> //you can tinker with the WtpFacet here } } } } } 

Facet

open class Facet

A project facet.

FileReference

interface FileReference

A reference to a file in eclipse.

Jdt

open class Jdt : PropertiesPersistableConfigurationObject

Represents the Eclipse JDT settings.

Library

open class Library : AbstractLibrary

A classpath entry representing a library.

Link

open class Link

Link.

Output

open class Output : ClasspathEntry

A classpath entry representing an output folder.

Project

open class Project : XmlPersistableConfigurationObject

Represents the customizable elements of an eclipse project file. (via XML hooks everything is customizable).

ProjectDependency

open class ProjectDependency : AbstractClasspathEntry

A classpath entry representing a project dependency.

ResourceFilter

interface ResourceFilter

The gradle DSL model of an Eclipse resource filter. This allows specifying a filter with a custom matcher and configuring whether it is an include/exclude filter that applies to files, folders, or both. The following example excludes the 'node_modules' folder.

 apply plugin: 'java' apply plugin: 'eclipse' eclipse { project { resourceFilter { appliesTo = 'FOLDERS' type = 'EXCLUDE_ALL' matcher { id = 'org.eclipse.ui.ide.multiFilter' // to find out which arguments to use, configure the desired // filter with Eclipse's UI and copy the arguments string over arguments = '1.0-name-matches-false-false-node_modules' } } } } 

ResourceFilterAppliesTo

class ResourceFilterAppliesTo

Specifies the type of resource that the Eclipse ResourceFilter applies to.

ResourceFilterMatcher

interface ResourceFilterMatcher

The model of an Eclipse resource filter matcher.

The matcher decides when the containing filter (or containing matcher) applies. The matcher configures things like whether this ResourceFilter matches resources by name, project relative path, location, last modified, etc. Eclipse has many types of built-in matchers and it is possible to specify the id and arguments for custom matchers using this model.

A matcher must have an id. It may have either a custom string argument or a set of nested child matchers (e.g. an 'or' matcher will have several nested condition matchers).

For more documentation on usage with examples, see ResourceFilter.

ResourceFilterType

class ResourceFilterType

Specifies whether an Eclipse ResourceFilter is including or excluding resources.

SourceFolder

open class SourceFolder : AbstractClasspathEntry

SourceFolder.path contains only project relative path.

Variable

open class Variable : AbstractLibrary

A variable library entry.

WbDependentModule

open class WbDependentModule : WbModuleEntry

A wtp descriptor dependent module entry.

WbModuleEntry

interface WbModuleEntry

Represents an entry in wb-module.

WbProperty

open class WbProperty : WbModuleEntry

A wtp descriptor property entry.

WbResource

open class WbResource : WbModuleEntry

A wtp descriptor resource entry.

WtpComponent

open class WtpComponent : XmlPersistableConfigurationObject

Creates the .settings/org.eclipse.wst.common.component file for WTP projects.

WtpFacet

open class WtpFacet : XmlPersistableConfigurationObject

Creates the .settings/org.eclipse.wst.common.project.facet.core.xml file for WTP projects.