<?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">
  <parent>
    <artifactId>jaxrs-integration-parent</artifactId>
    <groupId>org.jboss.errai</groupId>
    <version>3.1.1.Final</version>
  </parent>
  <modelVersion>4.0.0</modelVersion>

  <artifactId>errai-jaxrs-client</artifactId>
  <name>Errai::JAX-RS::Client</name>

  <build>
    <testOutputDirectory>war/WEB-INF/classes</testOutputDirectory>
    <resources>
      <resource>
        <directory>target/generated-sources</directory>
      </resource>
      <resource>
        <directory>src/main/java</directory>
      </resource>
      <resource>
        <directory>src/main/resources</directory>
      </resource>
    </resources>
    <testResources>
      <testResource>
        <directory>src/main/java</directory>
      </testResource>
      <testResource>
        <directory>src/test/resources</directory>
      </testResource>
    </testResources>
    <plugins>
      <!-- exclude JAX-RS API overrides as they'd pollute the server classpath 
        in GWTTestCases -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <excludes>
            <exclude>**/javax/ws/rs/core/*.java</exclude>
          </excludes>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <configuration>
          <excludes>**/core/**,**/ext/**</excludes>
        </configuration>
        <executions>
          <execution>
            <id>unpack</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>unpack</goal>
            </goals>
            <configuration>
              <artifactItems>
                <artifactItem>
                  <!-- Do not put version here. Managed version will be used. -->
                  <groupId>org.jboss.spec.javax.ws.rs</groupId>
                  <artifactId>jboss-jaxrs-api_1.1_spec</artifactId>
                  <classifier>sources</classifier>
                  <overWrite>false</overWrite>
                  <outputDirectory>target/generated-sources/javax/ws/rs/super</outputDirectory>
                </artifactItem>
              </artifactItems>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <executions>
          <execution>
            <goals>
              <goal>test-jar</goal>
            </goals>
            <configuration>
              <includes>
                <include>**/AbstractErraiJaxrsTest.*</include>
              </includes>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <dependencies>
    <dependency>
      <groupId>org.jboss.errai</groupId>
      <artifactId>errai-marshalling</artifactId>
    </dependency>

    <!-- Must come after errai-common is inherited for patched JUnitShell -->
    <dependency>
      <groupId>com.google.gwt</groupId>
      <artifactId>gwt-user</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>com.google.gwt</groupId>
      <artifactId>gwt-dev</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>javax.validation</groupId>
      <artifactId>validation-api</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>javax.validation</groupId>
      <artifactId>validation-api</artifactId>
      <classifier>sources</classifier>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.jboss.resteasy</groupId>
      <artifactId>jaxrs-api</artifactId>
    </dependency>

    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava-gwt</artifactId>
    </dependency>

    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-log4j12</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.jboss.errai</groupId>
      <artifactId>errai-ioc</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.jboss.errai</groupId>
      <artifactId>errai-jaxrs-provider</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.jboss.resteasy</groupId>
      <artifactId>resteasy-jaxrs</artifactId>
      <scope>test</scope>
    </dependency>

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

  <profiles>
    <profile>
      <id>integration-test</id>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-failsafe-plugin</artifactId>
            <configuration>
              <skipTests>false</skipTests>
              <additionalClasspathElements>
                <additionalClasspathElement>${basedir}/${testOutputDirectory}/</additionalClasspathElement>
                <additionalClasspathElement>${basedir}/src/main/java/</additionalClasspathElement>
                <additionalClasspathElement>${basedir}/src/test/java/</additionalClasspathElement>
              </additionalClasspathElements>
              <useManifestOnlyJar>false</useManifestOnlyJar>
              <forkMode>pertest</forkMode>
              <argLine>${argLine} -Xmx1500m -Derrai.devel.nocache=true</argLine>

              <systemProperties>
                <!-- Must disable long polling for automated tests to succeed -->
                <property>
                  <name>errai.hosted_mode_testing</name>
                  <value>true</value>
                </property>
                <!-- Do not accidently package server test marshallers when building Errai -->
                <property>
                  <name>errai.marshalling.server.classOutput.enabled</name>
                  <value>false</value>
                </property>
              </systemProperties>

              <includes>
                <include>**/AllJaxrsTests.java</include>
              </includes>
            </configuration>
          </plugin>
          <plugin>
            <groupId>org.jboss.errai</groupId>
            <artifactId>jacoco-gwt-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>jacoco-initialize</id>
                <phase>initialize</phase>
                <goals>
                  <goal>prepare-agent</goal>
                </goals>
              </execution>
              <execution>
                <id>jacoco-site</id>
                <phase>site</phase>
                <goals>
                  <goal>report</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
