SaneEconomy icon indicating copy to clipboard operation
SaneEconomy copied to clipboard

Bootstrap & inject dependencies at runtime

Open egg82 opened this issue 6 years ago • 12 comments

Introducing dep injection! Enjoy small jar file sizes with all the benefits of an uber-jar! Updated some plugins and moved pom.xml stuff around a bit Now including Paper API (will be useful later) There's some messy parts for now, but not really any more messy than the original codebase. Will be cleaned up in a future PR

egg82 avatar Nov 26 '18 19:11 egg82

What about using some small maven repo client libraries such as https://github.com/mikroskeem/PicoMaven ?

sgdc3 avatar Nov 28 '18 11:11 sgdc3

That'll work for downloading, but Luck's jar-relocator actually relocates the dep after it's downloaded, which allows to inject into a custom namespace instead of injecting into the main namespace (which we want to avoid as much as possible)

You could add in a new lib for just downloading the jar, but I don't see a reason to. Would just add bloat, really.

egg82 avatar Nov 29 '18 04:11 egg82

What's wrong with the current solution? It's 2018, people can handle a couple MB in a JAR IMO :stuck_out_tongue:

AppleDash avatar Nov 29 '18 05:11 AppleDash

That's a significantly longer download time for users with slow internet on their computer, wasteful when downloading updates to the plugin but not its dependencies, generally less efficient

hafarooki avatar Nov 29 '18 05:11 hafarooki

but at the same time it's probably the more correct way to do it

hafarooki avatar Nov 29 '18 05:11 hafarooki

There's nothing in particular that's "wrong" with the current setup, but that doesn't man it can't be improved ;)

The idea is to provide a slimmed-down jar and download the deps on-the-fly IF they are actually needed. It also helps uploading because some places (cough Spigot) limit upload file sizes.

egg82 avatar Nov 29 '18 05:11 egg82

It also makes the plugin seem much lighter weight superficially

hafarooki avatar Nov 29 '18 05:11 hafarooki

This PR is the start of a series of PRs designed to ultimately improve the plugin. A lot of future PRs will build off of this one. If this gets merged, I can start on the rest.

egg82 avatar Nov 29 '18 06:11 egg82

Especially good for people with awful internet using Shared hosting - the download happens on the host's side so there's no need to upload 4mb at 100kbps, instead they upload a couple hundred kilobytes and the host downloads the rest

codingJWilliams avatar Nov 29 '18 16:11 codingJWilliams

DEFINITELY this ^^ I remember the pain of uploading plugins back when I used shared hosts.

hafarooki avatar Nov 29 '18 17:11 hafarooki

I need to think about this a little bit more, because while I do like the idea, I am not sure I 100% like the implementation. At the same time, however, I'm not sure I can think of a better way to do it. Agree that it's messy in places, but I went to at least a little effort to make my code clean!

I really appreciate the effort, and once I get past my own stubbornness and approve this, I look forward to your future improvements :smile:

AppleDash avatar Nov 29 '18 18:11 AppleDash

Of course, yeah. Even my own implementation could use a little work to make it more concise, but I didn't want to over-engineer anything just yet.

And yeah, there's a bit of mess to clean up which I would have done beforehand, but it requires a separate PR. I didn't want to shove everything into one giant PR.

egg82 avatar Nov 29 '18 20:11 egg82