I have several general purpose classes in my local plugins, Also several general purpose functions in each plugin's locallib.php. I have been copying them verbatim from one plugin to another, and only changing the local_[pluginname] prefix.
I have three such local plugins as part of my Moodle website now, with duplicates of those general purpose classes and functions. It would be nice if they were in just one place. Would it be a terrible transgression of Moodle fashion to move those general purpose classes and functions to one common local plugin, and have the other plugins depend on and include files from that common plugin? Does anybody do it that way?
I know that common classes and functions are usually defined in a moodle/lib/somethinglib.php file, or in a moodle/lib/classes/something.php file. But, I am trying to steer clear of adding any files in the core Moodle, and keep all my stuff in local plugins.
You can do just as you said, put all your common classes in one plugin and reference them from another. This is made a bit safer by declaring plugin dependency in the the client plugin's version.php.
See plugin dependencies on this page https://docs.moodle.org/dev/version.php
This is how the classic Poodll plugins work. They all rely on the functionality in the Poodll filter. Well there are pros and cons to this approach. There is something to be said for the simplicity of keeping it all in one plugin, even if it makes the developers job harder.
Put all those shared classes into a standalone plugin. Plugin type "tool" or "local" are good candidates for this. Say it will be something like "tool_foobarlib".
All other plugins that need these classes, can then declare a dependency on tool_foobarlib in their version.php. See the relevant section at https://docs.moodle.org/dev/version.php for details.