Bump to odlparent 3.1.6
[alto.git] / utils / migrate_karaf4.sh
1 #!/bin/bash
2
3 FEATURES=$1
4 DIR=$2
5
6 XMLSTAR_VERSION=$(xml --version)
7
8 if [ -z "$XMLSTAR_VERSION" ] ; then
9     echo "xmlstarlet is REQUIRED to run this script."
10     exit -1
11 fi
12
13 feature_headless=$(sed -E 's/(xmlns|xsi)(:[a-zA-Z]+)?=".*"//g' $FEATURES)
14 modules=$(echo $feature_headless | xml sel -t -m 'features/feature' -v '@name' -n)
15 for module in $modules; do
16     # Generate feature pom for each module
17     echo ">>> Generate module $module"
18     module_content=$(echo $feature_headless | xml sel -t -c 'features/feature[@name="'$module'"]')
19     description=$(echo $module_content | xml sel -t -v 'feature/@description')
20     mkdir -p $DIR/$module
21     touch $DIR/$module/pom.xml
22     echo '<?xml version="1.0" encoding="UTF-8"?>
23 <!--
24 Copyright (c) 2015 Yale University and others. All rights reserved.
25 This program and the accompanying materials are made available under the
26 terms of the Eclipse Public License v1.0 which accompanies this distribution,
27 and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
28 -->
29 <project xmlns="http://maven.apache.org/POM/4.0.0"
30          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
31          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
32   <modelVersion>4.0.0</modelVersion>
33
34   <parent>
35     <groupId>org.opendaylight.odlparent</groupId>
36     <artifactId>single-feature-parent</artifactId>
37     <version>1.8.0-SNAPSHOT</version>
38     <relativePath/>
39   </parent>
40
41   <groupId>org.opendaylight.alto</groupId>
42   <artifactId>'$module'</artifactId>
43   <version>0.4.0-SNAPSHOT</version>
44   <packaging>feature</packaging>
45
46   <name>'$description'</name>
47 ' > $DIR/$module/pom.xml
48     echo $module_content | sed '
49     sX<feature version=['\''"]\([^'\''"]*\)['\''"]>\([^<]*\)</feature>X<dependency><groupId>${project.groupId}</groupId><artifactId>\2</artifactId><version>\1</version><type>xml</type><classifier>features</classifier></dependency>Xg
50 sX<bundle>mvn:\([^/]*\)/\([^/]*\)/Template:VERSION</bundle>X<dependency><groupId>\1</groupId><artifactId>\2</artifactId></dependency>Xg
51 sX<bundle>wrap:mvn:\([^/]*\)/\([^/]*\)/Template:VERSION</bundle>X<dependency><groupId>\1</groupId><artifactId>\2</artifactId></dependency>Xg
52 sX<bundle>mvn:\([^/]*\)/\([^/]*\)/\([^<]*\)</bundle>X<dependency><groupId>\1</groupId><artifactId>\2</artifactId><version>\3</version></dependency>Xg
53 sX<bundle>wrap:mvn:\([^/]*\)/\([^/]*\)/\([^<]*\)</bundle>X<dependency><groupId>\1</groupId><artifactId>\2</artifactId><version>\3</version></dependency>Xg
54     ' | xml ed -O -d 'feature/@*' -r 'feature' -v 'dependencies' >> $DIR/$module/pom.xml
55     echo '</project>' >> $DIR/$module/pom.xml
56 done