onos/buck-tools/onos_oar.py
Brian O'Connor e124f3dd7b Using $(maven_coords :target) marco
Note: This this macro is not yet available on buck master

Also, simplifying app/fwd buck file and improving onos_app
readability by using feature_coords instead of feature_name

Change-Id: I9aff07d66331a537f6711bf15fd760cf910f1afc
2016-04-08 18:43:36 -07:00

40 lines
1.2 KiB
Python
Executable File

#!/usr/bin/env python
#FIXME Add license
from zipfile import ZipFile
def generateOar(output, files=[]):
# Note this is not a compressed zip
with ZipFile(output, 'w') as zip:
for file, mvnCoords in files:
filename = file.split('/')[-1]
if mvnCoords == 'NONE':
dest = filename
else:
groupId, artifactId, version = mvnCoords.split(':')
groupId = groupId.replace('.', '/')
extension = filename.split('.')[-1]
if extension == 'jar':
filename = '%s-%s.jar' % ( artifactId, version )
elif 'features.xml' in filename:
filename = '%s-%s-features.xml' % ( artifactId, version )
dest = 'm2/%s/%s/%s/%s' % ( groupId, artifactId, version, filename )
zip.write(file, dest)
if __name__ == '__main__':
import sys
if len(sys.argv) < 2:
print 'USAGE'
sys.exit(1)
output = sys.argv[1]
args = sys.argv[2:]
if len(args) % 2 != 0:
print 'There must be an even number of args: file mvn_coords'
sys.exit(2)
files = zip(*[iter(args)]*2)
generateOar(output, files)