<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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <artifactId>rhq-enterprise-parent</artifactId>
        <groupId>org.rhq</groupId>
        <version>4.7.0</version>
    </parent>
    <artifactId>rhq-script-bindings</artifactId>
    <version>4.7.0</version>
    <name>RHQ Script Bindings</name>
    <description>Abstraction of different facilities and default configurations for script bindings</description>

    <properties>
        <filtered.location>src/main/java</filtered.location>
        <rhq.internal>false</rhq.internal>
    </properties>

    <dependencies>

        <dependency>
           <groupId>${project.groupId}</groupId>
           <artifactId>rhq-scripting-api</artifactId>
           <version>${project.version}</version>
        </dependency>

        <dependency>
           <groupId>${project.groupId}</groupId>
           <artifactId>rhq-core-util</artifactId>
           <version>${project.version}</version>
           <scope>provided</scope> <!-- by PC -->
        </dependency>
        
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>rhq-core-domain</artifactId>
            <version>${project.version}</version>
            <!-- I'm not sure this is still necessary due to hibernate now being provided scope in domain (jshaughn -->
            <exclusions>
                <exclusion>
                    <groupId>org.hibernate</groupId>
                    <artifactId>hibernate-entitymanager</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <!-- Provide a scripting impl for the tests -->
        <dependency>
           <groupId>${project.groupId}</groupId>
           <artifactId>rhq-scripting-javascript</artifactId>
           <version>${project.version}</version>
           <scope>test</scope>
        </dependency>
        
        <dependency>
           <groupId>${project.groupId}</groupId>
           <artifactId>rhq-scripting-python</artifactId>
           <version>${project.version}</version>
           <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>rhq-enterprise-server</artifactId>
            <version>${project.version}</version>
            <type>ejb-client</type>
            <exclusions>
                <exclusion>
                    <groupId>ant</groupId>
                    <artifactId>ant</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>commons-beanutils</groupId>
                    <artifactId>commons-beanutils</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>commons-collections</groupId>
                    <artifactId>commons-collections</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>commons-httpclient</groupId>
                    <artifactId>commons-httpclient</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>commons-lang</groupId>
                    <artifactId>commons-lang</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>commons-validator</groupId>
                    <artifactId>commons-validator</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>dom4j</groupId>
                    <artifactId>dom4j</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>gnu-getopt</groupId>
                    <artifactId>getopt</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>jboss</groupId>
                    <artifactId>jboss-cache</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>jboss</groupId>
                    <artifactId>jbpm</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>junit</groupId>
                    <artifactId>junit</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.rhq</groupId>
                    <artifactId>rhq-core-client-api</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.rhq</groupId>
                    <artifactId>rhq-core-dbutils</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.rhq</groupId>
                    <artifactId>rhq-enterprise-server-xml-schemas</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.rhq</groupId>
                    <artifactId>safe-invoker</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.rhq</groupId>
                    <artifactId>test-utils</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.snmp4j</groupId>
                    <artifactId>snmp4j</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>oswego-concurrent</groupId>
                    <artifactId>concurrent</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>postgresql</groupId>
                    <artifactId>postgresql</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>rss4j</groupId>
                    <artifactId>rss4j</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.jboss</groupId>
                    <artifactId>jboss-common-core</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>jboss</groupId>
                    <artifactId>jboss-jmx</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.jboss.remoting</groupId>
                    <artifactId>jboss-remoting</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>jboss</groupId>
                    <artifactId>jboss-serialization</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>antlr</groupId>
                    <artifactId>antlr</artifactId>
                </exclusion>                
                <exclusion>
                    <groupId>org.antlr</groupId>
                    <artifactId>antlr</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.jcraft</groupId>
                    <artifactId>jsch</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.rhq</groupId>
                    <artifactId>rhq-enterprise-comm</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>commons-lang</groupId>
            <artifactId>commons-lang</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>net.sf.opencsv</groupId>
            <artifactId>opencsv</artifactId>
        </dependency>

        <dependency>
            <groupId>org.javassist</groupId>
            <artifactId>javassist</artifactId>
        </dependency>

        <dependency>
            <groupId>org.powermock</groupId>
            <artifactId>powermock-module-testng</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.powermock</groupId>
            <artifactId>powermock-api-mockito</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
           <groupId>org.hibernate.javax.persistence</groupId>
           <artifactId>hibernate-jpa-2.0-api</artifactId>
           <scope>test</scope>    
      </dependency>

    </dependencies>

    <build>
        <sourceDirectory>${filtered.location}</sourceDirectory>
        <plugins>

            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <excludedGroups>${rhq.testng.excludedGroups}</excludedGroups>
                    <!-- <argLine>${jacoco.unit-test.args} -Xdebug -Xnoagent -Djava.compiler=NONE
                        -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y</argLine> -->
                    <argLine>${jacoco.unit-test.args} -Djava.security.manager -Djava.security.policy==${project.build.testOutputDirectory}/allow-all.policy</argLine>
                    <!-- This is important, because some of the tests try to exit the JVM. -->
                    <failIfNoTests>true</failIfNoTests>
                </configuration>
            </plugin>

            <plugin>
               <groupId>org.codehaus.mojo</groupId>
               <artifactId>clirr-maven-plugin</artifactId>
               <configuration>
                  <includes>
                     <!-- Hand picked stuff that corresponds to what is the script context initialized to
                     in the org/rhq/bindings/StandardBindings. -->
                     <include>org/rhq/bindings/client/*</include>
                     <include>org/rhq/bindings/export/*</include>
                     <include>org/rhq/bindings/output/*</include>
                     <include>org/rhq/bindings/util/ScriptAssert</include>
                     <include>org/rhq/bindings/util/ScriptAssertException</include>
                     <include>org/rhq/bindings/util/ScriptUtil</include>
                  </includes>
               </configuration>
            </plugin>

        </plugins>
    </build>

    <profiles>

      <profile>
         <!--
           This profile has been created to avoid unnecessary resolution of test dependencies during a build that
           does not run, compile or need tests.
           More test dependencies are to be moved here if the set of sub-dependencies is complex, references project
           test jars, or conflicts with changing the container version.
          -->
         <id>test.dependencies</id>
         <activation>
           <property>
             <name>maven.test.skip</name>
             <value>!true</value>
           </property>
         </activation>

         <dependencies>
           <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>rhq-core-domain</artifactId>
            <version>${project.version}</version>
            <type>test-jar</type>
            <scope>test</scope>
           </dependency>
         </dependencies>
       </profile>

        <profile>
            <id>dev</id>

            <properties>
                <rhq.rootDir>../../..</rhq.rootDir>
                <rhq.containerDir>${rhq.rootDir}/${rhq.defaultDevContainerPath}</rhq.containerDir>
                <rhq.deploymentDir>${rhq.containerDir}/${rhq.earLibDir}</rhq.deploymentDir>
            </properties>

            <build>
                <plugins>

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

                            <execution>
                                <id>deploy</id>
                                <phase>compile</phase>
                                <configuration>
                                    <target>
                                        <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}" />
                                    </target>
                                </configuration>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                            </execution>

                            <execution>
                                <id>undeploy</id>
                                <phase>clean</phase>
                                <configuration>
                                    <target>
                                        <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
                                        <echo>*** Deleting
                                            ${deployment.file}...</echo>
                                        <delete file="${deployment.file}" />
                                    </target>
                                </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-antrun-plugin</artifactId>
                  <executions>

                     <execution>
                        <id>bindings-api</id>
                        <phase>compile</phase>
                        <configuration>
                           <target>
                              <property name="javadoc.outputDirectory" value="${javadoc.outputDirectory}" />
                              <property name="project.dir" value="./src/main/java/org/rhq/bindings" />
                              <property name="maven.compile.classpath" refid="maven.compile.classpath" />
 
                              <mkdir dir="${javadoc.outputDirectory}/bindings" />
                              <javadoc destdir="${javadoc.outputDirectory}/bindings" author="false" version="true" windowtitle="RHQ ${project.version} Binding API" noindex="false">
                                 <classpath>
                                    <pathelement path="${maven.compile.classpath}" />
                                 </classpath>
                                 <fileset dir="${project.dir}" defaultexcludes="yes">
                                    <include name="**/RhqManagers.java" />
                                 </fileset>
                                 <link href="../remote-api/" />
                                 <link href="http://download.oracle.com/javase/6/docs/api/" />
                                 <bottom><![CDATA[Copyright &#169; 2005-2011 <a href="http://redhat.com/">Red Hat, Inc.</a>. All Rights Reserved.]]></bottom>
                              </javadoc>
                           </target>
                        </configuration>
                        <goals>
                           <goal>run</goal>
                        </goals>
                     </execution>

                  </executions>
               </plugin>
            </plugins>
         </build>

      </profile>

       <!-- Profile activated explicitly by command line call, or brew property.  -->
       <profile>
          <id>disable-tags</id>
            <activation>
                <property>
                    <name>brew</name>
                </property>
            </activation>
            <build>
            
               <resources>
                 <resource>
                   <directory>src/main/java</directory>
                   <filtering>true</filtering>
                   <targetPath>../filtered-sources/java</targetPath>
                 </resource>
                 <resource>
                   <directory>src/main/resources</directory>
                   <filtering>true</filtering>
                 </resource>
               </resources>
            
                <plugins>
                    <plugin>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <executions>

                            <execution>
                                <id>update-enabled-slsbs-for-remote</id>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <phase>generate-sources</phase>
                                <configuration>
                                    <target>
                                        <!-- Ex. -DTagManager=false will disable the TagManager from remote api if this profile is active. -->
                                        <echo>Updating remote api to exclude RemoteManagers passed in.</echo>
                                    </target>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        
    </profiles>
</project>
