<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

   <modelVersion>4.0.0</modelVersion>

   <parent>
      <groupId>org.rhq</groupId>
      <artifactId>rhq-parent</artifactId>
      <version>4.2.0</version>
      <relativePath>../../../../pom.xml</relativePath>
   </parent>

   <artifactId>rhq-remoting-cli</artifactId>

   <name>RHQ Enterprise Remote CLI</name>
   <description>RHQ Enterprise Remote Command Line Interface</description>

   <scm>
      <connection>scm:git:ssh://git.fedorahosted.org/git/rhq.git/modules/enterprise/client/</connection>
      <developerConnection>scm:git:ssh://git.fedorahosted.org/git/rhq.git/modules/enterprise/client/</developerConnection>
   </scm>

   <properties>
      <scm.module.path>modules/enterprise/remoting/</scm.module.path>
      <log4j.version>1.2.14</log4j.version>
      <persistence-api.version>1.0</persistence-api.version>
      <hibernate-all.version>1.0.0.Alpha9</hibernate-all.version>
      <opencsv.version>1.8</opencsv.version>
   </properties>

   <dependencies>
      <dependency>
         <groupId>${project.groupId}</groupId>
         <artifactId>rhq-remoting-client-api</artifactId>
         <version>${project.version}</version>
      </dependency>
      
      <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>rhq-script-bindings</artifactId>
            <version>${project.version}</version>
      </dependency>
      
      <dependency>
          <groupId>${project.groupId}</groupId>
          <artifactId>rhq-core-domain</artifactId>
          <version>${project.version}</version>
          <type>test-jar</type>
          <scope>test</scope>
      </dependency>

      <dependency>
         <groupId>commons-logging</groupId>
         <artifactId>commons-logging</artifactId>
      </dependency>

      <dependency>
         <groupId>net.sf.opencsv</groupId>
         <artifactId>opencsv</artifactId>
         <version>${opencsv.version}</version>
      </dependency>

      <dependency>
         <groupId>gnu-getopt</groupId>
         <artifactId>getopt</artifactId>
      </dependency>

      <dependency>
         <groupId>i18nlog</groupId>
         <artifactId>i18nlog</artifactId>
      </dependency>

      <dependency>
         <groupId>jline</groupId>
         <artifactId>jline</artifactId>
         <version>${jline.version}</version>
      </dependency>

      <dependency>
         <groupId>org.testng</groupId>
         <artifactId>testng</artifactId>
         <version>${testng.version}</version>
         <!-- Yes, this is actually meant to be compile, and not test, scoped. -->
      </dependency>

      <dependency>
         <groupId>log4j</groupId>
         <artifactId>log4j</artifactId>
         <version>${log4j.version}</version>
         <scope>runtime</scope>
      </dependency>

      <dependency>
         <groupId>commons-lang</groupId>
         <artifactId>commons-lang</artifactId>
         <version>2.4</version>
         <scope>test</scope>
      </dependency>
   </dependencies>

   <build>
      <plugins>

         <plugin>
            <artifactId>maven-antrun-plugin</artifactId>
            <executions>

               <execution>
                  <id>client-distribution</id>
                  <phase>package</phase>
                  <configuration>
                     <tasks>
                        <ant antfile="${basedir}/src/main/scripts/rhq-client.build.xml" dir="${basedir}" target="prepare-dist" inheritAll="false" inheritRefs="false">

                           <property name="buildNumber" value="${buildNumber}" />
                           <property name="java.jre.home" value="${java.home}" />
                           <property name="maven.compile.classpath" refid="maven.compile.classpath" />
                           <property name="maven.runtime.classpath" refid="maven.runtime.classpath" />
                           <property name="project.build.outputDirectory" value="${project.build.outputDirectory}" />
                           <property name="project.name" value="${project.name}" />
                           <property name="project.artifactId" value="${project.artifactId}" />
                           <property name="project.groupId" value="${project.groupId}" />
                           <property name="project.version" value="${project.version}" />
                           <property name="settings.localRepository" value="${settings.localRepository}" />
                           <property name="rhq-remoting-ws.version" value="${project.version}" />
                           <property name="commons-logging.version" value="${commons-logging.version}" />
                           <property name="opencsv.version" value="${opencsv.version}" />
                           <property name="concurrent.version" value="${concurrent.version}" />
                           <property name="getopt.version" value="${getopt.version}" />
                           <property name="hibernate-annotations.version" value="${hibernate-annotations.version}" />
                           <property name="i18nlog.version" value="${i18nlog.version}" />
                           <property name="jboss-common.version" value="${jboss-common.version}" />
                           <property name="jboss.version" value="${jboss.version}" />
                           <property name="jboss-remoting.version" value="${jboss-remoting.version}" />
                           <property name="jboss-javassist.version" value="${jboss-javassist.version}" />
                           <property name="jline.version" value="${jline.version}" />
                           <property name="log4j.version" value="${log4j.version}" />
                           <property name="testng.version" value="${testng.version}" />
                           <property name="persistence-api.version" value="${persistence-api.version}" />
                           <property name="rhq.client.build.exclude.cli.jar" value="${rhq.client.build.exclude.cli.jar}" />
                           <property name="rhq.client.build.include.client.jar" value="${rhq.client.build.include.client.jar}" />
                        </ant>
                     </tasks>
                  </configuration>
                  <goals>
                     <goal>run</goal>
                  </goals>
               </execution>

               <execution>
                  <phase>process-classes</phase>
                  <configuration>
                  <tasks>
                     <!-- generate the I18N resource bundles -->
                     <taskdef name="i18n" classpathref="maven.runtime.classpath" classname="mazz.i18n.ant.I18NAntTask" />

                     <i18n outputdir="${project.build.outputDirectory}" defaultlocale="en" verbose="false" append="false" verify="true">
                        <classpath refid="maven.runtime.classpath" />
                        <classfileset dir="${project.build.outputDirectory}">
                           <include name="**/ClientI18NResourceKeys.class" />
                        </classfileset>
                     </i18n>
                  </tasks>
               </configuration>
               <goals>
                  <goal>run</goal>
               </goals>
               </execution>

            </executions>
         </plugin>

         <plugin>
            <artifactId>maven-jar-plugin</artifactId>
            <configuration>
               <includes>
                  <include>org/rhq/**</include>
                  <include>client-messages*</include>
               </includes>
               <archive>
                  <index>true</index>
                  <manifestEntries>
                     <Implementation-Title>${rhq.product.name} - ${project.name}</Implementation-Title>
                     <Implementation-Version>${project.version}</Implementation-Version>
                     <Specification-Vendor>org.jboss</Specification-Vendor>
                     <Specification-Title>JBossWS</Specification-Title>
                     <Specification-Version>${jbossws-native-dist.version}</Specification-Version>
                     <Build-Number>${buildNumber}</Build-Number>
                  </manifestEntries>
               </archive>
            </configuration>
         </plugin>

         <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <configuration>
               <descriptors>
                  <descriptor>src/main/scripts/rhq-client.assembly.xml</descriptor>
               </descriptors>
               <finalName>${project.build.finalName}</finalName>
            </configuration>
            <executions>
               <execution>
                  <id>assemble-rhq-client-zip</id>
                  <phase>pre-integration-test</phase>
                  <goals>
                     <goal>single</goal>
                  </goals>
               </execution>
            </executions>
         </plugin>

<!--
         <plugin>
            <artifactId>maven-surefire-plugin</artifactId>
            <executions>
               <execution>
                  <id>test-non-ws</id>
                  <phase>test</phase>

                  <configuration>
                     <excludedGroups>${rhq.testng.excludedGroups},ws</excludedGroups>
                     <forkMode>pertest</forkMode>
                     <argLine>-Xmx512m -Xms128m</argLine>
                     <additionalClasspathElements>
-->
                        <!-- The below is required for WS Java Client support -->
<!--
                        <additionalClasspathElement>
                           ${project.build.outputDirectory}/lib/rhq-cli-${project.version}.jar
                        </additionalClasspathElement>
                        <additionalClasspathElement>
                           ${project.build.outputDirectory}/lib/${project.build.finalName}.jar
                        </additionalClasspathElement>
                     </additionalClasspathElements>

                  </configuration>

                  <goals>
                     <goal>test</goal>
                  </goals>
               </execution>
            </executions>
         </plugin>
-->
      </plugins>
   </build>


   <profiles>

      <!-- Unlike most of RHQ, this module requires JDK6, so replace the Java 5 bootclasspath that was added to the compiler args by the root POM with a bootclasspath based on the java.home sysprop (which should be Java 6 or later if the enforcer plugin did its job). -->
      <profile>
         <id>check-java-api</id>

         <activation>
            <property>
               <name>java5.home</name>
            </property>
         </activation>

         <build>
           <plugins>
              <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                  <compilerArguments>
                    <bootclasspath>${java.home}/lib/rt.jar${path.separator}${java.home}/lib/jsse.jar${path.separator}${java.home}/lib/jce.jar</bootclasspath>
                  </compilerArguments>
                </configuration>
              </plugin>
            </plugins>
          </build>
      </profile>

      <profile>
         <id>dev</id>
         <properties>
            <rhq.client.build.include.client.jar>true</rhq.client.build.include.client.jar>
            <rhq.rootDir>../../../..</rhq.rootDir>
            <rhq.containerDir>${rhq.rootDir}/${rhq.defaultDevContainerPath}</rhq.containerDir>
            <rhq.projectJar>${project.build.finalName}.zip</rhq.projectJar>
            <rhq.deploymentZip>rhq-remoting-cli-${project.version}.zip</rhq.deploymentZip>
            <rhq.deploymentDir>${rhq.containerDir}/jbossas/server/default/deploy/${rhq.earName}/rhq-downloads/rhq-client</rhq.deploymentDir>
         </properties>

         <build>
            <plugins>
               <plugin>
                  <artifactId>maven-antrun-plugin</artifactId>
                  <version>1.1</version>
                  <executions>
                     <execution>
                        <id>deploy</id>
                        <phase>install</phase>
                        <configuration>
                           <tasks>
                              <echo>*** Cleaning old ${rhq.deploymentDir}...</echo>
                              <mkdir dir="${rhq.deploymentDir}" />
                              <delete failonerror="false">
                                 <fileset dir="${rhq.deploymentDir}" includes="*.properties" />
                              </delete>
                              <property name="deployment.file" location="${rhq.deploymentDir}/${rhq.deploymentZip}" />
                              <echo>*** Updating ${deployment.file}...</echo>
                              <copy file="${basedir}/target/${rhq.projectJar}" toFile="${deployment.file}" />
                           </tasks>
                        </configuration>
                        <goals>
                           <goal>run</goal>
                        </goals>
                     </execution>
                     <execution>
                        <id>undeploy</id>
                        <phase>clean</phase>
                        <configuration>
                           <tasks>
                              <echo>*** Deleting ${rhq.deploymentDir}...</echo>
                              <delete failonerror="false">
                                 <fileset dir="${rhq.deploymentDir}" includes="*" />
                              </delete>
                           </tasks>
                        </configuration>
                        <goals>
                           <goal>run</goal>
                        </goals>
                     </execution>
                  </executions>
               </plugin>
            </plugins>
         </build>
      </profile>
      <profile>
      <id>cobertura</id>
      <activation>
        <activeByDefault>false</activeByDefault>
      </activation>
        <build>
         <plugins>
           <plugin>
             <artifactId>maven-antrun-plugin</artifactId>
              <dependencies>
               <dependency>
                 <groupId>net.sourceforge.cobertura</groupId>
                 <artifactId>cobertura</artifactId>
                 <version>${cobertura.version}</version>
               </dependency>
             </dependencies>
             <executions>
              <execution>
               <id>cobertura-instrument</id>
               <phase>process-test-classes</phase>
                 <configuration>
                   <tasks>
                   <!-- prepare directory structure for cobertura-->
                   <mkdir dir="target/cobertura" />
                   <mkdir dir="target/cobertura/backup" />
                   <!-- backup all classes so that we can instrument the original classes-->
                   <copy toDir="target/cobertura/backup" verbose="true" overwrite="true">
                      <fileset dir="target/classes">
                         <include name="**/*.class" />
                      </fileset>
                   </copy>
                   <!-- create a properties file and save there location of cobertura data file-->
                   <touch file="target/classes/cobertura.properties" />
                   <echo file="target/classes/cobertura.properties">net.sourceforge.cobertura.datafile=${project.build.directory}/cobertura/cobertura.ser</echo>
                   <taskdef classpathref="maven.plugin.classpath" resource="tasks.properties" />
                   <!-- instrument all classes in target/classes directory -->
                   <cobertura-instrument datafile="${project.build.directory}/cobertura/cobertura.ser" todir="${project.build.directory}/classes">
                     <fileset dir="${project.build.directory}/classes">
                        <include name="**/*.class" />
                      </fileset>
                    </cobertura-instrument>
                   </tasks>
                 </configuration>
               <goals>
                 <goal>run</goal>
               </goals>
              </execution>
              <execution>
               <id>cobertura-report</id>
               <phase>prepare-package</phase>
                 <configuration>
                   <tasks>
                     <taskdef classpathref="maven.plugin.classpath" resource="tasks.properties" />
                     <!-- prepare directory structure for cobertura-->
                     <mkdir dir="target/cobertura" />
                     <mkdir dir="target/site/cobertura" />
                     <!-- restore classes from backup folder to classes folder -->
                     <copy toDir="target/classes" verbose="true" overwrite="true">
                      <fileset dir="target/cobertura/backup">
                         <include name="**/*.class" />
                      </fileset>
                     </copy>
                     <!-- delete backup folder-->
                     <delete dir="target/cobertura/backup" />
                     <!-- create a code coverage report -->
                     <cobertura-report format="html" datafile="${project.build.directory}/cobertura/cobertura.ser" destdir="${project.build.directory}/site/cobertura">
                      <fileset dir="${basedir}/src/main/java">
                         <include name="**/*.java" />
                      </fileset>
                     </cobertura-report>
                     <!-- delete cobertura.properties file -->
                     <delete file="target/classes/cobertura.properties" />
                   </tasks>
                 </configuration>
               <goals>
                 <goal>run</goal>
               </goals>
               </execution>
            </executions>
           </plugin>
          </plugins>
       </build>
     </profile>
   </profiles>

</project>
