Thomas Vachuska
Committed by Gerrit Code Review

Enhanced onos-build-selective to react to any src file modifications and to also…

… result in a cascaded build of app modules which require the modified modules.

Change-Id: I1c41ca2d11c936bfeb7307ce0e01b20d0141daa6
1 -<?xml version="1.0" encoding="UTF-8"?>
2 -<!--
3 - ~ Copyright 2014 Open Networking Laboratory
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 -<project xmlns="http://maven.apache.org/POM/4.0.0"
18 - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
19 - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
20 - <modelVersion>4.0.0</modelVersion>
21 -
22 - <parent>
23 - <groupId>org.onosproject</groupId>
24 - <artifactId>onos-apps</artifactId>
25 - <version>1.2.0-SNAPSHOT</version>
26 - <relativePath>../pom.xml</relativePath>
27 - </parent>
28 -
29 - <artifactId>onos-app-grouphandler</artifactId>
30 - <packaging>bundle</packaging>
31 -
32 - <description>ONOS sample application using group service</description>
33 -
34 - <dependencies>
35 - <dependency>
36 - <groupId>org.onosproject</groupId>
37 - <artifactId>onos-api</artifactId>
38 - <version>${project.version}</version>
39 - </dependency>
40 - <dependency>
41 - <groupId>org.onosproject</groupId>
42 - <artifactId>onlab-osgi</artifactId>
43 - <version>${project.version}</version>
44 - </dependency>
45 - <dependency>
46 - <groupId>org.onosproject</groupId>
47 - <artifactId>onlab-nio</artifactId>
48 - <version>${project.version}</version>
49 - </dependency>
50 - <dependency>
51 - <groupId>org.onosproject</groupId>
52 - <artifactId>onlab-netty</artifactId>
53 - <version>${project.version}</version>
54 - </dependency>
55 - <dependency>
56 - <groupId>org.apache.karaf.shell</groupId>
57 - <artifactId>org.apache.karaf.shell.console</artifactId>
58 - </dependency>
59 - <dependency>
60 - <groupId>org.onosproject</groupId>
61 - <artifactId>onlab-misc</artifactId>
62 - </dependency>
63 - <dependency>
64 - <groupId>com.google.guava</groupId>
65 - <artifactId>guava</artifactId>
66 - </dependency>
67 - <dependency>
68 - <groupId>org.osgi</groupId>
69 - <artifactId>org.osgi.core</artifactId>
70 - </dependency>
71 - </dependencies>
72 -</project>
...@@ -3,11 +3,36 @@ ...@@ -3,11 +3,36 @@
3 # Selectively builds only those projects that contained modified Java files. 3 # Selectively builds only those projects that contained modified Java files.
4 # ---------------------------------------------------------------------------- 4 # ----------------------------------------------------------------------------
5 5
6 -# TODO: figure out a more elegant way of ignoring disconnected projects 6 +projects=$(find $ONOS_ROOT -type f -path '*/src/*' \
7 -projects=$(find $ONOS_ROOT -name '*.java' \
8 - -not -path '.git/*' -and -not -path '*/archetypes/*' -and -not -path '*/grouphandler/*' -and -not -path '*/maven-plugin/*' \
9 -exec $ONOS_ROOT/tools/dev/bin/onos-build-selective-hook {} \; | \ 7 -exec $ONOS_ROOT/tools/dev/bin/onos-build-selective-hook {} \; | \
8 + grep -v -f $ONOS_ROOT/tools/dev/bin/onos-build-selective.exclude | \
10 sort -u | sed "s:$ONOS_ROOT::g" | tr '\n' ',' | \ 9 sort -u | sed "s:$ONOS_ROOT::g" | tr '\n' ',' | \
11 sed 's:/,:,:g;s:,/:,:g;s:^/::g;s:,$::g') 10 sed 's:/,:,:g;s:,/:,:g;s:^/::g;s:,$::g')
12 11
13 -[ -n "$projects" ] && cd $ONOS_ROOT && mvn --projects $projects ${@:-clean install} 12 +if [ -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"
38 +fi
......
1 #!/bin/bash 1 #!/bin/bash
2 # ---------------------------------------------------------------------------- 2 # ----------------------------------------------------------------------------
3 -# Echoes project-level directory if a Java file within is newer than the 3 +# Echoes project-level directory if a source file within is newer than the
4 # target directory. 4 # target directory.
5 # ---------------------------------------------------------------------------- 5 # ----------------------------------------------------------------------------
6 6
7 -javaFile=${1#*\/src\/*\/java/} 7 +[ ${1/*\//} = "package-info.java" ] && exit 0
8 -basename=${1/*\//}
9 8
10 -[ $basename = "package-info.java" ] && exit 0 9 +project=${1/src*/}
11 - 10 +[ ${project}target -nt $1 ] || echo ${project}
12 -src=${1/$javaFile/}
13 -project=${src/src*/}
14 -target=$project/target
15 -
16 -[ $target -nt ${src}$javaFile ] || echo ${src/src*/}
......
1 +.*/archetypes/.*
2 +.*/maven-plugin/.*
3 +.*/build/conf/.*
...\ No newline at end of file ...\ No newline at end of file