# Class EclipseClasspath

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

public abstract class EclipseClasspath extends Object
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.

    plugins {
        id 'java'
        id '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

        //if you want to expose test classes to dependent projects
        containsTestFixtures = true

        //customizing which Eclipse source directories should be marked as test
        testSourceSets = [sourceSets.test]

        //customizing which dependencies should be marked as test on the project's classpath
        testConfigurations = [configurations.testCompileClasspath, configurations.testRuntimeClasspath]
      }
    }

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:

    plugins {
        id 'java'
        id '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
          }
        }
      }
    }

Since:
  1.0

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `EclipseClasspath(Project project)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `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.
  `void`
  `file(Action<? super XmlFileContentMerger> action)`
  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.
  `abstract DirectoryProperty`
  `getBaseSourceOutputDir()`
  The base output directory for source sets.
  `List<File>`
  `getClassFolders()`
  Returns the class folders.
  `Set<String>`
  `getContainers()`
  The classpath containers to be added.
  `abstract Property<Boolean>`
  `getContainsTestFixtures()`
  Returns `true` if the classpath contains test fixture classes that should be visible through incoming project dependencies.
  `File`
  `getDefaultOutputDir()`
  The default output directory where Eclipse puts compiled classes.
  `XmlFileContentMerger`
  `getFile()`
  See `file(Action)`.
  `org.gradle.plugins.ide.eclipse.model.internal.FileReferenceFactory`
  `getFileReferenceFactory()`
  Returns the file reference factory.
  `Collection<Configuration>`
  `getMinusConfigurations()`
  The configurations whose files are to be excluded from the classpath entries.
  `Map<String,File>`
  `getPathVariables()`
  Returns the path variables.
  `Collection<Configuration>`
  `getPlusConfigurations()`
  The configurations whose files are to be added as classpath entries.
  `Project`
  `getProject()`
  Returns the project.
  `Iterable<SourceSet>`
  `getSourceSets()`
  The source sets to be added.
  `abstract SetProperty<Configuration>`
  `getTestConfigurations()`
  Returns the test configurations.
  `abstract SetProperty<SourceSet>`
  `getTestSourceSets()`
  Returns the test source sets.
  `boolean`
  `isDownloadJavadoc()`
  Whether to download and associate Javadoc Jars with the dependency Jars.
  `boolean`
  `isDownloadSources()`
  Whether to download and associate source Jars with the dependency Jars.
  `boolean`
  `isProjectDependenciesOnly()`
  Returns whether project dependencies only is set.
  `void`
  `mergeXmlClasspath(Classpath xmlClasspath)`
  Merge xml classpath.
  `List<ClasspathEntry>`
  `resolveDependencies()`
  Calculates, resolves and returns dependency entries of this classpath.
  `void`
  `setClassFolders(List<File> classFolders)`
  Sets the class folders.
  `void`
  `setContainers(Set<String> containers)`
  Sets the containers.
  `void`
  `setDefaultOutputDir(File defaultOutputDir)`
  Sets the default output dir.
  `void`
  `setDownloadJavadoc(boolean downloadJavadoc)`
  Sets the download javadoc.
  `void`
  `setDownloadSources(boolean downloadSources)`
  Sets the download sources.
  `void`
  `setFile(XmlFileContentMerger file)`
  Sets the file.
  `void`
  `setMinusConfigurations(Collection<Configuration> minusConfigurations)`
  Sets the minus configurations.
  `void`
  `setPathVariables(Map<String,File> pathVariables)`
  Sets the path variables.
  `void`
  `setPlusConfigurations(Collection<Configuration> plusConfigurations)`
  Sets the plus configurations.
  `void`
  `setProjectDependenciesOnly(boolean projectDependenciesOnly)`
  Sets the project dependencies only.
  `void`
  `setSourceSets(Iterable<SourceSet> sourceSets)`
  Sets the source sets.

  ### Methods inherited from class Object

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

- ## Constructor Details

  - ### EclipseClasspath

    @Inject public EclipseClasspath(Project project)

