# How to perform specific tasks on buildship Refresh and Import

**URL:** <https://discuss.gradle.org/t/how-to-perform-specific-tasks-on-buildship-refresh-and-import/22120>\
**Category:** Help/Discuss\
**Tags:** buildship\
**Created:** [March 27, 2017, 2:24pm UTC](https://discuss.gradle.org/t/how-to-perform-specific-tasks-on-buildship-refresh-and-import/22120 "2017-03-27T14:24:37Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![johnBgood](https://avatars.discourse-cdn.com/v4/letter/j/b5ac83/32.png) [@johnBgood](https://discuss.gradle.org/u/johnBgood)\
**Post date:** [March 27, 2017, 2:24pm UTC](https://discuss.gradle.org/t/how-to-perform-specific-tasks-on-buildship-refresh-and-import/22120/1 "2017-03-27T14:24:37Z")

</div>

Hi there !

I’m starting using Buildship, and I saw that **eclipse** task is not used when I do a ‘Import Gradle project’, ok fine.  
Then I have 2 questions :

1. How can I perform some custom tasks when doing an Import. Previously I could do ‘eclipse dependsOn myTask’ but what now ?..

2. Same question on Refresh. How can I trigger my custom task when doing right clic on my project and ‘Gradle -\> Refresh’ ?

For now on, I have ugly **afterEvaluate {}** blocs in my buid.gradle files but I’d preffer some kind of hooks on Import / Refresh actions …

Thanks before for your help 🙂

John

---

<div class="post-metadata">

**Author:** ![jjstreet](https://avatars.discourse-cdn.com/v4/letter/j/dfb087/32.png) [@jjstreet](https://discuss.gradle.org/u/jjstreet)\
**Post date:** [March 29, 2017, 5:25pm UTC](https://discuss.gradle.org/t/how-to-perform-specific-tasks-on-buildship-refresh-and-import/22120/2 "2017-03-29T17:25:37Z")

</div>

I asked a question similar to yours a while back. Buildship does execute `eclipse` and `eclipseWtp` tasks if such tasks are available (from applying the plugins). It does this on gradle 3.0+.

> [@Buildship does not run eclipseWtp task](https://discuss.gradle.org/t/buildship-does-not-run-eclipsewtp-task/21245):
>
> I’m trying to figure out why my multiproject, when imported into eclipse through buildship does not have the wst component nature attached like it should. I’m using 1.0.21 and gradle 2.14.1. I’ve made sure every project applies the eclipse-wtp plugin by specifying it in the allprojects closure of the main build script. I could have sworn this worked at some point, now I’m stumped as to why its not. What are the requirements for importing a multi-project project and having buildship run the ecl…

It does not do this for earlier versions of gradle because those tasks were essentially busted.

You could make one of those tasks depend on your custom task, or make your custom task run after one of those via `mustRunAfter`

Also note that buildship is a young project still very much in development. You could offer your suggestions as issues in github as well.

---

<div class="post-metadata">

**Author:** ![johnBgood](https://avatars.discourse-cdn.com/v4/letter/j/b5ac83/32.png) [@johnBgood](https://discuss.gradle.org/u/johnBgood)\
**Post date:** [March 30, 2017, 8:40am UTC](https://discuss.gradle.org/t/how-to-perform-specific-tasks-on-buildship-refresh-and-import/22120/3 "2017-03-30T08:40:40Z")

</div>

First of all thanks for the reply !

But I import my projects by setting the Gradle version as 3.4.1 in buildship wizard. Then I have this in my build.gradle :

> task myTask(){  
> doFirst{  
> println “Hello there”  
> }  
> }  
> tasks.eclipse.dependsOn myTask

But the string Hello there is never printed ☹ (and I have the eclipse plugin applied)

Thanks again !

---

<div class="post-metadata">

**Author:** ![jjstreet](https://avatars.discourse-cdn.com/v4/letter/j/dfb087/32.png) [@jjstreet](https://discuss.gradle.org/u/jjstreet)\
**Post date:** [March 30, 2017, 6:29pm UTC](https://discuss.gradle.org/t/how-to-perform-specific-tasks-on-buildship-refresh-and-import/22120/4 "2017-03-30T18:29:19Z")

</div>

i’ve not actually tried to do what you attempting. I was just brainstorming. You might want to make sure you use buildship 2.0+ too, it might be related to that as well.

What kind of task do you need to accomplish when you import into eclipse? The eclipse plugins should have you covered for most of your needs.

---

<div class="post-metadata">

**Author:** ![johnBgood](https://avatars.discourse-cdn.com/v4/letter/j/b5ac83/32.png) [@johnBgood](https://discuss.gradle.org/u/johnBgood)\
**Post date:** [March 31, 2017, 3:59pm UTC](https://discuss.gradle.org/t/how-to-perform-specific-tasks-on-buildship-refresh-and-import/22120/5 "2017-03-31T15:59:08Z")

</div>

Yes I have the last version of Buildship 2.0.1.  
I use the APT plugin [Gradle apt plugin](https://github.com/tbroyer/gradle-apt-plugin) to add some annotation processor in my project.

The main problem is that even with a simple task like I mentioned :

> tasks.eclipse.dependsOn myTask

I never have the println happen.

Thanks

---

<div class="post-metadata">

**Author:** ![st\_oehme](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/st_oehme/32/5249_2.png) [@st\_oehme](https://discuss.gradle.org/u/st_oehme)\
**Post date:** [April 1, 2017, 12:23pm UTC](https://discuss.gradle.org/t/how-to-perform-specific-tasks-on-buildship-refresh-and-import/22120/6 "2017-04-01T12:23:41Z")

</div>

Buildship does not execute the eclipse task.

There is an open [feature request](https://github.com/eclipse/buildship/issues/265) already, please vote/follow there.

---

<div class="post-metadata">

**Author:** ![johnBgood](https://avatars.discourse-cdn.com/v4/letter/j/b5ac83/32.png) [@johnBgood](https://discuss.gradle.org/u/johnBgood)\
**Post date:** [April 3, 2017, 5:51pm UTC](https://discuss.gradle.org/t/how-to-perform-specific-tasks-on-buildship-refresh-and-import/22120/7 "2017-04-03T17:51:33Z")

</div>

Ok thanks for the clarification.  
So let’s say I use the [gradle node plugin](https://github.com/srs/gradle-node-plugin), then I have no way to execute the npmInstall task when importing or refreshing my project ?

Thanks again

---

<div class="post-metadata">

**Author:** ![st\_oehme](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/st_oehme/32/5249_2.png) [@st\_oehme](https://discuss.gradle.org/u/st_oehme)\
**Post date:** [April 4, 2017, 6:08am UTC](https://discuss.gradle.org/t/how-to-perform-specific-tasks-on-buildship-refresh-and-import/22120/8 "2017-04-04T06:08:56Z")

</div>

No, not at this point unfortunately.

---

<div class="post-metadata">

**Author:** ![johny123](https://avatars.discourse-cdn.com/v4/letter/j/a87d85/32.png) [@johny123](https://discuss.gradle.org/u/johny123)\
**Post date:** [February 9, 2018, 9:36am UTC](https://discuss.gradle.org/t/how-to-perform-specific-tasks-on-buildship-refresh-and-import/22120/9 "2018-02-09T09:36:16Z")

</div>

Hi, is there any plans to have this implemented in the near future?
