Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct scope of Bukkit API dependency #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

satoshinm
Copy link

The org.bukkit:bukkit dependency was scoped to "compile", which will cause it to be included in the plugin jar with maven-shade-plugin, for example. This can be avoided with exclusions but a cleaner fix is to change the scope to "provided", as this is the intended purpose: dependencies provided at runtime.

From the Maven documentation:

provided
This is much like compile, but indicates you expect the JDK or a container to provide the dependency at runtime. For example, when building a web application for the Java Enterprise Edition, you would set the dependency on the Servlet API and related Java EE APIs to scope provided because the web container provides those classes. This scope is only available on the compilation and test classpath, and is not transitive.

This accurately describes the Bukkit API dependency.

The org.bukkit:bukkit dependency was scoped to "compile", which will cause it to be included in the plugin jar with [maven-shade-plugin](https://maven.apache.org/components/plugins/maven-shade-plugin/), for example. This can be avoided with exclusions but a cleaner fix is to change the scope to "provided", as this is the intended purpose: dependencies provided at runtime.

From the [Maven documentation](http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope):

> provided
> This is much like compile, but indicates you expect the JDK or a container to provide the dependency at runtime. For example, when building a web application for the Java Enterprise Edition, you would set the dependency on the Servlet API and related Java EE APIs to scope provided because the web container provides those classes. This scope is only available on the compilation and test classpath, and is not transitive.

This accurately describes the Bukkit API dependency.
satoshinm added a commit to satoshinm/WebSandboxMC that referenced this pull request Apr 17, 2017
The Bukkit API was specified with compile scope, causing it to be shaded
into the plugin jar by default. Requested change to Bukkit/SamplePlugin
here: Bukkit/SamplePlugin#16 - to scope
provided, this is intended for dependencies provided at runtime (i.e.,
Bukkit) so removes all the unnecessary deps in the jar, ebean etc.

Remainder of this commit is coping with this fix: cleaning up the
unneeded relocations and exclusions, and breaking the unintentional
dependency on Google Commons where Charset was used although it is not
needed and available in java.nio. Netty is still shaded for server
software version independence, but even with it included and the
NetCraft binary, end result is plugin shrinks from 6.0 to 2.6 MB, well
under the Spigot Resources limit of 4 MB.
@mbax
Copy link
Member

mbax commented Apr 17, 2017

  1. Shade isn't used here, so it's not really a problem. Mistake, sure, but not a problem.

  2. Bukkit died. August 2014. Nobody's home.

RIP ⚰️

@satoshinm
Copy link
Author

Thanks for the reply, I guess I'll leave this pull request open even if it won't be merged, to allow others searching for a "bukkit sample plugin" to find this fix and save them some trouble if they decide to base their plugin on it (as I have).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants