Add hostname to .javacp

Maven resolved classpath will be stored to .javacp.`hostname` file.
This patch should help on cases where your ONOS directory is
shared between guest and host OS.

Change-Id: I9197a56664d49884a1cde52d34f8165e3af31fad
diff --git a/.gitignore b/.gitignore
index c9e6bc1..70a883c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,7 +4,7 @@
 .project
 .pydevproject
 .settings
-.javacp
+.javacp*
 target
 onos-logs
 onos.log
diff --git a/pom.xml b/pom.xml
index 77cadcc..bfff1bc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -201,6 +201,27 @@
 	</configuration>
       </plugin>
       <plugin>
+        <!-- Using groovy script to set maven property ${hostname}.
+             This is a workaround to get hostname as a property inside pom file,
+             which current Maven does not provide. -->
+        <groupId>org.codehaus.gmaven</groupId>
+        <artifactId>groovy-maven-plugin</artifactId>
+        <version>2.0</version>
+        <executions>
+          <execution>
+            <phase>initialize</phase>
+            <goals>
+              <goal>execute</goal>
+            </goals>
+            <configuration>
+              <source>
+                project.properties["hostname"] = InetAddress.getLocalHost().getHostName()
+              </source>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-dependency-plugin</artifactId>
         <version>2.8</version>
@@ -212,7 +233,7 @@
               <goal>build-classpath</goal>
             </goals>
             <configuration>
-              <outputFile>${project.basedir}/.javacp</outputFile>
+              <outputFile>${project.basedir}/.javacp.${hostname}</outputFile>
             </configuration>
           </execution>
         </executions>
@@ -316,6 +337,19 @@
                     <ignore></ignore>
                   </action>
                 </pluginExecution>
+                <pluginExecution>
+                  <pluginExecutionFilter>
+                    <groupId>org.codehaus.gmaven</groupId>
+                    <artifactId>groovy-maven-plugin</artifactId>
+                    <versionRange>[2.0,)</versionRange>
+                    <goals>
+                      <goal>execute</goal>
+                    </goals>
+                  </pluginExecutionFilter>
+                  <action>
+                    <ignore></ignore>
+                  </action>
+                </pluginExecution>
               </pluginExecutions>
             </lifecycleMappingMetadata>
           </configuration>
diff --git a/start-onos-jacoco.sh b/start-onos-jacoco.sh
index b721e9e..f2da4e0 100755
--- a/start-onos-jacoco.sh
+++ b/start-onos-jacoco.sh
@@ -43,10 +43,11 @@
     MVN="mvn -o"
 fi
 
-if [ ! -f ${ONOS_HOME}/.javacp ]; then
+CPFILE=${ONOS_HOME}/.javacp.`hostname`
+if [ ! -f ${CPFILE} ]; then
   ${MVN} -f ${ONOS_HOME}/pom.xml compile
 fi
-JAVA_CP=`cat ${ONOS_HOME}/.javacp`
+JAVA_CP=`cat ${CPFILE}`
 JAVA_CP="${JAVA_CP}:${ONOS_HOME}/target/classes"
 
 #<logger name="net.floodlightcontroller.linkdiscovery.internal" level="TRACE"/>
diff --git a/start-onos.sh b/start-onos.sh
index 248954d..e664d09 100755
--- a/start-onos.sh
+++ b/start-onos.sh
@@ -52,10 +52,11 @@
 
 MVN=${MVN:-mvn -o}
 
-if [ ! -f ${ONOS_HOME}/.javacp ]; then
+CPFILE=${ONOS_HOME}/.javacp.`hostname`
+if [ ! -f ${CPFILE} ]; then
   ${MVN} -f ${ONOS_HOME}/pom.xml compile
 fi
-JAVA_CP=`cat ${ONOS_HOME}/.javacp`
+JAVA_CP=`cat ${CPFILE}`
 JAVA_CP="${JAVA_CP}:${ONOS_HOME}/target/classes"
 
 #<logger name="net.floodlightcontroller.linkdiscovery.internal" level="TRACE"/>