| 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] |
| parts = mvnCoords.split(':') |
| parts.insert(2, parts.pop()) # move version to the 3rd position |
| groupId, artifactId, version = parts[0:3] |
| groupId = groupId.replace('.', '/') |
| extension = filename.split('.')[-1] |
| 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 ) |
| if __name__ == '__main__': |
| print 'There must be an even number of args: file mvn_coords' |
| files = zip(*[iter(args)]*2) |
| generateOar(output, files) |