Does anybody know if there is a way to automatically commit a project (a directory) just after a successful build from within an IDE? That is: something like a continous integration system, just lighter and better fit for a low-ceremony, “solo development” scenario.
I’m particularly interested in any solution that can work with IntelliJ IDEA (Community Edition) and GIT for Android projects (Java/Ant/Maven) but I’m also interested in other solutions (Eclipse, Netbeans, SVN, Hg, etc.). I’m also interested in a more general discussion on this topic (it is a good/bad idea, it can be done this way or this other, etc.).
I’m also open to code-based solutions (scripts, plug-ins, etc.). In particular, does anybody know if IntelliJ IDEA offers any “hook” for executing a script just before/after a menu command?
RATIONALE: I’m using IDEA to make a long series of small (but painful) experiments on an existing Android project and I would like to be able to go back step-by-step when needed using GIT (each step being represented by one of the previous successful builds). Call it “breadcrumbs programming” if you like.
Please note: I do know that this can be easily obtained with Ant/Maven/GIT/many-other-tools from the command line. I just want to see if it is possible to do it from within any of the IDEs I’m used to. And yes: I know I should commit often. I do it. I’m just tired to do it by hand.
OK, it looks like that this is not (yet) possible with IntelliJ IDEA, even if there is a very similar feature request sleeping since 2007: http://youtrack.jetbrains.com/issue/IDEABKL-5755 .
As long as I can see, the only IDE that currently offers a hook for executing a pre/post-build script in its own GUI is Eclipse, thanks to its “Builders” dialog:
Eclipse adding your own build command
Both IDEA and NetBeans rely on Ant targets (only) for this kind of pre/post-build processing tasks. See: https://ant.apache.org/manual/Tasks/exec.html .
Unfortunately, there is not yet a real integration between Ant and GIT (even if there are a few projects out there) so either you have to rely on a OS command (a process fork) or you can try to use JGit (http://eclipse.org/jgit/).
Another possible solution would be to modify the existing IDE GIT plug-in and make it able to accept pre/post-commit tasks or scripts (Eclipse, NetBeans and IDEA use plug-ins to interact with GIT).
Most likely, for the task at hand I will rely on my (old and tired) hands or on an Ant script.
In any case, IMHO, the “right” way to perform this kind of automatic commit would be the following:
Of course, a failed build should abort the remaining operations.
This would/should/ought NOT replace the normal, hand-performed, flow of commits. It should complement it, instead (maybe using a seperated GIT local repository or a separated branch).