I know this is an old question, but I still don't think Eclipse can run the gradle construct for you. The Spring gradle plugin is a great start, if you use it, you can define an external tool constructor to start gradle whenever you want. If you have many projects and they are all built using gradle, you can even gradle add features for your eclipse projects for you. Although this can be cleaned up, you can add something like this to the 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: '<project>/'+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 contents of the file stored at the top of the directory hierarchy: ./. ExternalToolBuilders / Gradle_Builder.launch. As defined here, this will only work after the "clean" [Gradle will be more expensive in time than the native Java Builder, so continue to use it to build automatically]. Note: the content below assumes that you are using a βgitβ and gradle wrapper. You see this in the value of ATTR_LOCATION. Adjust if necessary. One of the nice things about this approach is that you can have a gradle shell for any version of gradle you want, and then the eclipse will use that version when it starts!
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <launchConfiguration type="org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType"> <stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${workspace}"/> <booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/> <stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${git_dir}/../gradlew"/> <stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,"/> <stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="assemble"/> <booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/> <stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${project_loc}"/> </launchConfiguration>
JoeG Aug 30 '12 at 11:33 2012-08-30 11:33
source share