<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ JBoss, Home of Professional Open Source
  ~ Copyright 2012 Red Hat Inc. and/or its affiliates and other
  ~ contributors as indicated by the @author tags. All rights reserved.
  ~ See the copyright.txt in the distribution for a full listing of
  ~ individual contributors.
  ~
  ~ This is free software; you can redistribute it and/or modify it
  ~ under the terms of the GNU Lesser General Public License as
  ~ published by the Free Software Foundation; either version 2.1 of
  ~ the License, or (at your option) any later version.
  ~
  ~ This software is distributed in the hope that it will be useful,
  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  ~ Lesser General Public License for more details.
  ~
  ~ You should have received a copy of the GNU Lesser General Public
  ~ License along with this software; if not, write to the Free
  ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  -->
<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.infinispan</groupId>
      <artifactId>infinispan-parent</artifactId>
      <version>5.1.3.ER6-redhat-1</version>
      <relativePath>../parent/pom.xml</relativePath>
   </parent>

   <artifactId>infinispan-rhq-plugin</artifactId>
   <packaging>jar</packaging>

   <name>Infinispan RHQ Plugin</name>
   <description>The Infinispan RHQ Plugin</description>

   <properties>
      <scm.module.path>plugin/infinispan</scm.module.path>
      <rhq.defaultDevContainerPath>/jon/dev-container</rhq.defaultDevContainerPath>
   </properties>

   <dependencies>
      <dependency>
         <groupId>org.rhq</groupId>
         <artifactId>rhq-core-domain</artifactId>
         <scope>provided</scope>
         <exclusions>
            <exclusion>
               <groupId>hibernate</groupId>
               <artifactId>hibernate3</artifactId>
            </exclusion>
            <exclusion>
               <groupId>com.sun.xml.bind</groupId>
               <artifactId>jaxb-impl</artifactId>
            </exclusion>
            <exclusion>
               <groupId>javax.xml.bind</groupId>
               <artifactId>jaxb-api</artifactId>
            </exclusion>
            <exclusion>
               <groupId>net.sourceforge.cobertura</groupId>
               <artifactId>cobertura</artifactId>
            </exclusion>
         </exclusions>
      </dependency>
      <dependency>
         <groupId>org.rhq</groupId>
         <artifactId>rhq-core-plugin-api</artifactId>
         <exclusions>
            <exclusion>
               <groupId>com.sun.xml.bind</groupId>
               <artifactId>jaxb-impl</artifactId>
            </exclusion>
            <exclusion>
               <groupId>javax.xml.bind</groupId>
               <artifactId>jaxb-api</artifactId>
            </exclusion>
            <exclusion>
               <groupId>net.sourceforge.cobertura</groupId>
               <artifactId>cobertura</artifactId>
            </exclusion>
         </exclusions>
         <scope>provided</scope>
      </dependency>

      <dependency>
         <groupId>org.rhq</groupId>
         <artifactId>rhq-jmx-plugin</artifactId>
         <exclusions>
            <exclusion>
               <groupId>com.sun.xml.bind</groupId>
               <artifactId>jaxb-impl</artifactId>
            </exclusion>
            <exclusion>
               <groupId>javax.xml.bind</groupId>
               <artifactId>jaxb-api</artifactId>
            </exclusion>
            <exclusion>
               <groupId>net.sourceforge.cobertura</groupId>
               <artifactId>cobertura</artifactId>
            </exclusion>
         </exclusions>
         <scope>provided</scope>
      </dependency>
      
      <dependency>
         <groupId>org.rhq</groupId>
         <artifactId>rhq-core-native-system</artifactId>
         <exclusions>
            <exclusion>
               <groupId>org.hyperic</groupId>
               <artifactId>sigar</artifactId>
            </exclusion>
            <exclusion>
               <groupId>org.hyperic</groupId>
               <artifactId>sigar-dist</artifactId>
            </exclusion>
            <exclusion>
               <groupId>net.sourceforge.cobertura</groupId>
               <artifactId>cobertura</artifactId>
            </exclusion>
         </exclusions>
      </dependency>

      <dependency>
         <groupId>mc4j</groupId>
         <artifactId>org-mc4j-ems</artifactId>
         <scope>provided</scope>
      </dependency>

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

      <dependency>
            <groupId>org.jboss.logging</groupId>
            <artifactId>jboss-logging</artifactId>
            <scope>provided</scope>
      </dependency>

      <!-- Crazy dependencies to solve the usual compiler bug with unavailable annotations -->
      <dependency>
         <groupId>org.hibernate.javax.persistence</groupId>
         <artifactId>hibernate-jpa-2.0-api</artifactId>
         <scope>provided</scope>
      </dependency>
      
      <dependency>
         <groupId>org.hibernate</groupId>
         <artifactId>hibernate-core</artifactId>
         <scope>provided</scope>
      </dependency>

      <!-- Dependencies for plugin descriptor generation -->
      <dependency>
         <groupId>${project.groupId}</groupId>
         <artifactId>infinispan-core</artifactId>
         <scope>provided</scope>
      </dependency>
      
      <dependency>
         <groupId>${project.groupId}</groupId>
         <artifactId>infinispan-server-core</artifactId>
         <scope>provided</scope>
      </dependency>

      <dependency>
         <groupId>${project.groupId}</groupId>
         <artifactId>infinispan-core</artifactId>
         <type>test-jar</type>
         <scope>test</scope>
      </dependency>

   </dependencies>

   <build>
      <plugins>
         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <configuration>
               <archive>
                  <manifest>
                     <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
                     <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                     <mainClass>org.infinispan.Version</mainClass>
                  </manifest>
               </archive>
            </configuration>
            <executions>
               <execution>
                  <id>build-test-jar</id>
                  <goals>
                     <goal>test-jar</goal>
                  </goals>
                  <configuration>
                     <archive>
                        <manifest>
                           <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
                           <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                        </manifest>
                     </archive>
                  </configuration>
               </execution>
            </executions>
         </plugin>
         
         <!-- <plugin>
             <artifactId>maven-dependency-plugin</artifactId>
             <executions>
                 <execution>
                     <id>copy-infinispan-rhq-plugin-jar</id>
                     <phase>process-resources</phase>
                     <goals>
                         <goal>copy</goal>
                     </goals>
                     <configuration>
                         <artifactItems>
                             TODO include other needed external jars that should go into your jar file
                             <artifactItem>
                                 <groupId>org.infinispan</groupId>
                                 <artifactId>infinispan-core</artifactId>
                                 <version>${project.version}</version>
                             </artifactItem>
                             <artifactItem>
                                <groupId>org.jboss.logging</groupId>
                                <artifactId>jboss-logging</artifactId>
                                <version>${version.jboss.logging}</version>
                             </artifactItem>
                         </artifactItems>
                         <outputDirectory>${project.build.outputDirectory}/lib</outputDirectory>
                     </configuration>
                 </execution>
             </executions>
         </plugin> -->
 
         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <configuration>
               <doclet>org.infinispan.tools.rhq.RhqPluginXmlGenerator</doclet>
               <!--<additionalJOption>-J-Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y</additionalJOption>-->
               <docletArtifact>
                  <groupId>org.infinispan</groupId>
                  <artifactId>infinispan-tools</artifactId>
                  <version>${project.version}</version>
               </docletArtifact>
               <useStandardDocletOptions>false</useStandardDocletOptions>
            </configuration>
            <executions>
               <execution>
                  <phase>process-classes</phase>
                  <goals>
                     <goal>javadoc</goal>
                  </goals>
               </execution>
            </executions>
         </plugin>

      </plugins>
   </build>

   <profiles>
      <profile>
         <id>dev</id>

         <properties>
            <rhq.rootDir>../../..</rhq.rootDir>
            <rhq.containerDir>${rhq.rootDir}/${rhq.defaultDevContainerPath}</rhq.containerDir>
            <rhq.deploymentDir>
               ${rhq.containerDir}/jbossas/server/default/deploy/${rhq.earName}/rhq-downloads/rhq-plugins
            </rhq.deploymentDir>
         </properties>

         <build>
            <plugins>

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

                     <execution>
                        <id>deploy</id>
                        <phase>compile</phase>
                        <configuration>
                           <tasks>
                              <mkdir dir="${rhq.deploymentDir}"/>
                              <property name="deployment.file"
                                        location="${rhq.deploymentDir}/${project.build.finalName}.jar"/>
                              <echo>*** Updating ${deployment.file}...</echo>
                              <jar destfile="${deployment.file}" basedir="${project.build.outputDirectory}"/>
                           </tasks>
                        </configuration>
                        <goals>
                           <goal>run</goal>
                        </goals>
                     </execution>

                     <execution>
                        <id>deploy-jar-meta-inf</id>
                        <phase>package</phase>
                        <configuration>
                           <tasks>
                              <property name="deployment.file"
                                        location="${rhq.deploymentDir}/${project.build.finalName}.jar"/>
                              <echo>*** Updating META-INF dir in ${deployment.file}...</echo>
                              <unjar src="${project.build.directory}/${project.build.finalName}.jar"
                                     dest="${project.build.outputDirectory}">
                                 <patternset>
                                    <include name="META-INF/**"/>
                                 </patternset>
                              </unjar>
                              <jar destfile="${deployment.file}"
                                   manifest="${project.build.outputDirectory}/META-INF/MANIFEST.MF"
                                   update="true">
                              </jar>
                           </tasks>
                        </configuration>
                        <goals>
                           <goal>run</goal>
                        </goals>
                     </execution>

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

                  </executions>
               </plugin>

            </plugins>
         </build>

      </profile>
   </profiles>
</project>
