blob: 5776c63d5a0f878fdb0f6c48ef6e42031257ab22 [file] [log] [blame]
Thomas Vachuska615361e2015-05-01 11:00:34 -07001#!/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
9type=${1:-bundle}
10
Thomas Vachuska4bfccd542015-05-30 00:35:25 -070011[ $type = app ] && archetype=bundle || archetype=$type
12
Thomas Vachuska615361e2015-05-01 11:00:34 -070013if [ "$1" = "-?" -o "$1" = "-h" -o "$1" = "--help" ]; then
Thomas Vachuska76679752015-09-29 13:14:53 -070014 echo "usage: $(basename $0) {app|bundle|ui|uitab|uitopo|cli|api} groupId artifactId version package mvn-options"
Thomas Vachuska615361e2015-05-01 11:00:34 -070015 echo " All arguments are optional"
16 exit 1
17fi
18
19otherOptions=""
20[ -n "$1" ] && shift
21[ -n "$1" ] && otherOptions="$otherOptions -DgroupId=$1" && shift
Thomas Vachuska4bfccd542015-05-30 00:35:25 -070022[ -n "$1" ] && otherOptions="$otherOptions -DartifactId=$1" && dir=$1 && shift
Thomas Vachuska615361e2015-05-01 11:00:34 -070023[ -n "$1" ] && otherOptions="$otherOptions -Dversion=$1" && shift
24[ -n "$1" ] && otherOptions="$otherOptions -Dpackage=$1" && shift
25
Thomas Vachuska830b8a12016-08-05 09:50:15 -070026mvn archetype:generate -DarchetypeCatalog=local,remote \
27 -DarchetypeGroupId=org.onosproject \
Thomas Vachuska4bfccd542015-05-30 00:35:25 -070028 -DarchetypeArtifactId=onos-$archetype-archetype \
29 -DarchetypeVersion=$ONOS_POM_VERSION $otherOptions "$@"
30
31# Patch the pom.xml file to make this an app.
Brian O'Connor7a9aeab2015-06-22 13:36:26 -040032if [ $type = app ]; then
33 # We need to add a few lines to the pom.xml to make this an app
34 if [ -n "$dir" ] && [ -d $dir ]; then
35 egrep -v " (<!--|-->)" $dir/pom.xml > $dir/pom.app.xml
36 mv $dir/pom.app.xml $dir/pom.xml
37 else
38 echo
39 echo "IMPORTANT:"
40 echo "To build the application, you need to uncomment the 'onos.app.name' and 'onos.app.origin' properties in the pom.xml"
41 echo
42 fi
43fi