sbt-idea icon indicating copy to clipboard operation
sbt-idea copied to clipboard

Have some way to run gen-idea automatically

Open copumpkin opened this issue 12 years ago • 5 comments
trafficstars

I'm not sure if I'm just using it wrong or if I haven't found the endorsed way to do this yet, but basically:

I want gen-idea to run automatically when the project files are updated. That is, when the sbt build itself is changed, I want my idea files to get regenerated. Is there a way to make that happen, or can one be added? I realize that it won't capture library dependencies that can vary externally but I don't want that anyway, and it feels more correct for the idea derived build to happen when the main build is being run.

copumpkin avatar Apr 17 '13 04:04 copumpkin

What do you mean by this: "idea derived build to happen when the main build is being run"? How do you run the main build? Or in other words, with which sbt command/task you would like 'gen-idea' to be run? What detects that project files are updated? Or is this auto-detection mechanism the one you're asking here?

Currently I think this would only be possible by using some external program (inotify etc.) to watch for the changes in sbt build files and run 'sbt gen-idea' on change. Sbt's ~reload does not work as expected here, because it only watches for changes in main sources, not build definition.

mpeltonen avatar Apr 17 '13 06:04 mpeltonen

Oh, that was a pretty bad sentence, sorry! I meant that it feels "right" for gen-idea to run when the inter-project dependencies and other forms of project structure are being figured out during sbt's own startup, and not necessarily so much at the user's discretion (except perhaps when they know that something has changed in their ivy repo or something's broken).

I realize that sbt doesn't actually provide a very clean mechanism to jump in at startup like that, but I've been experimenting with a combination of hacky onLoad hooks with a canonical representation of inter-project and external dependencies to avoid unnecessary work. It seems to be working so far, but it's not done yet, and is set up kind of specifically to my project. Does any of that make sense?

copumpkin avatar Apr 17 '13 06:04 copumpkin

Is it possible to have gen-idea run automatically when update is executed?

doxxx avatar Apr 23 '13 11:04 doxxx

@doxxx: gen-idea is a command and I'm not currently aware of a way to run commands programmatically from your build files, or add interdependencies between/to them like you can do with tasks. I'm happy to be proved wrong though!

mpeltonen avatar Apr 23 '13 11:04 mpeltonen

Does it have to be a command? Could it be a task?

copumpkin avatar Jul 30 '14 16:07 copumpkin