blob: 576db7af785fbd26c8833ad274fd675437aec03b [file] [log] [blame]
tom1cd74ae2014-10-01 14:58:32 -07001#!/bin/bash
Pavlin Radoslavov91413792014-10-15 11:00:32 -07002# ----------------------------------------------------------------------------
tom1cd74ae2014-10-01 14:58:32 -07003# Selectively builds only those projects that contained modified Java files.
Pavlin Radoslavov91413792014-10-15 11:00:32 -07004# ----------------------------------------------------------------------------
tom1cd74ae2014-10-01 14:58:32 -07005
Thomas Vachuska87994d02015-04-23 11:55:24 -07006projects=$(find $ONOS_ROOT -type f -path '*/src/*' \
tom1cd74ae2014-10-01 14:58:32 -07007 -exec $ONOS_ROOT/tools/dev/bin/onos-build-selective-hook {} \; | \
Thomas Vachuska87994d02015-04-23 11:55:24 -07008 grep -v -f $ONOS_ROOT/tools/dev/bin/onos-build-selective.exclude | \
9 sort -u | sed "s:$ONOS_ROOT::g" | tr '\n' ',' | \
10 sed 's:/,:,:g;s:,/:,:g;s:^/::g;s:,$::g')
tom1cd74ae2014-10-01 14:58:32 -070011
Thomas Vachuska87994d02015-04-23 11:55:24 -070012if [ -n "$projects" ]; then
13 # Ascertain artifact IDs of the projects to be rebuilt
14 modulesERE=""
15 for pd in ${projects//,/ }; do
16 artifactId=$(grep -E "^ <artifactId>.*</artifactId>$" ${pd}/pom.xml | \
17 sed 's/.[^>]*>//;s/<.*//')
18 modulesERE="$modulesERE|$artifactId"
19 done
20 modulesERE=${modulesERE#|*}
21
22 # Search through staged app.xml files for any apps that require one or
23 # more of the modified artifacts.
24 appProjects=$(find $ONOS_ROOT -type f -path '*/target/oar/app.xml' | \
25 xargs grep '<artifact>' | grep -E "/($modulesERE)/" | \
26 cut -d: -f1 | sed 's:/target/oar/.*::g' | \
27 sort -u | sed "s:$ONOS_ROOT::g" | tr '\n' ',' | \
28 sed 's:/,:,:g;s:,/:,:g;s:^/::g;s:,$::g')
29
30 # If we found any, append those app projects to the list of projects to
31 # be built.
32 [ -n "$appProjects" ] && projects=$projects,$appProjects
33
34 echo Building projects $projects
35 cd $ONOS_ROOT && mvn --projects $projects ${@:-clean install}
36
37 [ -n "$appProjects" ] && echo "App staging required for projects $appProjects"
38fi