Eclipse launcher with gradle

(nicolas ciaravola) #1

Hi everybody,

I’m using gradle to generate my eclipse project.

So far so good, all works fine…(classpath, …) are correctly generated.

Question :

What is the best way to create an eclipse launcher that will use the repository dependencies automatically ?


(Szczepan Faber) #2

What do you mean by ‘eclipse launcher’? E.g. launch configuration?

My suggestion is not to use launcher :slight_smile: Instead create a java class that runs whatever your launcher needed to run. Make sure that this class lives in a project that has the classpath it needs. You can put this class in test sources in necessary. If one wants to run he just opens the class and runs/debugs.

This solution is also IDE-agnostic, so if someone uses a different IDE in your project he still can run this class.

Hope that helps!

(Blaine Simpson) #3

From Eclipse, use pulldown menu Run / External Tools / External Tools Configurations…

Select “Program” in left navigator panel then click the “New launch configuration” button in the tool bar (first button in my tool bar).

With Main tab selected, fill out the following fields:

  1. Name: (above the tabs) to "Gradle" (or whatever name you want for the launcher).
  2. Location: Use "Browse File System..." button to navigate to your "gradle.bat" or "gradlew.bat" to run.
  3. Working Directory: Use "Browse Workspace..." button to select directory with the "build.gradle" file for the desired project.
  4. Arguments: Enter "--gui"

Add to Arguments: the switch “-b filename.gradle” if you use a Gradle build file other than “build.gradle”.

After this, you can use the Run / External Tools or tool bar button to launch the Gradle Gui. You can do this and close it after each use, or (to avoid startup lag), minimize it when not in use.