How to perform specific tasks on buildship Refresh and Import

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 :slight_smile:

John

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+.

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.

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 :frowning: (and I have the eclipse plugin applied)

Thanks again !

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.

Yes I have the last version of Buildship 2.0.1.
I use the APT plugin 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

Buildship does not execute the eclipse task.

There is an open feature request already, please vote/follow there.

Ok thanks for the clarification.
So let’s say I use the gradle node plugin, then I have no way to execute the npmInstall task when importing or refreshing my project ?

Thanks again

No, not at this point unfortunately.

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