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

   <artifactId>rhq-core-domain</artifactId>
   <packaging>ejb</packaging>

   <name>RHQ Domain Model</name>
   <description>RHQ domain model classes (i.e. POJOs used by both server and agent)</description>

   <properties>
     <!-- dependency versions -->
     <jboss-embeddable-ejb3.version>1.0.0.Alpha9</jboss-embeddable-ejb3.version>
   </properties>


   <dependencies>

      <!-- the notorious util jar -->
      <dependency>
         <groupId>${rhq.groupId}</groupId>
         <artifactId>rhq-core-util</artifactId>
         <version>${project.version}</version>
      </dependency>

      <!-- required by PersistenceUtil (provided by AS) -->
      <!-- required also by hibernate Instrument task. (but use compile scope for this) -->
      <dependency>
         <groupId>hibernate</groupId>
         <artifactId>hibernate3</artifactId>
         <!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
         <scope>compile</scope>
      </dependency>

      <dependency>
         <groupId>hibernate-annotations</groupId>
         <artifactId>hibernate-annotations</artifactId>
         <!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
         <scope>provided</scope> <!-- by JBossAS -->
      </dependency>

      <!-- required by PersistenceUtil and EJB3 Embedded -->
      <dependency>
         <groupId>hibernate-entitymanager</groupId>
         <artifactId>hibernate-entitymanager</artifactId>
         <!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
         <scope>provided</scope> <!-- by JBossAS -->
      </dependency>

      <dependency>
         <groupId>javax.persistence</groupId>
         <artifactId>persistence-api</artifactId>
         <version>1.0</version>
         <scope>provided</scope> <!-- by JBossAS -->
      </dependency>

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

      <!--  needed for hibernate Instrument task
      <dependency>
         <groupId>javassist</groupId>
         <artifactId>javassist</artifactId>
         <version>${jboss-javassist.version}</version>
         <scope>runtime</scope>
      </dependency>
      -->

      <!--  needed for hibernate Instrument task
      <dependency>
        <groupId>commons-logging</groupId>
        <artifactId>commons-logging</artifactId>
        <scope>runtime</scope>
      </dependency>
      -->

      <!-- needed if you want to use the logging JDBC wrapper
      <dependency>
         <groupId>org.rhq</groupId>
         <artifactId>rhq-core-dbutils</artifactId>
         <version>${project.version}</version>
      </dependency>
      -->

      <!--
      <!- - so Seam annotations can be used in the entities - ->
      <dependency>
         <groupId>jboss</groupId>
         <artifactId>jboss-seam</artifactId>
         <version>${seam.version}</version>
         <scope>provided</scope> <!- - by ${rhq.earName} - ->
      </dependency>
      -->

      <!--================ Test Deps ================-->
      <dependency>
          <groupId>${project.groupId}</groupId>
          <artifactId>test-utils</artifactId>
          <version>${project.version}</version>
          <scope>test</scope>
      </dependency>

      <dependency>
         <groupId>javassist</groupId>
         <artifactId>javassist</artifactId>
         <version>${jboss-javassist.version}</version>
         <scope>test</scope>
      </dependency>

      <dependency>
         <groupId>postgresql</groupId>
         <artifactId>postgresql</artifactId>
         <!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
         <scope>test</scope>
      </dependency>

      <dependency>
         <groupId>com.h2database</groupId>
         <artifactId>h2</artifactId>
         <!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
         <scope>test</scope>
      </dependency>

      <dependency>
         <groupId>net.sourceforge.jtds</groupId>
         <artifactId>jtds</artifactId>
         <!-- NOTE: The version is defined in the root POM's dependencyManagement section. -->
         <scope>test</scope>
      </dependency>

      <dependency>
         <groupId>jboss.jboss-embeddable-ejb3</groupId>
         <artifactId>jboss-ejb3-all</artifactId>
         <version>${jboss-embeddable-ejb3.version}</version>
         <scope>test</scope>
      </dependency>

<!--
      <dependency>
         <groupId>jboss.jboss-embeddable-ejb3</groupId>
         <artifactId>hibernate-all</artifactId>
         <version>${jboss-embeddable-ejb3.version}</version>
         <scope>test</scope>
      </dependency>

      <dependency>
         <groupId>jboss.jboss-embeddable-ejb3</groupId>
         <artifactId>thirdparty-all</artifactId>
         <version>${jboss-embeddable-ejb3.version}</version>
         <scope>test</scope>
      </dependency>
