forked from graalvm/mx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mx_compat.py
228 lines (179 loc) · 6.44 KB
/
mx_compat.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
#
# ----------------------------------------------------------------------------------------------------
#
# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
# ----------------------------------------------------------------------------------------------------
import sys, inspect, re, types, bisect
from collections import OrderedDict
from os.path import join
import mx
class MxCompatibility500(object):
@staticmethod
def version():
return mx.VersionSpec("5.0.0")
def supportsLicenses(self):
return False
def licenseAttribute(self):
return 'licence'
def licensesAttribute(self):
return 'licences'
def defaultLicenseAttribute(self):
return 'defaultLicence'
def supportedMavenMetadata(self):
return []
def supportsRepositories(self):
return False
def newestInputIsTimeStampFile(self):
'''
Determines if the 'newestInput' parameter of BuildTask.needsBuild()
is a TimeStampFile or a simple time stamp (i.e. a float).
'''
return False
def getSuiteOutputRoot(self, suite):
return suite.dir
def mavenDeployJavadoc(self):
return False
def checkstyleVersion(self):
return '6.0'
def checkDependencyJavaCompliance(self):
"""
Determines if a project must have a higher or equal Java compliance level
than a project it depends upon.
"""
return False
def improvedImportMatching(self):
return False
def verifySincePresent(self):
return []
def moduleDepsEqualDistDeps(self):
"""
Determines if the constituents of a module derived from a distribution are
exactly the same as the constituents of the distribution.
"""
return False
def __str__(self):
return str("MxCompatibility({})".format(self.version()))
def __repr__(self):
return str(self)
class MxCompatibility520(MxCompatibility500):
@staticmethod
def version():
return mx.VersionSpec("5.2.0")
def supportsLicenses(self):
return True
def supportedMavenMetadata(self):
return ['library-coordinates', 'suite-url', 'suite-developer', 'dist-description']
class MxCompatibility521(MxCompatibility520):
@staticmethod
def version():
return mx.VersionSpec("5.2.1")
def supportsRepositories(self):
return True
class MxCompatibility522(MxCompatibility521):
@staticmethod
def version():
return mx.VersionSpec("5.2.2")
def licenseAttribute(self):
return 'license'
def licensesAttribute(self):
return 'licenses'
def defaultLicenseAttribute(self):
return 'defaultLicense'
class MxCompatibility533(MxCompatibility522):
@staticmethod
def version():
return mx.VersionSpec("5.3.3")
def newestInputIsTimeStampFile(self):
return True
class MxCompatibility555(MxCompatibility533):
@staticmethod
def version():
return mx.VersionSpec("5.5.5")
def getSuiteOutputRoot(self, suite):
return join(suite.dir, 'mxbuild')
class MxCompatibility566(MxCompatibility555):
@staticmethod
def version():
return mx.VersionSpec("5.6.6")
def mavenDeployJavadoc(self):
return True
class MxCompatibility5616(MxCompatibility566):#pylint: disable=too-many-ancestors
@staticmethod
def version():
return mx.VersionSpec("5.6.16")
def checkstyleVersion(self):
return '6.15'
class MxCompatibility59(MxCompatibility5616):#pylint: disable=too-many-ancestors
@staticmethod
def version():
return mx.VersionSpec("5.9.0")
def verifySincePresent(self):
return ['-verifysincepresent']
class MxCompatibility5200(MxCompatibility59):#pylint: disable=too-many-ancestors
@staticmethod
def version():
return mx.VersionSpec("5.20.0")
def checkDependencyJavaCompliance(self):
return True
def improvedImportMatching(self):
return True
class MxCompatibility5344(MxCompatibility5200):#pylint: disable=too-many-ancestors
@staticmethod
def version():
return mx.VersionSpec("5.34.4")
def moduleDepsEqualDistDeps(self):
return True
def minVersion():
_ensureCompatLoaded()
return _versionsMap.keys()[0]
def getMxCompatibility(version):
if version < minVersion(): # ensures compat loaded
return None
keys = _versionsMap.keys()
return _versionsMap[keys[bisect.bisect_right(keys, version)-1]]
_versionsMap = OrderedDict()
def _ensureCompatLoaded():
if not _versionsMap:
def flattenClassTree(tree):
root = tree[0][0]
assert isinstance(root, types.TypeType), root
yield root
if len(tree) > 1:
assert len(tree) == 2
rest = tree[1]
assert isinstance(rest, types.ListType), rest
for c in flattenClassTree(rest):
yield c
classes = []
regex = re.compile(r'^MxCompatibility[0-9a-z]*$')
for name, clazz in inspect.getmembers(sys.modules[__name__], inspect.isclass):
m = regex.match(name)
if m:
classes.append(clazz)
previousVersion = None
for clazz in flattenClassTree(inspect.getclasstree(classes)):
if clazz == object:
continue
assert previousVersion is None or previousVersion < clazz.version()
previousVersion = clazz.version()
_versionsMap[previousVersion] = clazz()