<?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 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.apache.activemq</groupId>
    <artifactId>apollo-project</artifactId>
    <version>1.0-beta1</version>
  </parent>

  <groupId>org.apache.activemq</groupId>
  <artifactId>apollo-dto</artifactId>
  <version>1.0-beta1</version>
  <packaging>bundle</packaging>

  <name>${project.artifactId}</name>

  <properties>
  </properties>

  <dependencies>


    <dependency>
      <groupId>org.codehaus.jackson</groupId>
      <artifactId>jackson-core-asl</artifactId>
      <version>${jackson-version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.jackson</groupId>
      <artifactId>jackson-mapper-asl</artifactId>
      <version>${jackson-version}</version>
    </dependency>
    <dependency>
      <groupId>org.fusesource.hawtbuf</groupId>
      <artifactId>hawtbuf</artifactId>
      <version>${hawtbuf-version}</version>
      <optional>true</optional>
    </dependency>
    <dependency>
      <groupId>org.apache.activemq</groupId>
      <artifactId>apollo-util</artifactId>
      <version>1.0-beta1</version>
    </dependency>

    <!-- Testing Dependencies -->    
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>test</scope>
      <version>${junit-version}</version>
    </dependency>
    <dependency>
      <groupId>log4j</groupId>
      <artifactId>log4j</artifactId>
      <scope>test</scope>
      <version>${log4j-version}</version>
    </dependency>

  </dependencies>

  <build>
  
    <resources>
      <resource>
        <directory>target/schema</directory>
        <includes>
          <include>**/*</include>
        </includes>
      </resource>
      <resource>
        <directory>src/main/resources</directory>
        <includes>
          <include>**/*</include>
        </includes>
        <filtering>true</filtering>
      </resource>
    </resources>
      
    <plugins>

<!--

    jaxb schemagen plugin does not work quite well for our use case (classpath problems),
    so we're using it as an ant task (see below)
    try to switch back to this in some future version

-->
<!--
       <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>
              <includes>
                <include>**/jaxb/package-info.java</include>
                <include>**/jaxb/*Xml.java</include>
              </includes>
              <schemas>
                <schema>
                  <namespace>http://activemq.apache.org/schema/activemq/apollo</namespace>
                  <file>apollo-apollo.xsd</file>
                </schema>
              </schemas>
            </configuration>
            <goals>
              <goal>generate</goal>
            </goals> 
          </execution>
        </executions>
      </plugin>  
-->
       <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <id>generate schema</id>
            <phase>process-sources</phase>
            <configuration>
                <tasks>        
                <taskdef name="schemagen" classname="com.sun.tools.jxc.SchemaGenTask">
                    <classpath refid="maven.compile.classpath" />
                </taskdef>
                <mkdir dir="${project.build.directory}/schema" />
                <schemagen srcdir="${project.build.sourceDirectory}" destdir="${project.build.directory}/schema">
                    <schema namespace="http://activemq.apache.org/schema/activemq/apollo" file="apollo-apollo.xsd" />
                    <classpath refid="maven.compile.classpath" />
                    <include name="**/jaxb/package-info.java" />
                    <include name="**/jaxb/*Xml.java" />
                </schemagen>
                </tasks>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
        
        <dependencies>
          <dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-xjc</artifactId>
            <version>${xjc-version}</version>
            <exclusions>
              <exclusion>
                <groupId>com.sun.xml.bind</groupId>
                <artifactId>jaxb-impl</artifactId>
              </exclusion>
            </exclusions>            
          </dependency>  
          <dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-impl</artifactId>
            <version>${jaxb-version}</version>
            <exclusions>
              <exclusion>
                <groupId>javax.jws</groupId>
                <artifactId>jsr181-api</artifactId>
              </exclusion>
            </exclusions>
          </dependency>
        </dependencies>
      </plugin>

    </plugins>
  </build>
  
  <profiles>
    <profile>
      <id>jdk-1.5</id>
      <activation>
        <jdk>1.5</jdk>
      </activation>
      <dependencies>
        <dependency>
          <groupId>javax.xml.bind</groupId>
          <artifactId>jaxb-api</artifactId>
          <version>${jaxb-api-version}</version>
        </dependency>
        <dependency>
          <groupId>com.sun.xml.bind</groupId>
          <artifactId>jaxb-impl</artifactId>
          <version>${jaxb-version}</version>
        </dependency>
      </dependencies>
    </profile>
    
   <profile>
      <id>ibmjdk</id>
      <activation>
        <file>
          <exists>${java.home}/../lib/tools.jar</exists>
        </file>
      </activation>
      <build>
        <pluginManagement>
          <plugins>
            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-antrun-plugin</artifactId>
              <dependencies>
                <dependency>
                  <groupId>com.sun</groupId>
                  <artifactId>tools</artifactId>
                  <!--the real JDK version could be 1.5 or 1.6-->
                  <version>1.5.0</version>
                  <scope>system</scope>
                  <optional>true</optional>
                  <systemPath>${java.home}/../lib/tools.jar</systemPath>
                </dependency>
              </dependencies>
            </plugin>
          </plugins>
        </pluginManagement>
      </build>
    </profile>
  </profiles>

</project>
