<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.Beta1</version>
   </parent>

   <groupId>org.rhq</groupId>
   <artifactId>rhq-jboss-as-common</artifactId>
   <packaging>jar</packaging>

   <name>RHQ JBossAS 4/5 Plugins Common Library</name>
   <description>A library with the code common to the JBoss AS 4 and 5 plugins</description>

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

   <properties>
      <scm.module.path>modules/common/jboss-as/</scm.module.path>
   </properties>

   <dependencies>

      <dependency>
         <groupId>ant</groupId>
         <artifactId>ant</artifactId>
         <version>1.6.5</version>
      </dependency>
      <dependency>
         <groupId>jboss</groupId>
         <artifactId>jbpm</artifactId>
         <version>3.1.1</version>
      </dependency>

      <dependency>
         <groupId>dom4j</groupId>
         <artifactId>dom4j</artifactId>
         <version>1.6.1</version>
      </dependency>

       <dependency>
          <groupId>mc4j</groupId>
          <artifactId>org-mc4j-ems</artifactId>
          <!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
       </dependency>

       <dependency>
          <groupId>${project.groupId}</groupId>
          <artifactId>rhq-core-plugin-api</artifactId>
          <version>${project.version}</version>
          <scope>provided</scope> <!-- by PC -->
       </dependency>

   </dependencies>

<!-- Because this library is a helper only used by other libraries, it doesn't make
     sense to package its dependencies into the /lib folder of its jar. The libraries
     there wouldn't be loaded by the plugin container classloader anyway because this
     helper library is already present in a /lib of the actual plugin.
     The plugin poms therefore must copy the dependencies of this library into their
     /lib dirs manually (until we find a better way of solving this...).
-->
<!--
   <build>
      <plugins>

         <plugin>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.0</version>
            <executions>
               <execution>
                  <id>copy-dependencies</id>
                  <phase>process-resources</phase>
                  <goals>
                     <goal>copy</goal>
                  </goals>
                  <configuration>
                     <artifactItems>
                        <artifactItem>
                           <groupId>jboss</groupId>
                           <artifactId>jbpm</artifactId>
                           <version>3.1.1</version>
                        </artifactItem>
                     </artifactItems>
                     <outputDirectory>${project.build.outputDirectory}/lib</outputDirectory>
                  </configuration>
               </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>${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>
                   <path id="cobertura.classpath">
                         <fileset dir="${user.home}/.m2/repository/net/sourceforge/cobertura/cobertura/${cobertura.version}/">
                            <include name="cobertura*.jar" />
                            <include name="lib/**/*.jar" />
                         </fileset>
                   </path>
                   <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>