<?xml version="1.0" encoding="UTF-8"?>

<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->

<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0">
  <parent>
    <artifactId>components</artifactId>
    <groupId>org.apache.camel</groupId>
    <version>1.5.0</version>
  </parent>
  <modelVersion>4.0.0</modelVersion>
  <artifactId>camel-rest</artifactId>

  <name>Camel :: REST</name>
  <description>Camel REST Support</description>
  <packaging>war</packaging>

  <properties>
    <camel.osgi.export.pkg>org.apache.camel.rest.*</camel.osgi.export.pkg>
    <jersey-version>1.0-ea-SNAPSHOT</jersey-version>
    <jetty-port>8080</jetty-port>
  </properties>

  <repositories>
    <repository>
      <id>java.net.maven2</id>
      <name>java.net Maven 2 Repo</name>
      <url>http://download.java.net/maven/2</url>
    </repository>
  </repositories>

  <dependencies>
    <dependency>
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-core</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-spring</artifactId>
    </dependency>
    <dependency>
      <groupId>com.sun.jersey</groupId>
      <artifactId>jersey-spring</artifactId>
      <version>${jersey-version}</version>
    </dependency>
    <dependency>
      <groupId>com.sun.jersey</groupId>
      <artifactId>jersey-json</artifactId>
      <version>${jersey-version}</version>
    </dependency>
    <dependency>
      <groupId>com.sun.jersey</groupId>
      <artifactId>jersey-atom</artifactId>
      <version>${jersey-version}</version>
    </dependency>

    <!-- testing -->
    <dependency>
      <groupId>com.sun.jersey</groupId>
      <artifactId>jersey-client</artifactId>
      <version>${jersey-version}</version>
      <scope>test</scope>
    </dependency>
    <!-- web container -->
    <dependency>
      <groupId>org.mortbay.jetty</groupId>
      <artifactId>jetty</artifactId>
      <version>${jetty-version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.mortbay.jetty</groupId>
      <artifactId>jetty-util</artifactId>
      <version>${jetty-version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.mortbay.jetty</groupId>
      <artifactId>jsp-2.1</artifactId>
      <version>${jetty-version}</version>
      <scope>test</scope>
    </dependency>
    <!-- enable commons-logging when inside jetty6:run -->
    <!--
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>jcl104-over-slf4j</artifactId>
        <version>1.5.0</version>
    </dependency>
    -->
    <!--
        <dependency>
          <groupId>org.slf4j</groupId>
          <artifactId>slf4j-jcl</artifactId>
        </dependency>
    -->
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-log4j12</artifactId>
    </dependency>

    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-test</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>commons-logging</groupId>
      <artifactId>commons-logging</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>log4j</groupId>
      <artifactId>log4j</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <resources>
      <resource>
        <directory>src/main/resources</directory>
        <filtering>false</filtering>
      </resource>
    </resources>

    <plugins>
      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <forkMode>pertest</forkMode>
          <includes>
            <include>**/*Test.*</include>
          </includes>
          <excludes>
            <!-- TODO FIXME ASAP -->
            <exclude>**/EndpointsHtmlTest.*</exclude>
            <exclude>**/RoutesTest.*</exclude>
          </excludes>
        </configuration>
      </plugin>


      <plugin>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.1-alpha-2</version>
        <configuration>
          <attachClasses>true</attachClasses>
        </configuration>
      </plugin>


      <plugin>
        <groupId>org.mortbay.jetty</groupId>
        <artifactId>maven-jetty-plugin</artifactId>
        <version>${jetty-version}</version>

        <configuration>
          <!--
                    <connectors>
                      <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
                        <port>${jetty.port}</port>
                        <maxIdleTime>60000</maxIdleTime>
                      </connector>
                    </connectors>
          -->

          <webAppConfig>
            <contextPath>/</contextPath>
          </webAppConfig>

          <systemProperties>
            <!-- enable easy JMX connection to JConsole -->
            <systemProperty>
              <name>com.sun.management.jmxremote</name>
              <value/>
            </systemProperty>
          </systemProperties>
          <scanIntervalSeconds>10</scanIntervalSeconds>
        </configuration>
        <dependencies>
          <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>${log4j-version}</version>
          </dependency>
          <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
          </dependency>
          <dependency>
            <groupId>taglibs</groupId>
            <artifactId>standard</artifactId>
            <version>1.1.2</version>
          </dependency>
        </dependencies>
      </plugin>
      
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <executions>
          <execution>
            <goals>
              <goal>javadoc</goal>
            </goals>
            <!--<phase>compile</phase>-->
            <phase>package</phase>
          </execution>
        </executions>

        <configuration>

          <encoding>UTF-8</encoding>
          <verbose>false</verbose>
          <show>public</show>
          <subpackages>com.sun.jersey.samples.generatewadl.resources</subpackages>

          <doclet>com.sun.jersey.wadl.resourcedoc.ResourceDoclet</doclet>
          <docletArtifacts>
            <docletArtifact>
              <groupId>com.sun.jersey</groupId>
              <artifactId>maven-wadl-plugin</artifactId>
              <version>${jersey-version}</version>
            </docletArtifact>
            <!--
                Also specify jersey and xerces as doclet artifacts as the ResourceDoclet
                uses classes provided by them to generate the resourcedoc.
             -->
            <docletArtifact>
              <groupId>com.sun.jersey</groupId>
              <artifactId>jersey-server</artifactId>
              <version>${jersey-version}</version>
            </docletArtifact>
            <docletArtifact>
              <groupId>xerces</groupId>
              <artifactId>xercesImpl</artifactId>
              <version>2.6.1</version>
            </docletArtifact>
            <docletArtifact>
              <groupId>javax.xml.bind</groupId>
              <artifactId>jaxb-api</artifactId>
              <version>${jaxb-api-version}</version>
            </docletArtifact>
            <docletArtifact>
              <groupId>com.sun.xml.bind</groupId>
              <artifactId>jaxb-impl</artifactId>
              <version>${jaxb-version}</version>
            </docletArtifact>
            <docletArtifact>
              <groupId>javax.activation</groupId>
              <artifactId>activation</artifactId>
              <version>1.1</version>
            </docletArtifact>
            <docletArtifact>
              <groupId>stax</groupId>
              <artifactId>stax-api</artifactId>
              <version>${stax-api-version}</version>
            </docletArtifact>
          </docletArtifacts>
          <additionalparam>-output ${project.build.outputDirectory}/resourcedoc.xml</additionalparam>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>attach-artifacts</id>
            <phase>package</phase>
            <goals>
              <goal>attach-artifact</goal>
            </goals>
            <configuration>
              <artifacts>
                <artifact>
                  <file>${project.build.directory}/schema/camel-rest.xsd</file>
                  <type>xsd</type>
                </artifact>
              </artifacts>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
    
    <pluginManagement>
      <plugins>
          <plugin>
            <groupId>com.sun.tools.jxc.maven2</groupId>
            <artifactId>maven-jaxb-schemagen-plugin</artifactId>
            <executions>
              <execution>
                <phase>process-sources</phase>
                <configuration>
                  <destdir>${project.build.directory}/schema</destdir>
                  <srcdir>src/main/java/org/apache/camel/rest/model</srcdir>
                  <schemas>
                    <schema>
                      <namespace>http://activemq.apache.org/camel/schema/rest</namespace>
                      <file>camel-rest.xsd</file>
                    </schema>
                  </schemas>
                  <!--<verbose>false</verbose>-->
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <configuration>
              <artifactItems>
                <artifactItem>
                  <groupId>org.apache.camel</groupId>
                  <artifactId>camel-rest</artifactId>
                  <version>${pom.version}</version>
                  <type>xsd</type>
                  <overWrite>false</overWrite>
                  <outputDirectory>${project.build.directory}/schema</outputDirectory>
                  <destFileName>camel-rest.xsd</destFileName>
                </artifactItem>
              </artifactItems>
            </configuration>
          </plugin>
      </plugins>
    </pluginManagement>    
  </build>
  
  <profiles>
    <!-- The next three profiles are used to bypass the schemagen plugin on HP and IBM JDKs.

         TODO: Whenever Maven supports profile activations based on multiple properties, we
         should combine the on-ibmjdk and on-hpjdk profiles as they do exactly the same thing. -->
    <profile>
      <id>enable-schemagen</id>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>com.sun.tools.jxc.maven2</groupId>
            <artifactId>maven-jaxb-schemagen-plugin</artifactId>
            <executions>
              <execution>
                <phase>process-sources</phase>
                <goals>
                  <goal>generate</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>on-ibmjdk</id>
      <activation>
        <property>
          <name>java.vendor</name>
          <value>IBM Corporation</value>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
              <execution>
                <id>copy</id>
                <phase>generate-sources</phase>
                <goals>
                  <goal>copy</goal>
                </goals>
              </execution>
            </executions>
          </plugin>                  
          <plugin>
            <groupId>com.sun.tools.jxc.maven2</groupId>
            <artifactId>maven-jaxb-schemagen-plugin</artifactId>
          </plugin>
        </plugins>
      </build>
    </profile>    
    <profile>
      <id>on-hpjdk</id>
      <activation>
        <property>
          <name>java.vendor</name>
          <value>Hewlett-Packard Co.</value>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
              <execution>
                <id>copy</id>
                <phase>generate-sources</phase>
                <goals>
                  <goal>copy</goal>
                </goals>
              </execution>
            </executions>
          </plugin>                          
          <plugin>
            <groupId>com.sun.tools.jxc.maven2</groupId>
            <artifactId>maven-jaxb-schemagen-plugin</artifactId>
          </plugin>
        </plugins>
      </build>
    </profile>        
  </profiles>  
</project>
