0%

手动编译Spigot

其实官网的教程很简单,只有一条命令:

1
java -jar BuildTools.jar

确实,用这一条命令就能完成,不过踩了一些坑。做一下记录。
前往https://git-scm.com/下载Git,http://www.oracle.com/technetwork/java/javase/downloads/index-jsp-138363.html#javasejdk下载jdk。
在国内首先要解决的是网络问题,否则数百MB的源码得很长时间才能下载好,然后,内存至少为2GB,1GB 是不够的,想来前几天编译总是失败的原因就是这个。

内存不够,会出现下面这个错误:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at org.objectweb.asm.ClassReader.readLabel(ClassReader.java:2403)
at org.objectweb.asm.ClassReader.readCode(ClassReader.java:1324)
at org.objectweb.asm.ClassReader.readMethod(ClassReader.java:1165)
at org.objectweb.asm.ClassReader.accept(ClassReader.java:727)
at org.objectweb.asm.ClassReader.accept(ClassReader.java:525)
at net.md_5.ss.repo.JarRepo.getClass0(JarRepo.java:38)
at net.md_5.ss.repo.ClassRepo.getClass(ClassRepo.java:22)
at net.md_5.ss.repo.AggregateRepo.getClass0(AggregateRepo.java:30)
at net.md_5.ss.repo.ClassRepo.getClass(ClassRepo.java:22)
at net.md_5.ss.remapper.EnhancedRemapper.findMethodDeclarer(EnhancedRemapper.java:67)
at net.md_5.ss.remapper.EnhancedRemapper.mapMethodName(EnhancedRemapper.java:33)
at org.objectweb.asm.commons.MethodRemapper.doVisitMethodInsn(MethodRemapper.java:155)
at org.objectweb.asm.commons.MethodRemapper.visitMethodInsn(MethodRemapper.java:142)
at org.objectweb.asm.ClassReader.readCode(ClassReader.java:1647)
at org.objectweb.asm.ClassReader.readMethod(ClassReader.java:1165)
at org.objectweb.asm.ClassReader.accept(ClassReader.java:727)
at org.objectweb.asm.ClassReader.accept(ClassReader.java:525)
at net.md_5.ss.model.ClassInfo.remap(ClassInfo.java:120)
at net.md_5.ss.SpecialSource.map(SpecialSource.java:96)
at net.md_5.ss.SpecialSource.main(SpecialSource.java:44)
Exception in thread "main" java.lang.RuntimeException: Error running command, return status !=0: [java, -jar, BuildData/bin/SpecialSource-2.jar, map, -i, work/minecraft_server.1.12.2.jar, -m, BuildData/mappings/bukkit-1.12.2-cl.csrg, -o, work/mapped.cf6b1333.jar-cl]
at org.spigotmc.builder.Builder.runProcess(Builder.java:555)
at org.spigotmc.builder.Builder.main(Builder.java:313)
at org.spigotmc.builder.Bootstrap.main(Bootstrap.java:23)

很奇怪的一点是,因为我首先考虑了网络问题,所以我首先在VPS上执行编译,以便所有的源码全部下载好,然后打包下载到本地,再在本地编译,出现的错误同样是上面这个错误。
最后无奈,动用非常手段,让网络正常一点,清空工程目录,单独执行编译命令才成功。
来张合影

编译成功后会在BuildTools同级目录里面出现craftbukkit-1.12.2.jarspigot-1.12.2.jar,好了,拿去愉快的玩耍吧。