How can I configure the eclipse configuration in the build script to generate a path variable that points to the Gradle executable?


(Brian Hyder) #1

How can I configure the eclipse configuration in the build script to generate a path variable that points to the Gradle executable?

I’m using Gradle Version: 1.0-milestone-8a

The end goal is to get gradle to generate a .project file with a variable named GRADLE_EXECUTABLE so that I can essentially create an external builder that already has the executable path stored in a variable.

<projectDescription>
 <variableList>
  <variable>
   <name>GRADLE_EXECUTABLE</name>
   <value>file:/C:/Program Files/Gradle/gradle-1.0-milestone-8a/bin/gradle.bat</value>
  </variable>
 </variableList>
</projectDescription>

Any help would be appreciated!


(Peter Niederwieser) #2

‘project.gradle.gradleHomeDir’ should help.


(Brian Hyder) #3

My fault, I should have been a little more specific on what I have currently done.

I have been able to generate the path in a variable in the build script using:

gradleExecutable = gradle.gradleHomeDir.path + File.separator + 'bin' + File.separator + 'gradle' + exeExtension

Then I have tried to configure the eclipse object to set a path variable:

/** Specify Eclipse Configuration */
eclipse {
 pathVariables 'GRADLE_EXECUTABLE': file(gradleExecutable)
    classpath{
  defaultOutputDir = file('build/eclipse_output')
 }
}

I then run the command:

gradle cleanEclipse eclipse

It generates the project file but no variables were created in the .project file.


(Peter Niederwieser) #4

First, ‘exeExtension’ sounds wrong. Depending on your platform, you’ll need either ‘gradle’ or ‘gradle.bat’. A simple way to construct the path is ‘file("$gradle.gradleHomeDir/bin/gradle")’.

Second, ‘pathVariables’ is for shortening absolute paths in class path entries (see the documentation). It won’t generate ‘variable’ entries in the ‘.project’ file. That you will have to do with an XML hook. If you think there should be an easier way, pull request are welcome. :slight_smile:


(Brian Hyder) #5

Thanks for the input. I was able to get the variable created using the XML hooks. The one thing that I would definitely put in a feature request for is the ability to create and configure external builders.


(Peter Niederwieser) #6

Are you looking for something not covered by build commands?