-->

      <!-- NOTE: The remaining test deps correspond to the classes contained in hibernate-all.jar and thirdparty-all.jar. -->

      <dependency>
         <groupId>antlr</groupId>
         <artifactId>antlr</artifactId>
         <version>2.7.7</version>
         <scope>test</scope>
      </dependency>

      <dependency>
         <groupId>cglib</groupId>
         <artifactId>cglib-nodep</artifactId>
         <version>2.1_3</version>
         <scope>test</scope>
      </dependency>

      <dependency>
         <groupId>commons-io</groupId>
         <artifactId>commons-io</artifactId>
         <version>1.4</version>
         <scope>test</scope>
      </dependency>

      <dependency>
         <groupId>commons-collections</groupId>
         <artifactId>commons-collections</artifactId>
         <version>3.2</version>
         <scope>test</scope>
      </dependency>

      <dependency>
         <groupId>commons-codec</groupId>
         <artifactId>commons-codec</artifactId>
         <version>${commons-codec.version}</version>
         <scope>test</scope>
      </dependency>

     <dependency>
         <groupId>dom4j</groupId>
         <artifactId>dom4j</artifactId>
         <version>1.6.1-jboss</version>
         <scope>test</scope>
      </dependency>

      <dependency>
         <groupId>oswego-concurrent</groupId>
         <artifactId>concurrent</artifactId>
         <version>1.3.4</version>
         <scope>test</scope>
      </dependency>

      <dependency>
         <groupId>trove</groupId>
         <artifactId>trove</artifactId>
         <version>1.0.2</version>
         <scope>test</scope>
      </dependency>

      <dependency>
         <groupId>xerces</groupId>
         <artifactId>xercesImpl</artifactId>
         <version>2.8.1</version>
         <scope>test</scope>
      </dependency>
   </dependencies>

   <build>

      <finalName>rhq-core-domain-ejb3</finalName>

       <resources>
           <resource>
               <directory>src/main/java</directory>
           </resource>
           <resource>
               <directory>src/main/resources</directory>
           </resource>
       </resources>


       <testResources>
         <testResource>
            <directory>src/test/resources</directory>
            <filtering>true</filtering>
         </testResource>
      </testResources>

      <plugins>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-source-plugin</artifactId>
        <version>2.1.2</version>
        <executions>
          <execution>
            <id>attach-sources</id>
            <phase>verify</phase>
            <goals>
              <goal>jar-no-fork</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

          <plugin>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
              <systemProperties>
                <property>
                  <name>ejbjarDirectory</name>
                  <value>target/classes</value>
                </property>
                <property>
                  <name>hibernate.dialect</name>
                  <value>${rhq.test.ds.hibernate-dialect}</value>
                </property>
              </systemProperties>
              <excludes>
                <exclude>**/ResourceTypeTest.java</exclude>
              </excludes>
              <!-- The below is required for tests to run against Oracle. -->
              <additionalClasspathElements>
                 <additionalClasspathElement>${settings.localRepository}/com/oracle/ojdbc6/${ojdbc6.version}/ojdbc6-${ojdbc6.version}.jar</additionalClasspathElement>
              </additionalClasspathElements>
            </configuration>
         </plugin>

         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <executions>
               <execution>
                  <phase>package</phase>
                  <goals>
                     <goal>test-jar</goal>
                  </goals>
                  <configuration>
                     <includes>
                        <include>org/rhq/core/domain/shared/**</include>
                     </includes>
                  </configuration>
               </execution>
            </executions>
         </plugin>
      </plugins>
   </build>


   <profiles>

       <profile>
         <id>dev</id>

         <properties>
            <rhq.rootDir>../../..</rhq.rootDir>
            <rhq.containerDir>${rhq.rootDir}/${rhq.defaultDevContainerPath}</rhq.containerDir>
            <rhq.deploymentName>${project.build.finalName}.jar</rhq.deploymentName>
            <rhq.deploymentDir>${rhq.containerDir}/jbossas/server/default/deploy/${rhq.earName}/${rhq.deploymentName}</rhq.deploymentDir>
         </properties>

         <build>
            <plugins>

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

                     <execution>
                        <phase>process-classes</phase>
                        <configuration>
                           <tasks>
                           <!-- don't instrument...
                           I'm leaving this here as an example of how to apply Hibernate Instrumentation to a class.
                           Instrumentation is useful for various property-level things such as field-level lazy load.
                           Using it turned out not t be a current option since the instrumented class carries with
                           it hibernate imports that we can't put in the domain jar since it's used on the Agent and
                           in Remote Java Clients. But this worked, so here ya go...
                              <taskdef name="instrument" classname="org.hibernate.tool.instrument.javassist.InstrumentTask">
                                 <classpath>
                                    <path refid="maven.runtime.classpath" />
                                    <path refid="maven.plugin.classpath" />
                                 </classpath>
                                 </taskdef>
                              <instrument verbose="true">
                                 <fileset dir="${project.build.outputDirectory}">
                                    <include name="**/domain/**/PackageBits.class" />
                                 </fileset>
                              </instrument>
                           -->
                              <property name="deployment.dir" location="${rhq.deploymentDir}" />
                              <echo>*** Copying updated files from target${file.separator}classes${file.separator} to ${deployment.dir}${file.separator}...</echo>
                              <copy todir="${deployment.dir}" verbose="${rhq.verbose}">
                                 <fileset dir="target/classes" />
                              </copy>
                           </tasks>
                        </configuration>
                        <goals>
                           <goal>run</goal>
                        </goals>
                     </execution>

                     <execution>
                        <id>undeploy</id>
                        <phase>clean</phase>
                        <configuration>
                          <tasks>
                            <property name="deployment.dir" location="${rhq.deploymentDir}" />
                            <echo>*** Deleting ${deployment.dir}${file.separator}...</echo>
                            <delete dir="${deployment.dir}" />
                          </tasks>
                        </configuration>
                        <goals>
                          <goal>run</goal>
                        </goals>
                     </execution>

                   </executions>
               </plugin>

           </plugins>
         </build>
      </profile>

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

         <build>
            <plugins>

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

                  <executions>
                     <execution>
                        <id>domain-api</id>
                        <phase>compile</phase>
                        <goals>
                           <goal>javadoc</goal>
                        </goals>
                        <configuration>
                           <doctitle>RHQ ${project.version} Domain API</doctitle>
                           <windowtitle>RHQ ${project.version} Domain API</windowtitle>
                           <reportOutputDirectory>${javadoc.outputDirectory}</reportOutputDirectory>
                           <destDir>domain</destDir>
                           <author>false</author>
                           <breakiterator>true</breakiterator>
                           <links>
                              <link>http://java.sun.com/javaee/5/docs/api/</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>


   <repositories>

        <repository>
            <id>codehaus</id>
            <name>Codehaus Releases</name>
            <url>http://repository.codehaus.org/</url>
            <snapshots>
               <enabled>false</enabled>
            </snapshots>
        </repository>

   </repositories>

</project>
