<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.7.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>
   
   <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-scripting-javascript</artifactId>
         <version>${project.version}</version>
         <scope>runtime</scope>
      </dependency>

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

      <dependency>
         <groupId>net.sf.opencsv</groupId>
         <artifactId>opencsv</artifactId>
      </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>
      </dependency>

      <dependency>
         <groupId>org.testng</groupId>
         <artifactId>testng</artifactId>
      </dependency>

      <dependency>
         <groupId>log4j</groupId>
         <artifactId>log4j</artifactId>
         <scope>runtime</scope>
      </dependency>

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

   <build>
      <plugins>

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

               <execution>
                  <id>client-distribution</id>
                  <phase>package</phase>
                  <configuration>
                     <target>
                        <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="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="i18nlog.version" value="${i18nlog.version}" />
                           <property name="jboss-common-core.version" value="${jboss-common-core.version}" />
                           <property name="jboss-logging.version" value="${jboss-logging.version}" />
                           <property name="jboss-remoting.version" value="${jboss-remoting.version}" />
                           <property name="jboss-javassist.version" value="${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="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}" />
                           <property name="rhq.bundle-additional-script-languages" value="${rhq.bundle-additional-script-languages}"/>
                        </ant>
                     </target>
                  </configuration>
                  <goals>
                     <goal>run</goal>
                  </goals>
               </execution>

               <execution>
                  <phase>process-classes</phase>
                  <configuration>
                  <target>
                     <!-- 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>
                  </target>
               </configuration>
               <goals>
                  <goal>run</goal>
               </goals>
               </execution>

            </executions>
         </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>

      </plugins>
   </build>


   <profiles>

      <profile>
         <!--
           This profile has been created to avoid unnecessary resolution of test dependencies during a build that
           does not run, compile or need tests.
           More test dependencies are to be moved here if the set of sub-dependencies is complex, references project
           test jars, or conflicts with changing the container version.
          -->
         <id>test.dependencies</id>
         <activation>
           <property>
             <name>maven.test.skip</name>
             <value>!true</value>
           </property>
         </activation>

         <dependencies>
           <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>rhq-core-domain</artifactId>
            <version>${project.version}</version>
            <type>test-jar</type>
            <scope>test</scope>
           </dependency>
         </dependencies>
       </profile>

      <!-- NOTE: this profile HAS TO have the same activation policy as the profile with the same name in the root pom.xml of RHQ -->
      <profile>
         <id>bundle-additional-script-languages</id>
         <activation>
            <property>
               <name>java.home</name>
            </property>
         </activation>

         <dependencies>
            <dependency>
               <groupId>${project.groupId}</groupId>
               <artifactId>rhq-scripting-python</artifactId>
               <version>${project.version}</version>
               <scope>runtime</scope>
            </dependency>
         </dependencies>
      </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}/${rhq.earDeployDir}/rhq-downloads/rhq-client</rhq.deploymentDir>
         </properties>

         <build>
            <plugins>
               <plugin>
                  <artifactId>maven-antrun-plugin</artifactId>
                  <executions>
                     <execution>
                        <id>deploy</id>
                        <phase>install</phase>
                        <configuration>
                           <target>
                              <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}" />
                           </target>
                        </configuration>
                        <goals>
                           <goal>run</goal>
                        </goals>
                     </execution>
                     <execution>
                        <id>undeploy</id>
                        <phase>clean</phase>
                        <configuration>
                           <target>
                              <echo>*** Deleting ${rhq.deploymentDir}...</echo>
                              <delete failonerror="false">
                                 <fileset dir="${rhq.deploymentDir}" includes="*" />
                              </delete>
                           </target>
                        </configuration>
                        <goals>
                           <goal>run</goal>
                        </goals>
                     </execution>
                  </executions>
               </plugin>
            </plugins>
         </build>
      </profile>
   </profiles>
</project>

