Skip to content

Commit 86e57f5

Browse files
committed
Fix unnecessary shaded API, shrinks jar from 6 to 2.6 MB. Closes GH-28
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.
1 parent ab3809c commit 86e57f5

File tree

2 files changed

+2
-48
lines changed

2 files changed

+2
-48
lines changed

pom.xml

+1-46
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<artifactId>spigot-api</artifactId>
3131
<version>1.11-R0.1-SNAPSHOT</version>
3232
<type>jar</type>
33-
<scope>compile</scope>
33+
<scope>provided</scope>
3434
</dependency>
3535
<dependency>
3636
<groupId>io.netty</groupId>
@@ -87,52 +87,7 @@
8787
io.github.satoshinm.WebSandboxMC.dep.io.netty
8888
</shadedPattern>
8989
</relocation>
90-
<relocation>
91-
<pattern>com.avaje</pattern>
92-
<shadedPattern>
93-
io.github.satoshinm.WebSandboxMC.dep.com.avaje
94-
</shadedPattern>
95-
</relocation>
96-
<relocation>
97-
<pattern>com.google</pattern>
98-
<shadedPattern>
99-
io.github.satoshinm.WebSandboxMC.dep.com.google
100-
</shadedPattern>
101-
</relocation>
102-
<relocation>
103-
<pattern>org.apache</pattern>
104-
<shadedPattern>
105-
io.github.satoshinm.WebSandboxMC.dep.org.apache
106-
</shadedPattern>
107-
</relocation>
108-
<relocation>
109-
<pattern>org.hamcrest</pattern>
110-
<shadedPattern>
111-
io.github.satoshinm.WebSandboxMC.dep.org.hamcrest
112-
</shadedPattern>
113-
</relocation>
114-
<relocation>
115-
<pattern>org.json</pattern>
116-
<shadedPattern>
117-
io.github.satoshinm.WebSandboxMC.dep.org.json
118-
</shadedPattern>
119-
</relocation>
120-
<relocation>
121-
<pattern>org.yaml</pattern>
122-
<shadedPattern>
123-
io.github.satoshinm.WebSandboxMC.dep.org.yaml
124-
</shadedPattern>
125-
</relocation>
12690
</relocations>
127-
<artifactSet>
128-
<excludes>
129-
<excludes>org.spigotmc:*</excludes>
130-
<excludes>net.md_5:*</excludes>
131-
<excludes>javax.persistence:*</excludes>
132-
<excludes>com.avaje:*</excludes>
133-
<excludes>org.hamcrest:*</excludes>
134-
</excludes>
135-
</artifactSet>
13691
</configuration>
13792
</execution>
13893
</executions>

src/main/java/io/github/satoshinm/WebSandboxMC/ws/WebSocketIndexPageHandler.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
*/
1616
package io.github.satoshinm.WebSandboxMC.ws;
1717

18-
import com.google.common.base.Charsets;
1918
import io.netty.buffer.ByteBuf;
2019
import io.netty.buffer.Unpooled;
2120
import io.netty.channel.ChannelFuture;
@@ -81,7 +80,7 @@ private void sendTextResource(String prepend, String name, String mimeType, Full
8180
buffer.append(line);
8281
buffer.append('\n');
8382
}
84-
ByteBuf content = Unpooled.copiedBuffer(buffer, Charsets.UTF_8);
83+
ByteBuf content = Unpooled.copiedBuffer(buffer, java.nio.charset.Charset.forName("UTF-8"));
8584

8685
FullHttpResponse res = new DefaultFullHttpResponse(HTTP_1_1, OK, content);
8786

0 commit comments

Comments
 (0)