Groovy Documentation

org.gradle.plugins.ide.eclipse.model
[Groovy] Class EclipseClasspath

java.lang.Object
  org.gradle.plugins.ide.eclipse.model.EclipseClasspath

class EclipseClasspath

The build path settings for the generated Eclipse project. Used by the 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 don't want some classpath entries 'exported' in Eclipse
     noExportConfigurations += configurations.provided

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


Property Summary
List classFolders

Set containers

The classpath containers to be added.

File defaultOutputDir

The default output directory where Eclipse puts compiled classes.

boolean downloadJavadoc

Whether to download and associate Javadoc Jars with the dependency Jars.

boolean downloadSources

Whether to download and associate source Jars with the dependency Jars.

XmlFileContentMerger file

See file(Closure).

Collection minusConfigurations

The configurations whose files are to be excluded from the classpath entries.

Collection noExportConfigurations

A subset of plusConfigurations whose files are not to be exported to downstream Eclipse projects.

Map pathVariables

Collection plusConfigurations

The configurations whose files are to be added as classpath entries.

org project

*

boolean projectDependenciesOnly

Iterable sourceSets

The source sets to be added.

 
Constructor Summary
EclipseClasspath(Project project)

 
Method Summary
void containers(String... containers)

Further classpath containers to be added.

void file(Closure closure)

Enables advanced configuration like tinkering with the output XML or affecting the way that the contents of an existing .classpath file is merged with Gradle build information.

FileReferenceFactory getFileReferenceFactory()

void mergeXmlClasspath(Classpath xmlClasspath)

List resolveDependencies()

Calculates, resolves and returns dependency entries of this classpath.

 
Methods inherited from class Object
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll
 

Property Detail

classFolders

List classFolders


containers

Set containers
The classpath containers to be added.

See EclipseClasspath for an example.


defaultOutputDir

File defaultOutputDir
The default output directory where Eclipse puts compiled classes.

See EclipseClasspath for an example.


downloadJavadoc

boolean downloadJavadoc
Whether to download and associate Javadoc Jars with the dependency Jars. Defaults to false.

See EclipseClasspath for an example.


downloadSources

boolean downloadSources
Whether to download and associate source Jars with the dependency Jars. Defaults to true.

See EclipseClasspath for an example.


file

XmlFileContentMerger file
See file(Closure).


minusConfigurations

Collection minusConfigurations
The configurations whose files are to be excluded from the classpath entries.

See EclipseClasspath for an example.


noExportConfigurations

Collection noExportConfigurations
A subset of plusConfigurations whose files are not to be exported to downstream Eclipse projects.

See EclipseClasspath for an example.


pathVariables

Map pathVariables


plusConfigurations

Collection plusConfigurations
The configurations whose files are to be added as classpath entries.

See EclipseClasspath for an example.


project

final org project
**


projectDependenciesOnly

boolean projectDependenciesOnly


sourceSets

Iterable sourceSets
The source sets to be added.

See EclipseClasspath for an example.


 
Constructor Detail

EclipseClasspath

EclipseClasspath(Project project)


 
Method Detail

containers

void containers(String... containers)
Further classpath containers to be added.

See EclipseClasspath for an example.

Parameters:
containers - the classpath containers to be added


file

void file(Closure closure)
Enables advanced configuration like tinkering with the output XML or affecting the way that the contents of an existing .classpath file is merged with Gradle build information. The object passed to the whenMerged{} and beforeMerged{} closures is of type Classpath.

See EclipseProject for an example.


getFileReferenceFactory

FileReferenceFactory getFileReferenceFactory()


mergeXmlClasspath

void mergeXmlClasspath(Classpath xmlClasspath)


resolveDependencies

List resolveDependencies()
Calculates, resolves and returns dependency entries of this classpath.


 

Gradle API 1.12