Squashed 'core/' changes from facd0bc..8d7beb3

8d7beb3 Fix CLI tests
d554322 Re-add changes from original preparegui

git-subtree-dir: core
git-subtree-split: 8d7beb32a0068e92c49889deff43247a72b883d9
Merge commit '4d11b643f2abf3e38a6a6ba71e0d40366473eae7'
refactor plugin properties
move plugin gradle script to the end so that it works
correct use of environment util
refactor externalevents