- ## Method Details

  - ### getSourceSets

    public Iterable<SourceSet> getSourceSets()
    The source sets to be added.

    See `EclipseClasspath` for an example.

    Since:
      1.0

  - ### setSourceSets

    public void setSourceSets(Iterable<SourceSet> sourceSets)
    Sets the source sets.
    Since:
      1.0

  - ### getPlusConfigurations

    public Collection<Configuration> getPlusConfigurations()
    The configurations whose files are to be added as classpath entries.

    See `EclipseClasspath` for an example.

    Since:
      1.0

  - ### setPlusConfigurations

    public void setPlusConfigurations(Collection<Configuration> plusConfigurations)
    Sets the plus configurations.
    Since:
      1.0

  - ### getMinusConfigurations

    public Collection<Configuration> getMinusConfigurations()
    The configurations whose files are to be excluded from the classpath entries.

    See `EclipseClasspath` for an example.

    Since:
      1.0

  - ### setMinusConfigurations

    public void setMinusConfigurations(Collection<Configuration> minusConfigurations)
    Sets the minus configurations.
    Since:
      1.0

  - ### getContainers

    public Set<String> getContainers()
    The classpath containers to be added.

    See `EclipseClasspath` for an example.

    Since:
      1.0

  - ### setContainers

    public void setContainers(Set<String> containers)
    Sets the containers.
    Since:
      1.0

  - ### getDefaultOutputDir

    public File getDefaultOutputDir()
    The default output directory where Eclipse puts compiled classes.

    See `EclipseClasspath` for an example.

    Since:
      1.0

  - ### setDefaultOutputDir

    public void setDefaultOutputDir(File defaultOutputDir)
    Sets the default output dir.
    Since:
      1.0

  - ### getBaseSourceOutputDir

    @Incubating public abstract DirectoryProperty getBaseSourceOutputDir()
    The base output directory for source sets.

    See `EclipseClasspath` for an example.

    Since:
      8.1

  - ### isDownloadSources

    public boolean isDownloadSources()
    Whether to download and associate source Jars with the dependency Jars. Defaults to true.

    See `EclipseClasspath` for an example.

    Since:
      1.0

  - ### setDownloadSources

    public void setDownloadSources(boolean downloadSources)
    Sets the download sources.
    Since:
      1.0

  - ### isDownloadJavadoc

    public boolean isDownloadJavadoc()
    Whether to download and associate Javadoc Jars with the dependency Jars. Defaults to false.

    See `EclipseClasspath` for an example.

    Since:
      1.0

  - ### setDownloadJavadoc

    public void setDownloadJavadoc(boolean downloadJavadoc)
    Sets the download javadoc.
    Since:
      1.0

  - ### getFile

    public XmlFileContentMerger getFile()
    See `file(Action)`.
    Since:
      1.0

  - ### setFile

    public void setFile(XmlFileContentMerger file)
    Sets the file.
    Since:
      1.0

  - ### getPathVariables

    public Map<String,File> getPathVariables()
    Returns the path variables.
    Since:
      1.0

  - ### setPathVariables

    public void setPathVariables(Map<String,File> pathVariables)
    Sets the path variables.
    Since:
      1.0

  - ### isProjectDependenciesOnly

    public boolean isProjectDependenciesOnly()
    Returns whether project dependencies only is set.
    Since:
      1.0

  - ### setProjectDependenciesOnly

    public void setProjectDependenciesOnly(boolean projectDependenciesOnly)
    Sets the project dependencies only.
    Since:
      1.0

  - ### getClassFolders

    public List<File> getClassFolders()
    Returns the class folders.
    Since:
      1.0

  - ### setClassFolders

    public void setClassFolders(List<File> classFolders)
    Sets the class folders.
    Since:
      1.0

  - ### getProject

    public Project getProject()
    Returns the project.
    Since:
      1.0

  - ### containers

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

    See `EclipseClasspath` for an example.

    Parameters:
      `containers` - the classpath containers to be added
    Since:
      1.0

  - ### file

    public void file(@DelegatesTo(XmlFileContentMerger.class) 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.

    Since:
      1.0

  - ### file

    public void file(Action<? super XmlFileContentMerger> action)
    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.

    Since:
      3.5

  - ### resolveDependencies

    public List<ClasspathEntry> resolveDependencies()
    Calculates, resolves and returns dependency entries of this classpath.
    Since:
      1.0

  - ### mergeXmlClasspath

    public void mergeXmlClasspath(Classpath xmlClasspath)
    Merge xml classpath.
    Since:
      1.0

  - ### getFileReferenceFactory

    public org.gradle.plugins.ide.eclipse.model.internal.FileReferenceFactory getFileReferenceFactory()
    Returns the file reference factory.
    Since:
      1.0

  - ### getContainsTestFixtures

    public abstract Property<Boolean> getContainsTestFixtures()
    Returns `true` if the classpath contains test fixture classes that should be visible through incoming project dependencies.
    Since:
      6.8

  - ### getTestSourceSets

    @Incubating public abstract SetProperty<SourceSet> getTestSourceSets()
    Returns the test source sets.

    The source directories in the returned source sets are marked with the 'test' classpath attribute on the Eclipse classpath.

    The default value contains the following elements:

    - All source sets with names containing the 'test' substring (case ignored)
    - All source sets defined via the jvm-test-suite DSL
    Since:
      7.5

  - ### getTestConfigurations

    @Incubating public abstract SetProperty<Configuration> getTestConfigurations()
    Returns the test configurations.

    All resolved dependencies that appear only in the returned dependency configurations are marked with the 'test' classpath attribute on the Eclipse classpath.

    The default value contains the following elements:

    - The compile and runtime configurations of the `getTestSourceSets()`, including the jvm-test-suite source sets
    - Other configurations with names containing the 'test' substring (case ignored)

    Note, that this property should contain resolvable configurations only.

    Since:
      7.5