# HG changeset patch # User Roland Schatz # Date 1364222371 -3600 # Node ID b27261747964b0794dba24516801be4416278239 # Parent d815f0ac9ed3fde2086748f8573bc4ad0b3d0d9e mx: merge provider configuration files in distribution jars diff -r d815f0ac9ed3 -r b27261747964 mxtool/mx.py --- a/mxtool/mx.py Fri Mar 22 19:50:51 2013 +0100 +++ b/mxtool/mx.py Mon Mar 25 15:39:31 2013 +0100 @@ -1658,16 +1658,28 @@ dname = name[1:] d = distribution(dname) fd, tmp = tempfile.mkstemp(suffix='', prefix=basename(d.path) + '.', dir=dirname(d.path)) + services = tempfile.mkdtemp(suffix='', prefix=basename(d.path) + '.', dir=dirname(d.path)) zf = zipfile.ZipFile(tmp, 'w') for p in sorted_deps(d.deps): outputDir = p.output_dir() for root, _, files in os.walk(outputDir): - for f in files: - relpath = root[len(outputDir) + 1:] - arcname = join(relpath, f).replace(os.sep, '/') - zf.write(join(root, f), arcname) + relpath = root[len(outputDir) + 1:] + if relpath == join('META-INF', 'services'): + for f in files: + with open(join(services, f), 'a') as outfile: + with open(join(root, f), 'r') as infile: + for line in infile: + outfile.write(line) + else: + for f in files: + arcname = join(relpath, f).replace(os.sep, '/') + zf.write(join(root, f), arcname) + for f in os.listdir(services): + arcname = join('META-INF', 'services', f).replace(os.sep, '/') + zf.write(join(services, f), arcname) zf.close() os.close(fd) + shutil.rmtree(services) # Atomic on Unix shutil.move(tmp, d.path) #print time.time(), 'move:', tmp, '->', d.path