We\'re looking at converting our Ant build to Gradle.
In regards to integration with Eclipse, we are looking for (conceptually) equivalent functionality for launch
I know this is an old question, but I still do not think it is possible to have Eclipse run a gradle build for you. The Spring Gradle plugin is a great start, if you use that, you can define an external tool builder to run gradle when you want. If you have lots of projects and all are being built with gradle, you can even have gradle add the capability to your eclipse projects for you. While this can be cleaned up, you can add something like this to your gradle build file:
apply plugin: 'eclipse'
eclipse {
project {
// Store a copy of the desired Gradle_Builder.launch file in a top-level 'master'
// directory. Then this code searches for it, and by copying it,
// adds the launch file to the specifc project that will run gradle
String launchFileNameOrig = '.externalToolBuilders/Gradle_Builder.launch'
String launchFileName = launchFileNameOrig
File launchFile = file(launchFileName)
boolean needToCopy = false
while (!launchFile.exists()) {
launchFileName = '../' + launchFileName
launchFile = file(launchFileName)
needToCopy = true
}
if (needToCopy) {
copy {
from (launchFile)
into '.externalToolBuilders'
}
}
buildCommand 'org.eclipse.ui.externaltools.ExternalToolBuilder', LaunchConfigHandle: '/'+launchFileNameOrig
file {
// when they made the "buildCommand" it looks like they left off 'triggers', so parse the XML until
// the right place is found, then insert it.
withXml {
def projectNode = it.asNode()
projectNode.iterator().each { subNode ->
String subNodeText = '' + subNode
if (subNodeText.startsWith('buildSpec')) {
subNode.iterator().each { buildCmd ->
String nameNode = buildCmd?.name
if (nameNode.contains('ExternalToolBuilder')) {
buildCmd.appendNode('triggers', 'full')
}
}
}
}
}
}
}
This is the content of the file stored at the top of the directory hierarchy under: ./.externalToolBuilders/Gradle_Builder.launch. As defined here, this will only run after a "clean" [Gradle is more expensive time-wise than the native Java Builder, so continue to use that for auto-building]. Note: the file contents below also assumes that you are using "git" and the gradle wrapper. You see this on the ATTR_LOCATION value. Adjust as needed. One nice thing about this approach though is that you can have the gradle wrapper be any version of gradle you want, and then eclipse will use that version when it runs!