Gradle launch comes from Eclipse

We are looking at converting our Ant build to Gradle.

As for integration with Eclipse, we are looking for (conceptually) equivalent functionality to run assemblies from the IDE. Eclipse provides a nice Ant view for invoking Ant targets.

There is an Eclipse plugin for launching Gradle assemblies (http://www.breskeby.com/downloads/gradle/eclipse/update/), but this, apparently, requires users to go through hoops to call different ones (change the launch configuration, etc.) .d.).

How do others use Gradle from Eclipse?

+45
eclipse gradle
Jun 22 2018-11-18T00:
source share
12 answers

The short answer is that we are not calling gradle scripts from Eclipse.

I believe that this site describes where this work is now, and now it is not.

I'm a little curious about what tasks you want to run from Eclipse. Why not run tasks from the command line?

+15
Jun 22 2018-11-22T00:
source share

This is a kind of old post, but SpringSource STS team released a plugin: http://static.springsource.org/sts/docs/latest/reference/html/gradle/

Installation instructions can be found here: http://static.springsource.org/sts/docs/latest/reference/html/gradle/installation.html

So far, my experience has been pretty positive. For direct Java projects, this works very well. I'm having some problems creating the correct war files through Eclipse when using the Gradle plugin, but Gradle itself does it wonderfully. I am relatively new to Gradle and the plugin, so this may be something that I am missing.

+24
Feb 09 '12 at 17:04
source share

Intermediate work is more acceptable for those who have a command line phobia.

From Eclipse, use the Run / External Tools / External Tools Configurations ... drop-down menu.

Select "Program" in the left pane of the navigator, then click the "New Launch Settings" button on the toolbar (first button on the toolbar).

When you select the Main tab, fill in the following fields:

  • Name: (above the tabs) to "Gradle" (or any other name you want to run).
  • Location: Use the Browse File System ... button to go to your gradle.bat or gradlew.bat to start.
  • Working directory: use the "Browse workspace ..." button to select the directory with the "build.gradle" file for the desired project.
  • Arguments: type "--gui"

Add to arguments: switch "-b filename.gradle" if you are using a Gradle build file other than "build.gradle".

After that, your developers can use the Run / External Tools button or toolbar to launch Gradle Gui. They can do this and close it after each use, or (to avoid delayed startup), minimize it when not in use.

+21
Oct 19 '11 at 20:08
source share

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> 
+8
Aug 30 '12 at 11:33
source share

The current answer to this question should be, Use Gradle's own Eclipse Buildship plugin :

http://projects.eclipse.org/projects/tools.buildship

This is maintained and developed by the Gradle team and will continue to improve in the future. It can also handle older versions (with functionality based on the availability of the Gradle version).

Edit 2017-03-01: After the release of Buildship 2.0, integration is even better, and I recommend it (if you are not already using IntelliJ, and then already installed). There are still some missing features, such as the ability to directly debug JavaExec tasks and the ability to perform precompilation / preimport tasks, but they are on the Github Problem List .

+8
Mar 07 '16 at 13:19
source share

You can create a custom launcher from eclipse that will call your Gradle construct.

+5
Jun 23 2018-11-11T00:
source share

You can use the Gradle Eclipse plugin , like gradle eclipse , to create an Eclipse project from a gradle project. It adds many goals to generated Eclipse projects and is highly customizable.

+2
Jun 22 '11 at 15:44
source share

As always, you better work with IDEA. Support has existed since 2009 http://blogs.jetbrains.com/idea/2009/08/gradle-support/

and even more complete support is now available through EAP (free to use!) http://blogs.jetbrains.com/idea/2011/09/keen-to-try-gradle-integration-in-intellij-idea/

+2
Oct 17 '11 at 9:24 a.m.
source share

You can use the buildship as indicated by FkYkko. However, keep in mind that Ant tasks are considered first-class citizens in gradle. This means that you can simply import the Ant build script, referring to your tasks in the same way as you refer to gradle tasks. Doing this allows you to simply use your Ant tasks out of the box with gradle, without converting them to gradle tasks.

For example, let's say that you have a script assembly called build.xml in the same directory as build.gradle, and a task in build.xml called buildProj. You can import build.xml and call build proj from build.gradle as follows:

 task antDeps { ant.importBuild 'build.xml' } task buildAll (dependsOn:['buildProj']) { // the rest of your gradle task here. } 

See this or this for more information.

+2
Jun 16 '16 at 16:17
source share

There is also Enide Gradle http://www.nodeclipse.org/projects/gradle
which can be used with or without the Gradle IDE by Pivotal.
In a Gradle, Maven, or CDT (C ++) project.

run

As a separate plugin, it can have a different configuration for the Gradle version and the Java version to use

This Gradle IDE package is in Enide

+1
Apr 24 '14 at 3:58
source share

I came across this issue after installing the new Buildship plugin, which is phasing out the Spring Tool Suite mentioned by others here.

Instructions for using the task view with Buildship:

Using the Gradle Tasks View

After importing the Gradle project successfully, the project is shown in the Gradle Tasks view. enter image description here By right-clicking on a specific Gradle task in the Gradle Tasks view, you can run the selected Gradle task.

enter image description here

By default, the result is displayed in the Gradle Executions view. It also appears in the Console view, similar to get output if you run the task through the command line.

Source

0
Oct 16 '16 at 19:03
source share

Another new project in 2016 - EGradle

https://github.com/de-jcup/egradle

It also does not require Project to have a special character, only the existing build.gradle would be enough.

The user manual is in the built-in help ( F1 ) or in the view mode https://rawgit.com/de-jcup/egradle/master/egradle-plugin-main/html/user_guide.html

0
Dec 12 '16 at 14:13
source share



All Articles