# Classpath order generated by eclipse plugin causes problems

**URL:** <https://discuss.gradle.org/t/classpath-order-generated-by-eclipse-plugin-causes-problems/1354>\
**Category:** Old Forum Archive\
**Created:** [January 9, 2012, 12:03pm UTC](https://discuss.gradle.org/t/classpath-order-generated-by-eclipse-plugin-causes-problems/1354 "2012-01-09T12:03:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![stesieber](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/stesieber/32/377_2.png) [@stesieber](https://discuss.gradle.org/u/stesieber)\
**Post date:** [January 9, 2012, 12:03pm UTC](https://discuss.gradle.org/t/classpath-order-generated-by-eclipse-plugin-causes-problems/1354/1 "2012-01-09T12:03:00Z")

</div>

The Classpath ordering that is generated by the eclipse plugin causes problems with transitive dependencies. Consider the following case: -Project A has a dependency to Jar X version 1 -Project B has a dependency to project A and Jar X version 2

The .classpath file of project B generated by the eclipse plugin will list project A(and thus Jar X Version 1) before Jar X Version 2. This is wrong because during the gradle build Jar X version 2 is used.

It would be better if the project dependencies appeared after the dependencies to artifacts. I know this issue was discussed on the dev Mailing List, but I didn’t see any JIRA issue nor a topic here directly related to it. Discussion on Nabble: [http://gradle.1045684.n5.nabble.com/Classpath-order-in-Eclipse-plugin-td4515748.html#a4528629](http://gradle.1045684.n5.nabble.com/Classpath-order-in-Eclipse-plugin-td4515748.html#a4528629)

Issues that might be Related: - GRADLE-2016 - GRADLE-1835 - GRADLE-1614

I used the following workaround (inspired by GRADLE-1614)

```gradle
eclipse.classpath.file{
        whenMerged{ classpath ->
            def projectRefs = classpath.entries.findAll{entry -> entry.kind =='src' && entry.path.startsWith('/')}
            //move the project references to the end of the list:
            classpath.entries.removeAll(projectRefs)
            classpath.entries.addAll(projectRefs)
           }
       }

```

I hope this might help somebody in the future 😉

---

<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:** [January 9, 2012, 12:29pm UTC](https://discuss.gradle.org/t/classpath-order-generated-by-eclipse-plugin-causes-problems/1354/2 "2012-01-09T12:29:00Z")

</div>

I don’t see how changing the order would help. Assume A depends on X:2 and B depends on A and X:1. Then the current order would lead to the correct result, and the changed order would not.

A potential solution is to not export any dependencies from Eclipse project A but add them explicitly to B. Then Gradle’s conflict resolution should kick in.

---

<div class="post-metadata">

**Author:** ![stesieber](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/stesieber/32/377_2.png) [@stesieber](https://discuss.gradle.org/u/stesieber)\
**Post date:** [January 9, 2012, 1:01pm UTC](https://discuss.gradle.org/t/classpath-order-generated-by-eclipse-plugin-causes-problems/1354/3 "2012-01-09T13:01:00Z")

</div>

I assumed that the Jars referenced by A already went through the Gradle conflict resolution. To be honest I didn’t verify my assumption.

Your proposal is certainly more robust and will produce the expected behaviour.
