<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-core-parent</artifactId>
      <version>4.2.0</version>
   </parent>

   <groupId>org.rhq</groupId>
   <artifactId>rhq-core-plugin-api</artifactId>
   <packaging>jar</packaging>

   <name>RHQ Plugin API</name>
   <description>RHQ Plugin API used to write custom plugins</description>

  <scm>
    <connection>scm:git:ssh://git.fedorahosted.org/git/rhq.git/modules/core/plugin-api</connection>
    <developerConnection>scm:git:ssh://git.fedorahosted.org/git/rhq.git/modules/core/plugin-api</developerConnection>
  </scm>

  <properties>
    <scm.module.path>modules/core/plugin-api/</scm.module.path>
  </properties>

   <dependencies>

      <!-- Internal Deps -->

      <dependency>
         <groupId>${rhq.groupId}</groupId>
         <artifactId>rhq-core-domain</artifactId>
         <version>${project.version}</version>
         <scope>provided</scope>
      </dependency>

      <dependency>
         <groupId>${rhq.groupId}</groupId>
         <artifactId>rhq-core-native-system</artifactId>
         <version>${project.version}</version>
      </dependency>

      <!-- 3rd Party Deps -->

      <!-- TODO: This is a fix for the Javac bug requiring annotations to be
           available when compiling dependent classes. It is fixed in JDK 6 -->
      <dependency>
         <groupId>javax.persistence</groupId>
         <artifactId>persistence-api</artifactId>
         <version>1.0</version>
         <scope>provided</scope>
      </dependency>
      <dependency>
         <groupId>jboss.jboss-embeddable-ejb3</groupId>
         <artifactId>hibernate-all</artifactId>
         <version>1.0.0.Alpha9</version>
         <scope>provided</scope> <!-- by ON Container -->
         <!-- needed for referenced domain entities that use Hibernate annotations -->
      </dependency>

      <dependency>
         <groupId>javax.xml.bind</groupId>
         <artifactId>jaxb-api</artifactId>
         <!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
      </dependency>

      <dependency>
         <groupId>com.sun.xml.bind</groupId>
         <artifactId>jaxb-impl</artifactId>
         <!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
         <!--<scope>test</scope>  not sure about this -->
      </dependency>

   </dependencies>

   <profiles>

      <profile>
         <id>javadoc</id>
         <activation>
            <property>
               <name>javadoc.outputDirectory</name>
            </property>
         </activation>

         <build>
            <plugins>

               <plugin>
                  <artifactId>maven-javadoc-plugin</artifactId>

                  <executions>
                     <execution>
                        <id>agent-plugin-api</id>
                        <phase>compile</phase>
                        <goals>
                           <goal>javadoc</goal>
                        </goals>
                        <configuration>
                           <doctitle>RHQ ${project.version} Agent Plugin API</doctitle>
                           <windowtitle>RHQ ${project.version} Agent Plugin API</windowtitle>
                           <reportOutputDirectory>${javadoc.outputDirectory}</reportOutputDirectory>
                           <destDir>plugin-api</destDir>
                           <author>false</author>
                           <breakiterator>true</breakiterator>
                           <links>
                              <link>../domain/</link>
                              <link>../system/</link>
                           </links>
                        </configuration>
                     </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>
