Add integration scripts from OPEN-O
[integration.git] / autorelease / scripts / generate-assembly.py
1 #!/usr/bin/env python
2 #
3 # Copyright 2016-2017 Huawei Technologies Co., Ltd.
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #     http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17 import sys, csv, subprocess
18
19 version = "1.1.0-SNAPSHOT"
20
21 root = subprocess.check_output(["git", "rev-parse", "--show-toplevel"]).rstrip()
22
23 with open( "{}/autorelease/binaries.csv".format(root), "r" ) as f:
24     reader = csv.DictReader(f)
25
26     print """
27 <!--
28    Copyright (c) 2016-2017 Huawei Technologies Co., Ltd.
29
30    Licensed under the Apache License, Version 2.0 (the "License");
31    you may not use this file except in compliance with the License.
32    You may obtain a copy of the License at
33
34        http://www.apache.org/licenses/LICENSE-2.0
35
36    Unless required by applicable law or agreed to in writing, software
37    distributed under the License is distributed on an "AS IS" BASIS,
38    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
39    See the License for the specific language governing permissions and
40    limitations under the License.
41 -->
42 <assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" 
43           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44           xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
45   <id>linux64</id>
46   <formats>
47     <format>tar.gz</format>
48   </formats>
49   <fileSets>
50     <fileSet>
51       <directory>../../distribution</directory>
52       <outputDirectory>/</outputDirectory>
53       <includes>
54         <include>**</include>
55       </includes>
56     </fileSet>
57   </fileSets>
58   <dependencySets>
59 """
60     
61     for row in reader:
62         if row["classifier"]:
63             include = "{}:{}:{}:{}".format(row["groupId"], row["artifactId"], row["extension"], row["classifier"])
64         else:
65             include = "{}:{}:{}".format(row["groupId"], row["artifactId"], row["extension"])
66
67         txt = """
68     <dependencySet>
69       <outputDirectory>{}</outputDirectory>
70       <useProjectArtifact>false</useProjectArtifact>
71       <includes>
72         <include>{}</include>
73       </includes>
74       <outputFileNameMapping>{}-${{artifact.version}}${{dashClassifier?}}.${{artifact.extension}}</outputFileNameMapping>
75     </dependencySet>"""
76         # print txt.format(row["filename"], include, row["filename"])
77         
78
79     print """
80   </dependencySets>
81 </assembly>
82 """