Integrating Gradle in a non-java-specific IDE

Hi all!

I am a happy Gradle and Emacs user and would like to add some better integration for gradle to Emacs.

Stuff that is usually a bit harder to do is getting the classpath so completion can be done easily.

Since I am using Gradle on a shared project with other people that do not use Emacs I can’t simply add support code to the gradle project files to support outputting stuff so emacs can read and know about the specific configuration.

I can add stuff like:

task classpath {
  configurations.each { configuration ->
    println configuration.compile.resolve().each { println it }
  }
}

To log all classpath dependencies, but what I am really looking for is a means to just get that from the cli using either the gradle executable or the wrapper and just ask it for the classpaths for tasks just as I can ask it about the projects and tasks per project.

An option would be to implement something like a cli eval method/task that would allow me to ask for classpaths once the build.gradle file and it’s dependencies has been resolved.

Any tips or ideas here for this? Would it be more beneficial to simply implement a server in Gradle that would ask the Gradle deamon for information?

Kind regards and thanks in advance,

Andreas Marschke.

Perhaps you could have an external settings file which you add via command line option

Eg: settings-emacs.gradle

gradle.projectsLoaded { Gradle gradle ->
   gradle.rootProject.with {
      task foo {
         doLast { println "$configurations.runtime.files"} 
      } 
   } 
} 

You could then do
gradle --settings c:/path/settings-emacs.gradle foo

You shouldn’t be using a settings file, but an init script for that. @Lance that’s probably what you meant, because the above won’t work.

Ah yeah… whoops
Correct, I meant an init script with the emacs specific tasks, not a settings

You can place init scripts in your user home and thus make them transparently executed on every build.

1 Like