<?xml version="1.0" encoding="UTF-8"?>
<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">
  <parent>
	  <groupId>io.hawt</groupId>
	  <artifactId>project</artifactId>
    <version>1.4.67</version>
  </parent>

  <modelVersion>4.0.0</modelVersion>
  <artifactId>sample</artifactId>
  <packaging>war</packaging>
  <name>${project.artifactId}</name>
  <description>hawtio :: Sample Web Application and Console</description>

  <properties>
    <!-- filtered plugin properties, we don't define plugin-scripts here
      as we build that dynamically using maven-antrun-plugin below. -->
    <!-- plugin-context is what context this plugin will handle requests on
      in the application server -->
    <plugin-context>/hawtio</plugin-context>

    <!-- plugin-name is the name of our plugin, affects the name used for
      the plugin's mbean -->
    <plugin-name>${project.artifactId}</plugin-name>

    <!-- plugin-domain is currently unused, we just define it to an empty
      string -->
    <plugin-domain />

    <!-- this lets this plugin deploy nicely into karaf, these get used
      for the ImportPackage directive for maven-bundle-plugin -->
    <fuse.osgi.export>
      io.hawt.web.plugin
    </fuse.osgi.export>
    <fuse.osgi.import>
      javax.servlet,
      *;resolution:=optional
    </fuse.osgi.import>

    <hawtio-config-importURLs />
    <hawtio-config-cloneOnStartup>true</hawtio-config-cloneOnStartup>
    <warSourceDirectory>${basedir}/src/main/webapp</warSourceDirectory>
    <webappDirectory>${webapp-outdir}</webappDirectory>

  </properties>

  <dependencies>
    <dependency>
      <groupId>io.hawt</groupId>
      <artifactId>hawtio-default</artifactId>
      <version>${project.version}</version>
      <!--
        NOTE this WAR dependency type which enables this WAR to
        inherit all the plugins and content from the hawtio-default WAR
      -->
      <type>war</type>
    </dependency>
    <!-- we only need to embed this dependency in the war, this contains
      a nice helper class that our plugin can use to export it's plugin
      mbean -->
    <dependency>
      <groupId>io.hawt</groupId>
      <artifactId>hawtio-plugin-mbean</artifactId>
      <version>${project.version}</version>
    </dependency>

    <!-- servlet API is provided by the container -->
    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>servlet-api</artifactId>
      <version>${servlet-api-version}</version>
      <scope>provided</scope>
    </dependency>

    <!-- logging -->
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <version>${slf4j-version}</version>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-log4j12</artifactId>
      <version>${slf4j-version}</version>
    </dependency>

    <!-- lets mark dependencies from the WAR as provided to avoid jetty:run adding duplicates -->
    <dependency>
      <groupId>io.hawt</groupId>
      <artifactId>hawtio-core</artifactId>
      <version>${project.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>io.hawt</groupId>
      <artifactId>hawtio-git</artifactId>
      <version>${project.version}</version>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.jolokia</groupId>
      <artifactId>jolokia-core</artifactId>
      <version>${jolokia-version}</version>
    </dependency>


    <!-- for some sample stuff to browse -->
    <dependency>
      <groupId>io.hawt.example.services</groupId>
      <artifactId>example-infinispan</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>io.hawt.example.services</groupId>
      <artifactId>example-dozer-models</artifactId>
      <version>${project.version}</version>
    </dependency>
<!--
    <dependency>
      <groupId>io.hawt</groupId>
      <artifactId>hawtio-watcher-spring-context</artifactId>
      <version>${project.version}</version>
    </dependency>
-->

    <dependency>
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-jms</artifactId>
      <version>${camel-version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-spring</artifactId>
      <version>${camel-version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-jackson</artifactId>
      <version>${camel-version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.activemq</groupId>
      <artifactId>activemq-client</artifactId>
      <version>${activemq-version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.activemq</groupId>
      <artifactId>activemq-broker</artifactId>
      <version>${activemq-version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.activemq</groupId>
      <artifactId>activemq-camel</artifactId>
      <version>${activemq-version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-web</artifactId>
      <version>${spring-version}</version>
    </dependency>

<!--
    <dependency>
      <groupId>org.apache.xbean</groupId>
      <artifactId>xbean-spring</artifactId>
      <version>${xbean-version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-context</artifactId>
      <version>${spring-version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-core</artifactId>
      <version>${spring-version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-beans</artifactId>
      <version>${spring-version}</version>
    </dependency>
-->
    <dependency>
      <groupId>com.sun</groupId>
      <artifactId>tools</artifactId>
      <version>1.6</version>
      <scope>system</scope>
      <systemPath>${toolsjar}</systemPath>
    </dependency>
  </dependencies>

  <repositories>
    <repository>
      <id>oss-sonatype-snapshots</id>
      <name>OSS Sonatype Nexus Snapshots</name>
      <url>https://oss.sonatype.org/content/repositories/snapshots</url>
      <releases>
        <enabled>false</enabled>
      </releases>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </repository>
  </repositories>
  <build>
    <!-- we want to ensure src/main/resources/WEB-INF/web.xml is being filtered
      so that it picks up all of our javascript files -->
    <resources>
      <resource>
        <directory>src/main/resources</directory>
        <filtering>true</filtering>
        <includes>
          <include>**/*.xml</include>
        </includes>
      </resource>
    </resources>

    <plugins>

      <!-- We use maven-antrun-plugin to build up a list of
           javascript files for our plugin mbean, this means
           it needs to run before the maven-resources-plugin
           copies and filters the web.xml, since for this
           example we use contextParam settings to configure
           our plugin mbean -->

      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <version>${maven-antrun-plugin-version}</version>
        <executions>

          <execution>
            <!-- we run this early in the build process before
              maven-resources-plugin is run.  We're exporting the
              plugin-scripts property from here, so we need to
              use maven-antrun-plugin 1.6 or up -->
            <id>generate-sources</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <target>
                <echo>Building plugin javascript file list</echo>
                <!-- javascript-files will contain all of the javascript in
                  our project -->
                <fileset id="javascript-files" dir="${basedir}/src/main/webapp">
                  <include name="**/*.js" />
                </fileset>
                <!-- we need to strip out the top level path which is
                   our source directory and be sure to change the directory
                   separators to forward slashes -->
                <pathconvert pathsep="," dirsep="/" property="plugin-scripts" refid="javascript-files">
                  <map from="${basedir}/src/main/webapp/" to="" />
                </pathconvert>
                <!--<echo>Files: ${plugin-scripts}</echo>-->

                <echo>Copying log4j.properties</echo>
                <copy file="src/main/resources/log4j.properties" todir="target/classes" />

              </target>
              <!-- this exports plugin-scripts to the maven build, without
                this line ${plugin-scripts} in the web.xml file won't be
                replaced -->
              <exportAntProperties>true</exportAntProperties>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <version>${maven-resources-plugin-version}</version>
        <executions>
          <execution>
            <!-- defining this maven plugin in the same phase as the
              maven-antrun-plugin but *after* we've configured the
              maven-antrun-plugin ensures we filter resources *after*
              we've discovered the plugin .js files. -->
            <id>copy-resources</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>resources</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <!-- Exclude the hawtio-default overlay web.xml such that
       our own filtered one would take it's place
      -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.6</version>
        <configuration>
          <webXml>target/classes/WEB-INF/web.xml</webXml>
          <overlays>
            <overlay>
              <!--<groupId>io.hawtio</groupId>-->
              <id>hawtio-default</id>
              <excludes>
                <exclude>src/main/webapp/WEB-INF/web.xml</exclude>
              </excludes>
            </overlay>
          </overlays>
        </configuration>
      </plugin>

      <plugin>
        <groupId>${jetty-plugin-groupId}</groupId>
        <artifactId>jetty-maven-plugin</artifactId>
        <version>${jetty-version}</version>
        <configuration>
          <webAppSourceDirectory>${project.build.directory}/${project.name}</webAppSourceDirectory>
          <scanIntervalSeconds>1</scanIntervalSeconds>
          <webAppConfig>
            <descriptor>${webappDirectory}/WEB-INF/web.xml</descriptor>
            <contextPath>${context}</contextPath>
            <!--<resourceBases>-->
              <!--<resourceBase>${project.basedir}/src/main/webapp</resourceBase>-->
              <!--<resourceBase>${project.basedir}/src/main/webapp/js</resourceBase>-->
              <!--<resourceBase>${project.basedir}/src/main/webapp/html</resourceBase>-->
              <!--<resourceBase>${project.basedir}/src/main/webapp/css</resourceBase>-->
            <!--</resourceBases>-->
          </webAppConfig>
          <connectors>
            <connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
              <port>${jettyPort}</port>
              <maxIdleTime>60000</maxIdleTime>
            </connector>
          </connectors>
          <systemProperties>
            <systemProperty>
              <key>hawtio.config.dir</key>
              <value>${hawtio-config-dir}</value>
            </systemProperty>
            <systemProperty>
              <key>hawtio.config.repo</key>
              <value>${hawtio-config-repo}</value>
            </systemProperty>
          </systemProperties>
          <!--
           Causes jetty to reload js & friends while avoiding locking
           which would break things on Windows.
          -->
          <contextXml>${project.basedir}/jetty/jetty-config.xml</contextXml>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.tomcat.maven</groupId>
        <artifactId>tomcat7-maven-plugin</artifactId>
        <version>2.0</version>
        <configuration>
          <port>9090</port>
          <path>${context}</path>
          <systemProperties>
          </systemProperties>
          <useTestClasspath>false</useTestClasspath>
          <warSourceDirectory>${project.build.directory}/${project.name}-${project.version}</warSourceDirectory>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.tomcat.maven</groupId>
        <artifactId>tomcat6-maven-plugin</artifactId>
        <version>2.0</version>
        <configuration>
          <port>9090</port>
          <path>${context}</path>
          <systemProperties>
          </systemProperties>
          <useTestClasspath>false</useTestClasspath>
          <warSourceDirectory>${project.build.directory}/${project.name}-${project.version}</warSourceDirectory>
        </configuration>
      </plugin>

      <plugin>
        <artifactId>maven-clean-plugin</artifactId>
        <version>2.5</version>
        <configuration>
          <filesets>
            <fileset>
              <directory>${basedir}/overlays</directory>
              <includes>
                <include>**/*.*</include>
              </includes>
              <followSymlinks>false</followSymlinks>
            </fileset>
          </filesets>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>
