I cannot seem to include my composer-installable third-party library in my plugin so that GPM doesn’t cough and spit it out again. I am not sure about what should come first – I shall outline my understanding of the required steps here, let you point out what I have got wrong, and when I have managed to make my plugin installable with the library included, I shall update the docs. (Unfortunately, looking at other plugins with third-party code doesn’t really help me here, because I can’t see how they managed to put it there.)
Exact steps to incorporate a library with composer into a custom plugin and track it all with git:
- Create plugin with all the basic files, and add it to git project.
- Create directory
vendor/in plugin directory.
- Copy the library’s
composer.jsonfile into plugin directory.
composer.phar installin plugin directory, this will create a whole bunch of files including
- Add the whole shebang as a subtree into the plugin’s git project (copying modified steps from this github article:
git remote add -f mynameforthelibrary email@example.com:libcreator/third-party.git
git merge -s ours --no-commit --allow-unrelated-histories mynameforthelibrary/master
git read-tree --prefix=vendor/whatnamegoeshere??/
git commit -m "Subtree merged in directory [???]"
Would this work, in this sequence?? Did I get the naming right? In the example they use the same name for everything, but in theory I could name the subtree whatever I want – is that right?
In my project, I confused subtrees with submodules and also copied the whole library into a subdirectory but then installed it with composer as well, and my third-party code incorporation is a mess now. Before I fix this, I would love to have a clear understanding of how to do it properly. Please and thank you so much!