comparison mxtool/mx.py @ 21043:5ea65fe64368

Check distributions overlap in gate
author Gilles Duboscq <gilles.m.duboscq@oracle.com>
date Mon, 20 Apr 2015 18:27:46 +0200
parents b99da6d86cfe
children 53b2d64f8ad1
comparison
equal deleted inserted replaced
21042:38b39b75500c 21043:5ea65fe64368
99 99
100 """ 100 """
101 A distribution is a jar or zip file containing the output from one or more Java projects. 101 A distribution is a jar or zip file containing the output from one or more Java projects.
102 """ 102 """
103 class Distribution: 103 class Distribution:
104 def __init__(self, suite, name, path, sourcesPath, deps, mainClass, excludedDependencies, distDependencies, javaCompliance): 104 def __init__(self, suite, name, path, sourcesPath, deps, mainClass, excludedDependencies, distDependencies, javaCompliance, isProcessorDistribution=False):
105 self.suite = suite 105 self.suite = suite
106 self.name = name 106 self.name = name
107 self.path = path.replace('/', os.sep) 107 self.path = path.replace('/', os.sep)
108 self.path = _make_absolute(self.path, suite.dir) 108 self.path = _make_absolute(self.path, suite.dir)
109 self.sourcesPath = _make_absolute(sourcesPath.replace('/', os.sep), suite.dir) if sourcesPath else None 109 self.sourcesPath = _make_absolute(sourcesPath.replace('/', os.sep), suite.dir) if sourcesPath else None
111 self.update_listeners = set() 111 self.update_listeners = set()
112 self.mainClass = mainClass 112 self.mainClass = mainClass
113 self.excludedDependencies = excludedDependencies 113 self.excludedDependencies = excludedDependencies
114 self.distDependencies = distDependencies 114 self.distDependencies = distDependencies
115 self.javaCompliance = JavaCompliance(javaCompliance) if javaCompliance else None 115 self.javaCompliance = JavaCompliance(javaCompliance) if javaCompliance else None
116 self.isProcessorDistribution = isProcessorDistribution
116 117
117 def sorted_deps(self, includeLibs=False, transitive=False): 118 def sorted_deps(self, includeLibs=False, transitive=False):
118 deps = [] 119 deps = []
119 if transitive: 120 if transitive:
120 for depDist in [distribution(name) for name in self.distDependencies]: 121 for depDist in [distribution(name) for name in self.distDependencies]:
1088 deps = [p.name] 1089 deps = [p.name]
1089 mainClass = None 1090 mainClass = None
1090 exclDeps = [] 1091 exclDeps = []
1091 distDeps = [] 1092 distDeps = []
1092 javaCompliance = None 1093 javaCompliance = None
1093 d = Distribution(self, dname, path, sourcesPath, deps, mainClass, exclDeps, distDeps, javaCompliance) 1094 d = Distribution(self, dname, path, sourcesPath, deps, mainClass, exclDeps, distDeps, javaCompliance, True)
1094 d.subDir = os.path.relpath(os.path.dirname(p.dir), self.dir) 1095 d.subDir = os.path.relpath(os.path.dirname(p.dir), self.dir)
1095 self.dists.append(d) 1096 self.dists.append(d)
1096 p.definedAnnotationProcessors = annotationProcessors 1097 p.definedAnnotationProcessors = annotationProcessors
1097 p.definedAnnotationProcessorsDist = d 1098 p.definedAnnotationProcessorsDist = d
1098 d.definingProject = p 1099 d.definingProject = p
2561 parser.add_argument('-f', action='store_true', dest='force', help='force build (disables timestamp checking)') 2562 parser.add_argument('-f', action='store_true', dest='force', help='force build (disables timestamp checking)')
2562 parser.add_argument('-c', action='store_true', dest='clean', help='removes existing build output') 2563 parser.add_argument('-c', action='store_true', dest='clean', help='removes existing build output')
2563 parser.add_argument('-p', action='store_true', dest='parallelize', help='parallelizes Java compilation if possible') 2564 parser.add_argument('-p', action='store_true', dest='parallelize', help='parallelizes Java compilation if possible')
2564 parser.add_argument('--source', dest='compliance', help='Java compliance level for projects without an explicit one') 2565 parser.add_argument('--source', dest='compliance', help='Java compliance level for projects without an explicit one')
2565 parser.add_argument('--Wapi', action='store_true', dest='warnAPI', help='show warnings about using internal APIs') 2566 parser.add_argument('--Wapi', action='store_true', dest='warnAPI', help='show warnings about using internal APIs')
2567 parser.add_argument('--check-distributions', action='store_true', dest='check_distributions', help='check built distributions for overlap')
2566 parser.add_argument('--projects', action='store', help='comma separated projects to build (omit to build all projects)') 2568 parser.add_argument('--projects', action='store', help='comma separated projects to build (omit to build all projects)')
2567 parser.add_argument('--only', action='store', help='comma separated projects to build, without checking their dependencies (omit to build all projects)') 2569 parser.add_argument('--only', action='store', help='comma separated projects to build, without checking their dependencies (omit to build all projects)')
2568 parser.add_argument('--no-java', action='store_false', dest='java', help='do not build Java projects') 2570 parser.add_argument('--no-java', action='store_false', dest='java', help='do not build Java projects')
2569 parser.add_argument('--no-native', action='store_false', dest='native', help='do not build native projects') 2571 parser.add_argument('--no-native', action='store_false', dest='native', help='do not build native projects')
2570 parser.add_argument('--jdt-warning-as-error', action='store_true', help='convert all Eclipse batch compiler warnings to errors') 2572 parser.add_argument('--jdt-warning-as-error', action='store_true', help='convert all Eclipse batch compiler warnings to errors')
2788 for t in failed: 2790 for t in failed:
2789 log('Compiling {0} failed'.format(t.proj.name)) 2791 log('Compiling {0} failed'.format(t.proj.name))
2790 abort('{0} Java compilation tasks failed'.format(len(failed))) 2792 abort('{0} Java compilation tasks failed'.format(len(failed)))
2791 2793
2792 if args.java: 2794 if args.java:
2795 files = []
2793 for dist in sorted_dists(): 2796 for dist in sorted_dists():
2794 if dist not in updatedAnnotationProcessorDists: 2797 if dist not in updatedAnnotationProcessorDists:
2795 archive(['@' + dist.name]) 2798 archive(['@' + dist.name])
2799 if args.check_distributions and not dist.isProcessorDistribution:
2800 with zipfile.ZipFile(dist.path, 'r') as zf:
2801 files.extend([member for member in zf.namelist() if not member.startswith('META-INF/services')])
2802 dups = set([x for x in files if files.count(x) > 1])
2803 if len(dups) > 0:
2804 abort('Distributions overlap! duplicates: ' + str(dups))
2796 2805
2797 if suppliedParser: 2806 if suppliedParser:
2798 return args 2807 return args
2799 return None 2808 return None
2800 2809