I assume this will be a static config file, right? i.e. not changed by any plugins, nor different from plugin to plugin - also true?
If that's so, it can really be handled the same as any other common/shared code, which I now handle by having a release procedure that automatically copies the common code into plugin specific directories for the released form of the plugin.
summary: during development, plugins have lrdevplugin extension and share common code from a common directory.
following release, plugins have lrplugin extension and common code has been copied to lrplugin subdirectory.
Yes, that's it true. The file is static, so it should not be changed by any other plugins. Automatic copy is a good solution, but I'm looking for the other way of solutions, like when you create a line require 'config' and it should find automatic the config file for you. Maybe we should set path on OS environment or something like that?
However, I find a temporarily solutions that need not to make any other copy of the original. It's to use symlink,, a way to make a reference to the original file without any copy.
Anyway thanks for advice.
Well, you can write your own loader to load files from wherever you want to, but then you need to make sure the file is in at least one of the place your going to look for it, which means you need to either write an installer, or trust your user to do the right thing.
John Ellis wrote such a require function that he has been generous enough to share with the community if you want to have a look.
Hi Rob, your solutions seem to be better, so I've change to what you has recommended, also make an automatic copy. Thanks again.
One thing I've learned: Its not good to have any critical files outside the lrplugin folder upon delivery.
Reason: Users sometimes assume there isn't, and may move it around without asking, or even delete other files that came with it.
I mean, if the plugin is using some form of link/reference to some files, then it may still find them, I've just never invented a way to handle this, but maybe you could, or make a feature request if you'd need Lr/SDK support for it to work well...
I used to have plugin dev folders and files:
- Common (lua modules)
- Plugin X.lrplugin
- Plugin Y.lrplugin
So when it was time to release, I just zipped up the doc, plugin, and common folder and that was all. Very convenient for me, but users kept misplacing the common folder, and then the plugin would not work, sometimes they even let me know there was a problem ;-}
Now, I have a plugin that releases other plugins and copies "Common modules" into 'lrplugin' subfolder.
So, its entirely possible you could invent a scheme that uses pseudo environment variables or a common subdirectory outside lrplugin or something, but I'm having a hard time imagining that being foolproof without an installer.
PS - I actually have a standard subdirectory under lrplugin named 'Preferences' just for config files.
Typical released plugin nowadays:
- Plugin X.lrplugin
- App (optional sidekick app)
- Framework (common lua modules)
- Preferences (config support files)
- Export Presets (if export plugin with built-in presets)
If you use common/shared/config modules, only way I know is to have a release procedure to copy stuff to lrplugin folder, or an installer to make sure files will be found outside lrplugin folder - but maybe I've missed some brilliant idea you are about to come up with :-)
Sorry, if I'm explaining too much about something you already understood - I'd be crucified for it on the tougher forums ;-}
Hello Rob. I've was busy for last moment so answer you a little bit late. Hope you don't mind. I've have now read your post. Yes, your theory seem to be correct, because the only way to do is to put your config file on plugins folder. So i got help to do an installer to make it work. I hope that in version sdk 4 it should be easier to make reference to path in require statement so we could refer in any folder we liket to. I've hope you have had a good weekend, and enjoy fun for the rest.
I'd love to hear about that installer, if you wouldn't mind sharing...
Hello again. The installer is not done by my self so I'm not wise as I should be. But basically what i know is that you are using Maven to do the installer. Here in maven you have to configure the xlm like the path to lightroom plugins. In the maven it auto zip your lightroom files then in the end it produce the .exe files if you are using windows. You can read more about maven,, how to do and some examples here at http://maven.apache.org/ and http://maven.apache.org/plugins/maven-install-plugin/.