Thomas Vachuska | 615361e | 2015-05-01 11:00:34 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # ----------------------------------------------------------------------------- |
| 3 | # Tool to create an application from scratch using ONOS Maven archetypes. |
| 4 | # ----------------------------------------------------------------------------- |
| 5 | |
| 6 | [ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1 |
| 7 | . $ONOS_ROOT/tools/build/envDefaults |
| 8 | |
| 9 | type=${1:-bundle} |
| 10 | |
Thomas Vachuska | 4bfccd54 | 2015-05-30 00:35:25 -0700 | [diff] [blame] | 11 | [ $type = app ] && archetype=bundle || archetype=$type |
| 12 | |
Thomas Vachuska | 615361e | 2015-05-01 11:00:34 -0700 | [diff] [blame] | 13 | if [ "$1" = "-?" -o "$1" = "-h" -o "$1" = "--help" ]; then |
Thomas Vachuska | 7667975 | 2015-09-29 13:14:53 -0700 | [diff] [blame] | 14 | echo "usage: $(basename $0) {app|bundle|ui|uitab|uitopo|cli|api} groupId artifactId version package mvn-options" |
Thomas Vachuska | 615361e | 2015-05-01 11:00:34 -0700 | [diff] [blame] | 15 | echo " All arguments are optional" |
| 16 | exit 1 |
| 17 | fi |
| 18 | |
| 19 | otherOptions="" |
| 20 | [ -n "$1" ] && shift |
| 21 | [ -n "$1" ] && otherOptions="$otherOptions -DgroupId=$1" && shift |
Thomas Vachuska | 4bfccd54 | 2015-05-30 00:35:25 -0700 | [diff] [blame] | 22 | [ -n "$1" ] && otherOptions="$otherOptions -DartifactId=$1" && dir=$1 && shift |
Thomas Vachuska | 615361e | 2015-05-01 11:00:34 -0700 | [diff] [blame] | 23 | [ -n "$1" ] && otherOptions="$otherOptions -Dversion=$1" && shift |
| 24 | [ -n "$1" ] && otherOptions="$otherOptions -Dpackage=$1" && shift |
| 25 | |
Thomas Vachuska | 525651f | 2016-10-04 11:50:29 -0700 | [diff] [blame^] | 26 | set -e |
| 27 | |
Thomas Vachuska | 830b8a1 | 2016-08-05 09:50:15 -0700 | [diff] [blame] | 28 | mvn archetype:generate -DarchetypeCatalog=local,remote \ |
| 29 | -DarchetypeGroupId=org.onosproject \ |
Thomas Vachuska | 4bfccd54 | 2015-05-30 00:35:25 -0700 | [diff] [blame] | 30 | -DarchetypeArtifactId=onos-$archetype-archetype \ |
| 31 | -DarchetypeVersion=$ONOS_POM_VERSION $otherOptions "$@" |
| 32 | |
| 33 | # Patch the pom.xml file to make this an app. |
Brian O'Connor | 7a9aeab | 2015-06-22 13:36:26 -0400 | [diff] [blame] | 34 | if [ $type = app ]; then |
| 35 | # We need to add a few lines to the pom.xml to make this an app |
| 36 | if [ -n "$dir" ] && [ -d $dir ]; then |
| 37 | egrep -v " (<!--|-->)" $dir/pom.xml > $dir/pom.app.xml |
| 38 | mv $dir/pom.app.xml $dir/pom.xml |
| 39 | else |
| 40 | echo |
| 41 | echo "IMPORTANT:" |
| 42 | echo "To build the application, you need to uncomment the 'onos.app.name' and 'onos.app.origin' properties in the pom.xml" |
| 43 | echo |
| 44 | fi |
| 45 | fi |