<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-common-parent</artifactId>
        <version>4.0.0.B02</version>
    </parent>

    <groupId>org.rhq</groupId>
    <artifactId>rhq-ant-bundle-common</artifactId>
    <packaging>jar</packaging>

    <name>RHQ Ant Bundle Plugins Common Library</name>
    <description>A library with the code common to the agent and server plugins for Ant Bundles</description>

    <scm>
        <connection>scm:git:ssh://git.fedorahosted.org/git/rhq.git/modules/common/ant-bundle/</connection>
        <developerConnection>scm:git:ssh://git.fedorahosted.org/git/rhq.git/modules/common/ant-bundle/</developerConnection>
    </scm>

    <properties>
        <scm.module.path>modules/common/ant-bundle/</scm.module.path>
    </properties>

    <dependencies>

        <dependency>
           <groupId>${project.groupId}</groupId>
           <artifactId>rhq-core-domain</artifactId>
           <version>${project.version}</version>
        </dependency>
     
        <dependency>
           <groupId>${project.groupId}</groupId>
           <artifactId>rhq-core-util</artifactId>
           <version>${project.version}</version>
        </dependency>
        
        <dependency>
           <groupId>${project.groupId}</groupId>
           <artifactId>rhq-core-native-system</artifactId>
           <version>${project.version}</version>
           <exclusions>
              <exclusion>
                 <groupId>org.hyperic</groupId>
                 <artifactId>sigar</artifactId>
              </exclusion>
              <exclusion>
                 <groupId>org.hyperic</groupId>
                 <artifactId>sigar-dist</artifactId>
              </exclusion>
           </exclusions>
        </dependency>

        <dependency>
           <groupId>commons-logging</groupId>
           <artifactId>commons-logging</artifactId>
           <version>1.1.0.jboss</version>
        </dependency>
        
        <dependency>
            <groupId>org.apache.ant</groupId>
            <artifactId>ant</artifactId>
            <version>1.8.0</version>
        </dependency>

        <dependency>
            <groupId>org.apache.ant</groupId>
            <artifactId>ant-launcher</artifactId>
            <version>1.8.0</version>
        </dependency>

        <!-- include some optional Ant tasks for users to be able to use -->
        <dependency>
            <groupId>org.apache.ant</groupId>
            <artifactId>ant-nodeps</artifactId>
            <version>1.8.0</version>
        </dependency>

        <dependency>
            <groupId>ant-contrib</groupId>
            <artifactId>ant-contrib</artifactId>
            <version>1.0b3</version>
            <exclusions>
               <exclusion>
                   <groupId>ant</groupId>
                   <artifactId>ant</artifactId>
               </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.liquibase</groupId>
            <artifactId>liquibase-core</artifactId>
            <version>1.9.5</version>
        </dependency>

    </dependencies>

    <build>
      <plugins>
       <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <configuration>
          <descriptors>
            <descriptor>src/main/scripts/assembly.xml</descriptor>
          </descriptors>
        </configuration>
        <executions>
          <execution>
             <id>assembly</id>
             <phase>package</phase>
             <goals>
                <goal>single</goal>
             </goals>
          </execution>
        </executions>
       </plugin>
      </plugins>
    </build>

  <profiles>
      <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>1.9.4.1</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>
