comparison mxtool/mx.py @ 17059:a5dc5513ce85

mx: add check for compliance level of a distribution
author Bernhard Urban <bernhard.urban@jku.at>
date Mon, 08 Sep 2014 09:46:07 +0200
parents 49b8c8932786
children 75a4acd33159
comparison
equal deleted inserted replaced
17058:97d0508b7cf1 17059:a5dc5513ce85
62 62
63 """ 63 """
64 A distribution is a jar or zip file containing the output from one or more Java projects. 64 A distribution is a jar or zip file containing the output from one or more Java projects.
65 """ 65 """
66 class Distribution: 66 class Distribution:
67 def __init__(self, suite, name, path, sourcesPath, deps, mainClass, excludedDependencies, distDependencies): 67 def __init__(self, suite, name, path, sourcesPath, deps, mainClass, excludedDependencies, distDependencies, javaCompliance):
68 self.suite = suite 68 self.suite = suite
69 self.name = name 69 self.name = name
70 self.path = path.replace('/', os.sep) 70 self.path = path.replace('/', os.sep)
71 self.path = _make_absolute(self.path, suite.dir) 71 self.path = _make_absolute(self.path, suite.dir)
72 self.sourcesPath = _make_absolute(sourcesPath.replace('/', os.sep), suite.dir) if sourcesPath else None 72 self.sourcesPath = _make_absolute(sourcesPath.replace('/', os.sep), suite.dir) if sourcesPath else None
73 self.deps = deps 73 self.deps = deps
74 self.update_listeners = set() 74 self.update_listeners = set()
75 self.mainClass = mainClass 75 self.mainClass = mainClass
76 self.excludedDependencies = excludedDependencies 76 self.excludedDependencies = excludedDependencies
77 self.distDependencies = distDependencies 77 self.distDependencies = distDependencies
78 self.javaCompliance = JavaCompliance(javaCompliance) if javaCompliance else None
78 79
79 def sorted_deps(self, includeLibs=False, transitive=False): 80 def sorted_deps(self, includeLibs=False, transitive=False):
80 deps = [] 81 deps = []
81 if transitive: 82 if transitive:
82 for depDist in [distribution(name) for name in self.distDependencies]: 83 for depDist in [distribution(name) for name in self.distDependencies]:
166 isCoveredByDependecy = True 167 isCoveredByDependecy = True
167 break 168 break
168 169
169 if isCoveredByDependecy: 170 if isCoveredByDependecy:
170 continue 171 continue
172
173 if self.javaCompliance:
174 if p.javaCompliance > self.javaCompliance:
175 abort("Compliance level doesn't match: Distribution {0} requires {1}, but {2} is {3}.".format(self.name, self.javaCompliance, p.name, p.javaCompliance))
171 176
172 # skip a Java project if its Java compliance level is "higher" than the configured JDK 177 # skip a Java project if its Java compliance level is "higher" than the configured JDK
173 jdk = java(p.javaCompliance) 178 jdk = java(p.javaCompliance)
174 assert jdk 179 assert jdk
175 180
928 sourcesPath = attrs.pop('sourcesPath', None) 933 sourcesPath = attrs.pop('sourcesPath', None)
929 deps = pop_list(attrs, 'dependencies') 934 deps = pop_list(attrs, 'dependencies')
930 mainClass = attrs.pop('mainClass', None) 935 mainClass = attrs.pop('mainClass', None)
931 exclDeps = pop_list(attrs, 'exclude') 936 exclDeps = pop_list(attrs, 'exclude')
932 distDeps = pop_list(attrs, 'distDependencies') 937 distDeps = pop_list(attrs, 'distDependencies')
933 d = Distribution(self, name, path, sourcesPath, deps, mainClass, exclDeps, distDeps) 938 javaCompliance = attrs.pop('javaCompliance', None)
939 d = Distribution(self, name, path, sourcesPath, deps, mainClass, exclDeps, distDeps, javaCompliance)
934 d.__dict__.update(attrs) 940 d.__dict__.update(attrs)
935 self.dists.append(d) 941 self.dists.append(d)
936 942
937 # Create a distribution for each project that defines annotation processors 943 # Create a distribution for each project that defines annotation processors
938 for p in self.projects: 944 for p in self.projects:
953 sourcesPath = None 959 sourcesPath = None
954 deps = [p.name] 960 deps = [p.name]
955 mainClass = None 961 mainClass = None
956 exclDeps = [] 962 exclDeps = []
957 distDeps = [] 963 distDeps = []
958 d = Distribution(self, dname, path, sourcesPath, deps, mainClass, exclDeps, distDeps) 964 javaCompliance = None
965 d = Distribution(self, dname, path, sourcesPath, deps, mainClass, exclDeps, distDeps, javaCompliance)
959 d.subDir = os.path.relpath(os.path.dirname(p.dir), self.dir) 966 d.subDir = os.path.relpath(os.path.dirname(p.dir), self.dir)
960 self.dists.append(d) 967 self.dists.append(d)
961 p.definedAnnotationProcessors = annotationProcessors 968 p.definedAnnotationProcessors = annotationProcessors
962 p.definedAnnotationProcessorsDist = d 969 p.definedAnnotationProcessorsDist = d
963 d.definingProject = p 970 d.definingProject = p