# Eclipse plugin: add new element to a classpathentry

**URL:** <https://discuss.gradle.org/t/eclipse-plugin-add-new-element-to-a-classpathentry/6432>\
**Category:** Old Forum Archive\
**Created:** [December 9, 2011, 1:11pm UTC](https://discuss.gradle.org/t/eclipse-plugin-add-new-element-to-a-classpathentry/6432 "2011-12-09T13:11:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pascal\_Stieber](https://avatars.discourse-cdn.com/v4/letter/p/f07891/32.png) [@Pascal\_Stieber](https://discuss.gradle.org/u/Pascal_Stieber)\
**Post date:** [December 9, 2011, 1:11pm UTC](https://discuss.gradle.org/t/eclipse-plugin-add-new-element-to-a-classpathentry/6432/1 "2011-12-09T13:11:00Z")

</div>

Hey guys,

i’m messing around with the eclipse plugin for days. hope sb. can help me! my problem: when i create the .classpath file it would be nice to add a new element in an classpathentry. each classpathentries containing my project depedencies should contain a new src element which refers to the \*-src.jar.

concrete example: actual:

what i want:

i hope somebody can help !?!?

---

<div class="post-metadata">

**Author:** ![Pascal\_Stieber](https://avatars.discourse-cdn.com/v4/letter/p/f07891/32.png) [@Pascal\_Stieber](https://discuss.gradle.org/u/Pascal_Stieber)\
**Post date:** [December 9, 2011, 1:14pm UTC](https://discuss.gradle.org/t/eclipse-plugin-add-new-element-to-a-classpathentry/6432/2 "2011-12-09T13:14:00Z")

</div>

i am sry. the example seems to get lost!

a new trial: actuall:

```gradle
<classpathentry kind="src" path="/someDependendComponent" exported="true"/>

```

what i want:

```gradle
<classpathentry kind="src" path="/someDependendComponent" exported="true" src="path/to/dependendComponent-src.jar"/>

```

---

<div class="post-metadata">

**Author:** ![Peter\_Niederwieser](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@Peter\_Niederwieser](https://discuss.gradle.org/u/Peter_Niederwieser)\
**Post date:** [December 10, 2011, 8:02am UTC](https://discuss.gradle.org/t/eclipse-plugin-add-new-element-to-a-classpathentry/6432/3 "2011-12-10T08:02:00Z")

</div>

Is this for dependencies that aren’t available from a Maven or Ivy repository? Otherwise you should get this for free.

---

<div class="post-metadata">

**Author:** ![Pascal\_Stieber](https://avatars.discourse-cdn.com/v4/letter/p/f07891/32.png) [@Pascal\_Stieber](https://discuss.gradle.org/u/Pascal_Stieber)\
**Post date:** [December 11, 2011, 2:14pm UTC](https://discuss.gradle.org/t/eclipse-plugin-add-new-element-to-a-classpathentry/6432/4 "2011-12-11T14:14:00Z")

</div>

yes, you are right. this are project dependencies and they’re not available from a repository. but i need its src path. how can i add this?

---

<div class="post-metadata">

**Author:** ![rolfsuurd1](https://avatars.discourse-cdn.com/v4/letter/r/d9b06d/32.png) [@rolfsuurd1](https://discuss.gradle.org/u/rolfsuurd1)\
**Post date:** [December 12, 2011, 11:30am UTC](https://discuss.gradle.org/t/eclipse-plugin-add-new-element-to-a-classpathentry/6432/5 "2011-12-12T11:30:00Z")

</div>

There might be a more ‘groovy’ way to do it but you can adjust the actual .classpath file ‘by hand’ like this:

```gradle
eclipse {
    classpath {
        file {
            withXml {
                def node = it.asNode()
                node.appendNode('classpathentry', [kind: 'src', path: 'some/path', exported: true, src: 'path/to/component-src.jar'])
            }
        }
    }
}

```

---

<div class="post-metadata">

**Author:** ![Pascal\_Stieber](https://avatars.discourse-cdn.com/v4/letter/p/f07891/32.png) [@Pascal\_Stieber](https://discuss.gradle.org/u/Pascal_Stieber)\
**Post date:** [December 13, 2011, 1:07pm UTC](https://discuss.gradle.org/t/eclipse-plugin-add-new-element-to-a-classpathentry/6432/6 "2011-12-13T13:07:00Z")

</div>

i solved this problem as follows:

```gradle
whenConfigured { classpath ->
 classpath.entries.findAll{entry -> entry.kind == 'src' && entry.exported == true}.each{
  def componentName = it.path
  def sourcePath = fileTree("${rootDir}/${componentName}/build/libs").findAll{it.name.endsWith("src.jar")}
              withXml {
            def node = it.asNode()
          node.appendNode('classpathentry', [kind: 'src', path: componentName, exported: true, sourcepath: sourcePath.join()])
     }
     }
      classpath.entries -= classpath.entries.findAll{entry -> entry.kind == 'src' && entry.exported == true}
}

```

it would be nice if this workaround would be a part of the plugin.
