# Creating the classpath using the plugin

**URL:** <https://discuss.gradle.org/t/creating-the-classpath-using-the-plugin/11763>\
**Category:** Buildship\
**Tags:** eclipse, plugins\
**Created:** [September 20, 2015, 8:23pm UTC](https://discuss.gradle.org/t/creating-the-classpath-using-the-plugin/11763 "2015-09-20T20:23:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![aram535](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/aram535/32/3343_2.png) [@aram535](https://discuss.gradle.org/u/aram535)\
**Post date:** [September 20, 2015, 8:23pm UTC](https://discuss.gradle.org/t/creating-the-classpath-using-the-plugin/11763/1 "2015-09-20T20:23:10Z")

</div>

Hi,

I’m trying to create a text plugin for our eclipse projects.

eclipse.gradle:

```
allprojects {
    apply plugin:'eclipse'
    eclipse {
        project {
            buildCommand 'org.eclipse.buildship.core.gradleprojectbuilder'
            buildCommand 'org.eclipse.jdt.core.javabuilder'
            buildCommand 'edu.umd.cs.findbugs.plugin.eclipse.findbugsBuilder'
            natures = [
                    'org.eclipse.buildship.core.gradleprojectnature',
                    'org.eclipse.jdt.core.javanature',
                    'org.sonar.ide.eclipse.core.sonarNature',
                    'edu.umd.cs.findbugs.plugin.eclipse.findbugsNature']
        }
        classpath {
            file {
                beforeMerged { classpath ->
                    classpath.entries.removeAll { entry -> entry.kind == 'lib' || entry.kind == 'var' }
                }
                whenMerged { classpath ->
                    classpath.entries.findAll { entry -> entry.kind == 'lib' }*.exported = true
                }
            }

            if (env == 'dev') {
                downloadSources = true
                downloadJavadoc = true
            } else {
                downloadSources = false
                downloadJavadoc = false
            }
        }
    }
}

```

This produces this very clean .classpath, which is 1000% better than the mess that the default settings do.

```
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
        <classpathentry kind="output" path="bin"/>
        <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
</classpath>

```

What I would like to end up with, is this:

```
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
        <classpathentry kind="src" path="src">
                <attributes>
                        <attribute name="FROM_GRADLE_MODEL" value="true"/>
                </attributes>
        </classpathentry>
        <classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
        <classpathentry exported="true" kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
        <classpathentry kind="output" path="bin"/>
</classpath>
```

---

<div class="post-metadata">

**Author:** ![donat](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/donat/32/7798_2.png) [@donat](https://discuss.gradle.org/u/donat)\
**Post date:** [October 6, 2015, 6:11am UTC](https://discuss.gradle.org/t/creating-the-classpath-using-the-plugin/11763/2 "2015-10-06T06:11:00Z")

</div>

The same question was asked here:

> [@Gradle eclipse plugin](https://discuss.gradle.org/t/gradle-eclipse-plugin/11776):
>
> Hi, I’m trying to create a text plugin for our eclipse projects. eclipse.gradle: allprojects { apply plugin:'eclipse' eclipse { project { buildCommand 'org.eclipse.buildship.core.gradleprojectbuilder' buildCommand 'org.eclipse.jdt.core.javabuilder' buildCommand 'edu.umd.cs.findbugs.plugin.eclipse.findbugsBuilder' natures = [ 'org.eclipse.buildship.core.gradleprojectnature', 'org.eclipse.jdt…
