# Gradle integration for eclipse keeps on changing .classpath file

**URL:** <https://discuss.gradle.org/t/gradle-integration-for-eclipse-keeps-on-changing-classpath-file/11813>\
**Category:** Help/Discuss\
**Tags:** buildship, eclipse\
**Created:** [September 22, 2015, 5:40pm UTC](https://discuss.gradle.org/t/gradle-integration-for-eclipse-keeps-on-changing-classpath-file/11813 "2015-09-22T17:40:39Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![fbudassi](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/fbudassi/32/3815_2.png) [@fbudassi](https://discuss.gradle.org/u/fbudassi)\
**Post date:** [September 22, 2015, 5:40pm UTC](https://discuss.gradle.org/t/gradle-integration-for-eclipse-keeps-on-changing-classpath-file/11813/1 "2015-09-22T17:40:39Z")

</div>

My current configuration includes a Java WAR project using gradle with the java and eclipse-wtp plugins, and the latest version of Buildship for Eclipse integration (1.0.3 till this morning and 1.0.4 right now) along with Eclipse Luna.

After following this solution [http://stackoverflow.com/a/9820317/1544713](http://stackoverflow.com/a/9820317/1544713) (successfully) to avoid deploying the test classes to my local server, I noticed that every time I refreshed the project or closed and opened Eclipse, the `.classpath` file and `.settings/org.eclipse.wst.common.component` were changed to their previous state, which is something I that gives me problems (deploying the test classes to the local server implies that they will fail to be loaded due to the lack of some test time dependencies, and of course an undesired behaviour).

The content of `.classpath` is changed from (the right one):

```
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
    <attributes>
        <attribute name="FROM_GRADLE_MODEL" value="true"/>
    </attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/resources">
    <attributes>
        <attribute name="FROM_GRADLE_MODEL" value="true"/>
    </attributes>
</classpathentry>

```

to this undesired state:

```
<classpathentry kind="src" path="src/test/java">
    <attributes>
        <attribute name="FROM_GRADLE_MODEL" value="true"/>
    </attributes>
</classpathentry>
<classpathentry kind="src" path="src/test/resources">
    <attributes>
        <attribute name="FROM_GRADLE_MODEL" value="true"/>
    </attributes>
</classpathentry>

```

And in the case of `.settings/org.eclipse.wst.common.component`, these two lines are added (which again, I don’t want them to be present):

```
    <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/test/java"/>
    <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/test/resources"/>

```

I can’t figure out if it is Gradle that is changing the files or Buildship, or even Eclipse. In any case, I guess there is a way to stop this happening. I have tried many alternatives, like the following configs in build.gradle:

```
eclipse.classpath.file.whenMerged { cp ->
    cp.entries.findAll { it.kind = "src" && it.path.startsWith("src/test/") }*.output = "target/test-classes"
}

eclipse {
    wtp.component {  
        file.withXml { xml ->       
            def node = xml.asNode()                     
            def wbrNodes = node.'**'.findAll { it.name() == 'wb-resource' && it.'@source-path'.startsWith("/src/test/")}
            if (wbrNodes.size() > 0) {
                wbrNodes.each { n -> n.parent().remove(n) }
            }                   
        }
    }
}

```

But this configuration works erratically (sometimes it seems to work, some other times it doesn’t, and actually the first piece of code that starts with eclipse.classpath.file.whenMerged never works).

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![fbudassi](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/fbudassi/32/3815_2.png) [@fbudassi](https://discuss.gradle.org/u/fbudassi)\
**Post date:** [September 22, 2015, 7:50pm UTC](https://discuss.gradle.org/t/gradle-integration-for-eclipse-keeps-on-changing-classpath-file/11813/2 "2015-09-22T19:50:36Z")

</div>

I have started to think that Buildship is my real problem, but i’m still unsure about why… Any help?

---

<div class="post-metadata">

**Author:** ![Lance\_Java](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/lance_java/32/787_2.png) [@Lance\_Java](https://discuss.gradle.org/u/Lance_Java)\
**Post date:** [September 23, 2015, 11:01am UTC](https://discuss.gradle.org/t/gradle-integration-for-eclipse-keeps-on-changing-classpath-file/11813/3 "2015-09-23T11:01:13Z")

</div>

I’m pretty sure you can’t use the [eclipse plugin](https://docs.gradle.org/current/userguide/eclipse_plugin.html) and buildship together. You’ll need to choose one or the other since they both manipulate the `.classpath` and `.project` files.

---

<div class="post-metadata">

**Author:** ![fbudassi](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/fbudassi/32/3815_2.png) [@fbudassi](https://discuss.gradle.org/u/fbudassi)\
**Post date:** [September 23, 2015, 12:50pm UTC](https://discuss.gradle.org/t/gradle-integration-for-eclipse-keeps-on-changing-classpath-file/11813/4 "2015-09-23T12:50:47Z")

</div>

Do you know if there is a way to prevent Buildship from modifying the `.classpath` and `.settings/org.eclipse.wst.common.component` when they have been manually changed?

---

<div class="post-metadata">

**Author:** ![Lance\_Java](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/lance_java/32/787_2.png) [@Lance\_Java](https://discuss.gradle.org/u/Lance_Java)\
**Post date:** [September 23, 2015, 1:19pm UTC](https://discuss.gradle.org/t/gradle-integration-for-eclipse-keeps-on-changing-classpath-file/11813/5 "2015-09-23T13:19:23Z")

</div>

I don’t think that’s currently possible. I _think_ buildship assumes it owns `.classpath` and `.project` and can therefore do what it wants with them.

Sounds like you want

```gradle
apply plugin: 'buildship' 

buildship.wtp.component.file.withXml { ... } 

```

This doesn’t exist but sounds like a reasonable feature request.

---

<div class="post-metadata">

**Author:** ![fbudassi](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/fbudassi/32/3815_2.png) [@fbudassi](https://discuss.gradle.org/u/fbudassi)\
**Post date:** [September 23, 2015, 1:23pm UTC](https://discuss.gradle.org/t/gradle-integration-for-eclipse-keeps-on-changing-classpath-file/11813/6 "2015-09-23T13:23:05Z")

</div>

Anyways, I still don’t understand how it is possible that something which (to me) seems a typical problem as preventing the test classes from being deployed in a local server can’t be handled in any way with Buildship…

---

<div class="post-metadata">

**Author:** ![Lance\_Java](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/lance_java/32/787_2.png) [@Lance\_Java](https://discuss.gradle.org/u/Lance_Java)\
**Post date:** [September 23, 2015, 1:28pm UTC](https://discuss.gradle.org/t/gradle-integration-for-eclipse-keeps-on-changing-classpath-file/11813/7 "2015-09-23T13:28:22Z")

</div>

I doubt that buildship currently supports wtp projects. I’d guess wtp support is part of the future roadmap.

Can you just have a normal (non wtp) project and deploy the war built by gradle? This won’t contain test classes

---

<div class="post-metadata">

**Author:** ![fbudassi](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/fbudassi/32/3815_2.png) [@fbudassi](https://discuss.gradle.org/u/fbudassi)\
**Post date:** [September 23, 2015, 1:35pm UTC](https://discuss.gradle.org/t/gradle-integration-for-eclipse-keeps-on-changing-classpath-file/11813/8 "2015-09-23T13:35:07Z")

</div>

Unluckily, I’m using JRebel to reload dynamically the classes while developing, so I depend on the stuff auto-compiled by Eclipse located in /bin/, and that’s why I wanted to move the \*Test.class from /bin/ to anywhere else…

Right now I’m trying with the other Gradle integration plugin (the one from Nodeclipse in the Eclipse Marketplace) to see if I can get a better result with it.

---

<div class="post-metadata">

**Author:** ![Lance\_Java](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/lance_java/32/787_2.png) [@Lance\_Java](https://discuss.gradle.org/u/Lance_Java)\
**Post date:** [September 23, 2015, 1:40pm UTC](https://discuss.gradle.org/t/gradle-integration-for-eclipse-keeps-on-changing-classpath-file/11813/9 "2015-09-23T13:40:52Z")

</div>

I think wtp and buildship have conflicting goals. One of buildship’s main goals is that eclipse is NOT the build tool. Everything is built by gradle and nothing is built to /bin/

---

<div class="post-metadata">

**Author:** ![Lance\_Java](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/lance_java/32/787_2.png) [@Lance\_Java](https://discuss.gradle.org/u/Lance_Java)\
**Post date:** [September 23, 2015, 1:44pm UTC](https://discuss.gradle.org/t/gradle-integration-for-eclipse-keeps-on-changing-classpath-file/11813/10 "2015-09-23T13:44:25Z")

</div>

Perhaps you could achieve the same functionality by running a `--continuous` task. The task could unzip the war to the server directory any time an input changes (eg a class file)

---

<div class="post-metadata">

**Author:** ![Lance\_Java](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/lance_java/32/787_2.png) [@Lance\_Java](https://discuss.gradle.org/u/Lance_Java)\
**Post date:** [September 23, 2015, 1:55pm UTC](https://discuss.gradle.org/t/gradle-integration-for-eclipse-keeps-on-changing-classpath-file/11813/11 "2015-09-23T13:55:08Z")

</div>

FYI gretty supports hot deployment

[http://akhikhl.github.io/gretty-doc/Hot-deployment.html](http://akhikhl.github.io/gretty-doc/Hot-deployment.html)

---

<div class="post-metadata">

**Author:** ![fbudassi](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/fbudassi/32/3815_2.png) [@fbudassi](https://discuss.gradle.org/u/fbudassi)\
**Post date:** [September 23, 2015, 7:14pm UTC](https://discuss.gradle.org/t/gradle-integration-for-eclipse-keeps-on-changing-classpath-file/11813/12 "2015-09-23T19:14:48Z")

</div>

Thanks for your help Lance\_Java. You are right, you can’t mix Buildship with the gradle plugin eclipse-wtp.

In the end, I had to change from Buildship to **Gradle IDE Pack 3.6.x+0.17** which uses build.gradle to build its model… It’s a pity because I wanted to use the official tools as much as possible, but this limitation (and the fact that Buildship doesn’t show custom tasks, though being a smaller limitation) made me leave it.

---

<div class="post-metadata">

**Author:** ![Lance\_Java](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/lance_java/32/787_2.png) [@Lance\_Java](https://discuss.gradle.org/u/Lance_Java)\
**Post date:** [September 24, 2015, 8:40am UTC](https://discuss.gradle.org/t/gradle-integration-for-eclipse-keeps-on-changing-classpath-file/11813/13 "2015-09-24T08:40:04Z")

</div>

Keep in mind that buildship is still in it’s infancy and the first release was 3 months ago. I’m sure WTP support is on the todo list.

I suggest you raise a feature request for the “withXml” hook I suggested above. Buildship improvements seem to arrive quickly from what I’ve seen. A new version was just announced 5 hours ago!

It’s likely some (most?) of this feature could be copied from the eclipse plugin

---

<div class="post-metadata">

**Author:** ![polle](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/polle/32/5651_2.png) [@polle](https://discuss.gradle.org/u/polle)\
**Post date:** [October 14, 2016, 7:57am UTC](https://discuss.gradle.org/t/gradle-integration-for-eclipse-keeps-on-changing-classpath-file/11813/14 "2016-10-14T07:57:29Z")

</div>

I’m having the same issue. Does anyone know of a workaround or whether there are any plans of fixing it?

---

<div class="post-metadata">

**Author:** ![jlczuk](https://avatars.discourse-cdn.com/v4/letter/j/b5a626/32.png) [@jlczuk](https://discuss.gradle.org/u/jlczuk)\
**Post date:** [July 24, 2019, 12:48pm UTC](https://discuss.gradle.org/t/gradle-integration-for-eclipse-keeps-on-changing-classpath-file/11813/15 "2019-07-24T12:48:50Z")

</div>

Nearly four years later, this problem still exists. Buildship infancy is no longer a viable explanation. Shall we infer that the official position is to just deal with it?
