gradle
8.3

# EclipseClasspath

abstract 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.

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

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

Content copied to clipboard

## Constructors

EclipseClasspath
Link copied to clipboard
@Inject
constructor(project: Project)

## Functions

containers
Link copied to clipboard
open fun containers(containers: Array<String>)
Further classpath containers to be added.
file
Link copied to clipboard
open fun file(@DelegatesTo(value = XmlFileContentMerger::class) closure: Closure)
open fun file(action: Action<out Any>)
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.
getBaseSourceOutputDir
Link copied to clipboard
@Incubating
abstract fun getBaseSourceOutputDir(): Property<File>
The base output directory for source sets.
getFileReferenceFactory
Link copied to clipboard
open fun getFileReferenceFactory(): FileReferenceFactory
isDownloadJavadoc
Link copied to clipboard
open fun isDownloadJavadoc(): Boolean
Whether to download and associate Javadoc Jars with the dependency Jars.
isDownloadSources
Link copied to clipboard
open fun isDownloadSources(): Boolean
Whether to download and associate source Jars with the dependency Jars.
isProjectDependenciesOnly
Link copied to clipboard
open fun isProjectDependenciesOnly(): Boolean
mergeXmlClasspath
Link copied to clipboard
open fun mergeXmlClasspath(xmlClasspath: Classpath)
resolveDependencies
Link copied to clipboard
open fun resolveDependencies(): List<ClasspathEntry>
Calculates, resolves and returns dependency entries of this classpath.
setDownloadJavadoc
Link copied to clipboard
open fun setDownloadJavadoc(downloadJavadoc: Boolean)
setDownloadSources
Link copied to clipboard
open fun setDownloadSources(downloadSources: Boolean)
setProjectDependenciesOnly
Link copied to clipboard
open fun setProjectDependenciesOnly(projectDependenciesOnly: Boolean)

## Properties

classFolders
Link copied to clipboard
open var classFolders: List<File>
containers
Link copied to clipboard
open var containers: Set<String>
containsTestFixtures
Link copied to clipboard
val containsTestFixtures: Property<Boolean>
defaultOutputDir
Link copied to clipboard
open var defaultOutputDir: File
file
Link copied to clipboard
open var file: XmlFileContentMerger
minusConfigurations
Link copied to clipboard
open var minusConfigurations: Collection<Configuration>
pathVariables
Link copied to clipboard
open var pathVariables: Map<String, File>
plusConfigurations
Link copied to clipboard
open var plusConfigurations: Collection<Configuration>
project
Link copied to clipboard
val project: Project
sourceSets
Link copied to clipboard
open var sourceSets: Iterable<SourceSet>
testConfigurations
Link copied to clipboard
@get:Incubating
val testConfigurations: SetProperty<Configuration>
testSourceSets
Link copied to clipboard
@get:Incubating
val testSourceSets: SetProperty<SourceSet>