Git command in gradle not working


(Yurii) #1

Hi,
I have such code and it works ok while I am executing gradle build in Intelij Idea and in console but in eclispe it does not produce any output.

Please, can someone explain me how to make horrible eclipse working in normal way??

ext{
    buildNumber = ("git rev-parse HEAD").execute().text.trim()
}

println buildNumber

(Schalk Cronjé) #2

If you hard-code the path to git i.e.e /usr/bin/git does it work then in Eclipse?


(Yurii) #3

I will try later, but it is not a solution of my problem, because my project must be able to build on different computers with different git installation directories, different OSs and different git versions.


(uklance) #4

You could use jgit, grgit or gradle-git


(Schalk Cronjé) #5

Not it is not, but it will tell you whether Eclipse removes PATH from the running environment.

Also I would echo @Lance’s recommendation for using grgit instead.


(Yurii) #6

Thank you for your answers and I am going to try grgit!
But why it have to change my PATH from the running environment why can not it work normally?


(Rob Sargent) #7

Because all IDEs are evil, even IntelliJ.


(Schalk Cronjé) #8

Many tools will do that to isolate the environment from the build process. Even though there can be some frustration in it, as you have discovered in it, there is a lot of good in it.

Accidental pollution from the environment can lead to builds failing on some systems an not others. It can also lead to builds that are not repeatable. Many plugins in Gradle will also isolate the environment to an absolute minimum when running external tools.