-
Notifications
You must be signed in to change notification settings - Fork 20
/
reloc-ver.py
59 lines (50 loc) · 2.15 KB
/
reloc-ver.py
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/python
import sys
# Add version to package, like CB's maven-shade-plugin relocation
if len(sys.argv) < 2:
print "usage: %s inVersion outVersion" % (sys.argv[0],)
raise SystemExit
inVersion = sys.argv[1] # "v1_4_5"
outVersion = sys.argv[2] # "v1_4_6"
def addVersion(path, version):
if version == "nover": return path
# <relocation>
# <pattern>net.minecraft.server</pattern>
# <shadedPattern>net.minecraft.server.v${minecraft_version}</shadedPattern>
# </relocation>
#
path = path.replace("net/minecraft/server/", "net/minecraft/server/" + version + "/")
# <relocation>
# <pattern>org.bouncycastle</pattern>
# <shadedPattern>net.minecraft.v${minecraft_version}.org.bouncycastle</shadedPattern>
# </relocation>
path = path.replace("org/bouncycastle/", "net/minecraft/" + version + "/org/bouncycastle/")
return path
noverMode = inVersion == "nover" # for making unversioned 1.4.5 -> versioned (with v1_4_5 package) - ignores output
for line in sys.stdin.readlines():
line = line.strip()
tokens = line.split(" ")
kind = tokens[0]
args = tokens[1:]
if kind == "PK:": # package
print line
elif kind == "CL:": # class
inName, outName = args
if noverMode:
print kind, inName, addVersion(outName, outVersion)
else:
print kind, addVersion(inName, inVersion), addVersion(outName, outVersion)
elif kind == "FD:": # field
inName, outName = args
if noverMode:
print kind, inName, addVersion(outName, outVersion)
else:
print kind, addVersion(inName, inVersion), addVersion(outName, outVersion)
elif kind == "MD:": # method
inName, inSig, outName, outSig = args
if noverMode:
print kind, inName, inSig, addVersion(outName, outVersion), addVersion(outSig, outVersion)
else:
print kind, addVersion(inName, inVersion), inSig, addVersion(outName, outVersion), addVersion(outSig, outVersion)
else:
print line