I have been discussing this issue with Peter Gromov of IntelliJ. He
believes that adding a special field to the generated build class like:
private static final File SOURCE_FILE = new File("<path>")
would be a good solution. To do this, I'll need to update the cache data to
know this source location so that if the source is moved then the class file
will be regenerated. If no one sees any issues with this, I'll submit a
patch in the next few days. This change will enable better IDE integration
and (I think) will be invisible to the end user of Gradle.
On Thu, Jun 11, 2009 at 2:50 PM, John Murph <[email protected]> wrote:
> I am trying to write an IDEA plugin to support Gradle. My primary concern
> is to support debugging. The issue I'm running into is mapping build files
> to classes in the VM. In a multi-project build, there are many files named
> build.gradle. Each of these is turned into a class called build_gradle.
> This is not unqiue enough for me. There are two scenario's that need to be
> supported (these are opposite cases):
>
> 1) When a breakpoint is placed in a gradle build file, I need to determine
> what class to set up for the breakpoint. This is currently easy (I'm
> actually creating an instance of FileScriptSource and calling the
> getClassName() method so that if the algorithm changes, the plugin still
> works).
>
> 2) When a breakpoint is reached, I need to take the class and figure out
> the file that should be displayed. This is currently a problem, as I don't
> know to which of the many build.gradle files this build_gradle class maps.
> I would love to have a method in Gradle to call for this purpose as well.
> Then the plugin really could work with any (future) version of Gradle.
>
> I've had several thoughts, but none of them are working out. I thought
> about putting the "project path" as the package structure for the build
> files, but that doesn't seem to work. I can determine what Gradle project I
> should be dealing with, but that doesn't help me find the build file (I
> should note that I don't want the plugin to have to "run" gradle as that
> seems fragile and complicated). I thought about putting a well known static
> final constant in the build class when it is compiled that points to the
> file, but if the file and cache are moved, that would break (it also seems
> kinda wrong, somehow).
>
> Does anyone have any ideas how to change Gradle so that build files can be
> matched up to running classes?
>
> P.S. If anyone cares, I'm writing this by looking at the Gant support in
> the JetGroovy plugin that is bundled with IDEA. I'm hoping to get this back
> into IDEA as a part of that plugin (or a separately bundled plugin).
> --
> John Murph
> Automated Logic Research Team
>
--
John Murph
Automated Logic Research Team