
This post is for any Jcr/CRX developers out there that are using IntelliJ as their IDE instead of CrxDE.
Ok, the reason I'm writing this little post is that I see several developers at my company using IntelliJ for developing against the Day server, but they keep a separate Terminal window open for doing all of their Vault commands. If you don't know what vault is or does, then this article is probably not for you. But if you do...
There is a feature in IntelliJ called External Tools. With it, you can make IntelliJ call, you guessed it, an external command. For our purposes we want to configure it to call a vault command, so that we don't have to keep a separate window open to add/update/checkin new files into the Jcr. In the screenshot above you can see my current External Commands vault setup.
Lets look at the 1st configuration, the checkin.

So on this screenshot you can see that I've named the command "vlt ci", and that I've put it in a Group called vault. This will group all of the vault commands together in your right click menu.
Also, in the Program setting I've pointed to the external program, the vlt command. On my system it is located in ~/apps/day/author/crx-quickstart/opt/filevault/vault-cli-2.2.22/bin/vlt.
The parameters setting gets ci $FilePath$ --force. I always do force, don't ask me why it just seems to work better.
And the last setting, Working Directory, gets $FileDir$/..This will allow you to right click on any file in the Project view tab or just right click on an file you have open, and the vault command will execute as if you had run it in that directory.
A quick note about the Parameters & Working Directory:
The reason I do: ci $FilePath$ --force is that the $FilePath$ will put the full filepath in the argument, and in the working directory you always want to be one directory up from where you are working. The reason to do this, is that you want to be able to use the same command for both files and directories.
A quick note about the Parameters & Working Directory:
The reason I do: ci $FilePath$ --force is that the $FilePath$ will put the full filepath in the argument, and in the working directory you always want to be one directory up from where you are working. The reason to do this, is that you want to be able to use the same command for both files and directories.
If you click on Insert Macro right by that field you will see some of the different options you can use.
So with this information you can create, Status, Delete, Update, and Add the same way. (Status won't need the extra stuff in Parameters, just the 'st' command.
After that I add my keymappings to do these quickly. I like Alt-C -> checkin, Alt-X -> status, Alt-A -> add, and Alt-Z for delete.
After that I add my keymappings to do these quickly. I like Alt-C -> checkin, Alt-X -> status, Alt-A -> add, and Alt-Z for delete.
OUTDATED: (The 2 separate commands 'below in grey' should no longer be needed if you do it the way I specified above)
One final little hack for the Add command. I had to create 2 separate commands - one for adding a directory, and another for adding a file. The only difference for adding a directory was that I had to move up a directory in the Working Directory field. Here is the screenshot that shows this:

And now you are setup. When you create a new file that you want to insert into the Jcr, you simply right click on it, and now in your right click menu, you should have a section named "Vault" that you can browse into and see a command names "vlt add file". After that you can check the file in in the same way.
If you run into issues, the console output at the bottom of your IntelliJ should give you some hints as to what you might have done wrong.
A couple of reasons why you want to do this from IntelliJ
- You don't want to keep a terminal open and pointed at the jcr_root directory of your project. On my projects I actually have several src root directories so if I'm using Terminals to vault stuff I actually need several Terminals open, each pointing to the src root so I can vault things up.
- Speed: Doing a whole tree checkin from the src root each time is slow. It's much faster to check in a file from the working directory. e.g. A file is in jcr_root/apps/stuff/stuff1/stuff2/stuff3/file.jsp. If you check it in from the jcr_root directory this can sometimes take several seconds (like 15 seconds sometimes on my system). If you cd down to the stuff3 directory and do a vlt ci there, it will work very quickly.
Hope this helps!
Hey, great work with this let's say tutorial. It's difficult to find information on working with day tools on the internet. I encourage you to continue spreading the knowledge. Regards.
ReplyDeleteGreat post - very helpful thanks
ReplyDelete