Need to make plugin's (non-Java) files available at runtime (Gradle newbie)

(Andrew McKibbin) #1

I feel I should be able to do this, but from the docs I can’t figure out how.

I have an existing legacy .exe tool that I want to wrap in a Gradle plugin so projects can use it as a build step. So I have a plugin that declares an Exec task to run the tool. The plugin’s publication artifacts include the .exe and associated dlls. I need to either (a) determine where those were found in the repository (so I can make that the working directory of the Exec task) or (b) copy them to a directory local to the project (so I can make THAT the working directory).

I haven’t managed to do the first one, and the only solution I created to the second was very clunky and involved the client gradle script doing the work (rather than the plugin).

Can anyone give me any pointers?

(detelinyordanov) #2

I had a similar case and did the following:

  • added all artifacts + dependencies required for the process to a separate configuration in my plugin, e.g. ‘process’ (the plugin’s own artifacts and dependencies are declared in the ‘runtime’ configuration) - at runtime the plugin would figure out its version and do a 2nd resolve, but this time resolving the ‘process’ configuration - this would deliver those artifacts and you can copy them wherever you like

I’m not sure this is the best approach, in my case the plugin does a couple of other things and running this process is an optional operation, that’s why I did not add this additional stuff in the ‘runtime’ configuration, and also because I would then had to filter them somehow.