<?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/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <artifactId>zanata-common-api</artifactId>
  <name>Zanata Common API</name>
  <description>Zanata API definitions</description>
  <parent>
    <groupId>org.zanata</groupId>
    <artifactId>api</artifactId>
    <version>4.4.3</version>
  </parent>
  <packaging>jar</packaging>

  <!-- Connection URLs repeated as workaround for https://issues.apache.org/jira/browse/MPIR-234 -->
  <scm>
    <connection>scm:git:https://github.com/zanata/zanata-platform.git</connection>
    <developerConnection>scm:git:git@github.com:zanata/zanata-platform.git</developerConnection>
    <tag>platform-4.4.3</tag>
  </scm>

  <properties>
    <enunciate.version>2.9.1</enunciate.version>
  </properties>

  <build>
    <plugins>

      <plugin>
        <artifactId>maven-enforcer-plugin</artifactId>
        <configuration>
          <rules>
            <bannedDependencies>
              <excludes combine.children="append">
                <!-- For GWT compatibility, stick to guava -->
                <exclude>commons-lang:commons-lang</exclude>
                <exclude>org.apache.commons:commons-lang3</exclude>
              </excludes>
            </bannedDependencies>
          </rules>
        </configuration>
      </plugin>

      <!-- package up source files for GWT: http://stackoverflow.com/a/8731652/14379 -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-source-plugin</artifactId>
        <version>3.0.1</version>
        <executions>
          <execution>
            <id>attach-sources</id>
            <phase>package</phase>
            <goals>
              <goal>jar-no-fork</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>com.webcohesion.enunciate</groupId>
        <artifactId>enunciate-slim-maven-plugin</artifactId>
      </plugin>

      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>jaxb2-maven-plugin</artifactId>
        <version>1.3</version>
        <configuration>
          <includes>
            <include>**/org/zanata/common/*.java</include>
            <include>**/org/zanata/rest/dto/**/*.java</include>
          </includes>
        </configuration>
      </plugin>

      <!-- Mandatory plugins for using Spock -->
      <plugin>
        <groupId>org.codehaus.gmaven</groupId>
        <artifactId>gmaven-plugin</artifactId>
        <executions>
          <execution>
            <id>setup</id>
            <phase>initialize</phase>
            <goals>
              <goal>execute</goal>
            </goals>
            <configuration>
              <source>project.properties["version-as-java-package"] = "v" + project.version.replaceAll("[.-]", "_")</source>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>

    <pluginManagement>
      <plugins>
        <plugin>
          <!--
             Docs will be generated in target/site/rest-api-docs/.
           -->
          <groupId>com.webcohesion.enunciate</groupId>
          <artifactId>enunciate-slim-maven-plugin</artifactId>
          <version>${enunciate.version}</version>
          <configuration>
            <!-- Required, but apparently unused -->
            <enunciateArtifactId>zanata-api</enunciateArtifactId>
            <configFile>etc/enunciate/enunciate.xml</configFile>
            <docsSubdir>rest-api-docs</docsSubdir>
          </configuration>
          <dependencies>
            <dependency>
              <groupId>com.webcohesion.enunciate</groupId>
              <artifactId>enunciate-docs</artifactId>
              <version>${enunciate.version}</version>
            </dependency>
            <dependency>
              <groupId>com.webcohesion.enunciate</groupId>
              <artifactId>enunciate-jackson1</artifactId>
              <version>${enunciate.version}</version>
            </dependency>
            <dependency>
              <groupId>com.webcohesion.enunciate</groupId>
              <artifactId>enunciate-jaxb</artifactId>
              <version>${enunciate.version}</version>
            </dependency>
            <dependency>
              <groupId>com.webcohesion.enunciate</groupId>
              <artifactId>enunciate-jaxrs</artifactId>
              <version>${enunciate.version}</version>
            </dependency>
          </dependencies>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>

  <reporting>
    <plugins>
      <plugin>
        <groupId>com.webcohesion.enunciate</groupId>
        <artifactId>enunciate-slim-maven-plugin</artifactId>
      </plugin>
    </plugins>
  </reporting>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
    </dependency>
    <dependency>
      <groupId>org.jboss.spec.javax.ws.rs</groupId>
      <artifactId>jboss-jaxrs-api_2.0_spec</artifactId>
    </dependency>
    <dependency>
      <groupId>com.webcohesion.enunciate</groupId>
      <artifactId>enunciate-core-annotations</artifactId>
      <version>${enunciate.version}</version>
      <exclusions>
        <exclusion>
          <groupId>javax.annotation</groupId>
          <artifactId>jsr250-api</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-all</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.google.code.findbugs</groupId>
      <artifactId>findbugs-annotations</artifactId>
    </dependency>
    <dependency>
      <groupId>com.google.code.findbugs</groupId>
      <artifactId>jsr305</artifactId>
    </dependency>
    <dependency>
      <groupId>net.jcip</groupId>
      <artifactId>jcip-annotations</artifactId>
    </dependency>
    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-validator</artifactId>
      <exclusions>
        <exclusion>
          <groupId>xml-apis</groupId>
          <artifactId>xml-apis</artifactId>
        </exclusion>
      </exclusions>
      <!--this is needed for now. Aftet AS7 upgrade may need to revisit this-->
      <version>5.2.3.Final</version>
    </dependency>

    <dependency>
      <groupId>javax.validation</groupId>
      <artifactId>validation-api</artifactId>
      <version>1.1.0.Final</version>
    </dependency>

    <dependency>
      <!-- we still need this because the annotation must present in the
       interface/dto otherwise RESTEasy server implementation won't work-->
      <groupId>org.jboss.resteasy</groupId>
      <artifactId>resteasy-multipart-provider</artifactId>
      <exclusions>
        <exclusion>
          <groupId>com.sun.xml.bind</groupId>
          <artifactId>jaxb-impl</artifactId>
        </exclusion>
        <exclusion>
          <groupId>commons-logging</groupId>
          <artifactId>commons-logging</artifactId>
        </exclusion>
        <exclusion>
          <groupId>javax.servlet</groupId>
          <artifactId>servlet-api</artifactId>
        </exclusion>
        <exclusion>
          <groupId>javax.annotation</groupId>
          <artifactId>jsr250-api</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>org.codehaus.jackson</groupId>
      <artifactId>jackson-core-asl</artifactId>
    </dependency>

    <dependency>
      <groupId>org.codehaus.jackson</groupId>
      <artifactId>jackson-mapper-asl</artifactId>
    </dependency>

    <dependency>
      <groupId>org.codehaus.jackson</groupId>
      <artifactId>jackson-xc</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
    </dependency>
    <dependency>
      <groupId>org.spockframework</groupId>
      <artifactId>spock-core</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
    </dependency>

    <dependency>
      <groupId>org.hamcrest</groupId>
      <artifactId>hamcrest-core</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.hamcrest</groupId>
      <artifactId>hamcrest-library</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>javax.xml.stream</groupId>
      <artifactId>stax-api</artifactId>
    </dependency>

    <dependency>
      <groupId>javax.xml.bind</groupId>
      <artifactId>jaxb-api</artifactId>
    </dependency>

  </dependencies>

  <profiles>
    <profile>
      <id>withShade</id>
      <activation>
        <property>
          <name>skipShade</name>
          <value>!true</value>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <executions>
              <execution>
                <id>compat</id>
                <phase>package</phase>
                <goals>
                  <goal>shade</goal>
                </goals>
                <configuration>
                  <shadedArtifactAttached>true</shadedArtifactAttached>
                  <shadedClassifierName>compat</shadedClassifierName>
                  <artifactSet>
                    <includes>
                      <include>org.zanata:zanata-common-api</include>
                    </includes>
                  </artifactSet>
                  <relocations>
                    <relocation>
                      <pattern>org.zanata</pattern>
                      <shadedPattern>org.zanata.apicompat</shadedPattern>
                    </relocation>
                  </relocations>
                </configuration>
              </execution>
              <execution>
                <id>versioned-compat</id>
                <phase>package</phase>
                <goals>
                  <goal>shade</goal>
                </goals>
                <configuration>
                  <shadedArtifactAttached>true</shadedArtifactAttached>
                  <shadedClassifierName>compat_${version-as-java-package}</shadedClassifierName>
                  <artifactSet>
                    <includes>
                      <include>org.zanata:zanata-common-api</include>
                    </includes>
                  </artifactSet>
                  <relocations>
                    <relocation>
                      <pattern>org.zanata</pattern>
                      <shadedPattern>org.zanata.${version-as-java-package}</shadedPattern>
                    </relocation>
                  </relocations>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

</project>
