<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>com.webcohesion.enunciate</groupId>
    <artifactId>enunciate-examples</artifactId>
    <version>2.14.0</version>
  </parent>

  <artifactId>enunciate-examples-contract-first</artifactId>
  <name>Enunciate - Contract-First API Example</name>
  <description>Enunciate Example: Contract-First API.</description>
  <packaging>war</packaging>

  <build>
    <plugins>
      <plugin>
        <groupId>com.github.ekryd.echo-maven-plugin</groupId>
        <artifactId>echo-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>warn-limited-tests</id>
            <goals>
              <goal>echo</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <skip>${activate.full.tests}</skip>
          <level>WARNING</level>
          <message>You are building the ${project.artifactId} project without running the full test suite, which includes compiling and running the Enunciate-generated client-side code. In order to run the full suite, you will need to do a bunch of tricky environment setup. Enable the 'enunciate-full-tests' profile to start your path down the rabbit hole.</message>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>jaxws-maven-plugin</artifactId>
        <executions>
          <execution>
            <phase>generate-sources</phase>
            <goals>
              <goal>wsimport</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <wsdlDirectory>src/main/contract</wsdlDirectory>
          <!--turn off wsimport compilation-->
          <sourceDestDir>${project.build.directory}/generated-sources/api</sourceDestDir>
          <!-- Needed with JAXP 1.5 -->
          <vmArgs>
            <vmArg>-Djavax.xml.accessExternalSchema=all</vmArg>
          </vmArgs>
        </configuration>
      </plugin>
      <plugin>
        <!--now we need to add the generated sources we're testing to the test classpath-->
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <executions>
          <execution>
            <phase>validate</phase>
            <goals>
              <goal>add-source</goal>
            </goals>
            <configuration>
              <sources>
                <source>${project.build.directory}/generated-sources</source>
              </sources>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>com.webcohesion.enunciate</groupId>
        <artifactId>enunciate-maven-plugin</artifactId>
        <version>${enunciate.version}</version>
        <executions>
          <execution>
            <id>assemble</id>
            <goals>
              <goal>assemble</goal>
            </goals>
            <configuration>
              <project-extensions>
                <extension>java-xml-client</extension>
              </project-extensions>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <!--skip deploy (this is just a test module)-->
        <artifactId>maven-deploy-plugin</artifactId>
        <configuration>
          <skip>true</skip>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <dependencies>
    <dependency>
      <groupId>com.sun.xml.ws</groupId>
      <artifactId>jaxws-rt</artifactId>
      <version>${jaxws-ri-rt.version}</version>
    </dependency>

    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>javax.servlet-api</artifactId>

      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.13.1</version>

      <scope>test</scope>
    </dependency>
  </dependencies>

  <profiles>
    <profile>
      <id>full-integration-tests</id>
      <activation>
        <property>
          <name>activate.full.tests</name>
          <value>true</value>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-enforcer-plugin</artifactId>
            <executions>
              <execution>
                <id>require.gcc</id>
                <phase>validate</phase>
                <goals>
                  <goal>enforce</goal>
                </goals>
                <configuration>
                  <rules>
                    <requireProperty>
                      <property>gcc.executable</property>
                      <message>In order to build the ${project.artifactId} module, you must have gcc installed along with libxml and gnustep.
You will need to provide the Enunciate build with a handle to those things as follows:

* The 'gcc.executable' build property must provide the path to your 'gcc' executable.
* The 'libxml.config.executable' build property must provide your libxml compiler flags
  and library includes.
* The 'gnustep.config.executable' build property must provide your gnustep compiler flags
  and library includes.

Recommended configuration in settings.xml:

&lt;settings&gt;
  &lt;profiles&gt;
    &lt;profile&gt;
      &lt;id&gt;gcc-installed&lt;/id&gt;
      &lt;activation&gt;
        &lt;activeByDefault&gt;true&lt;/activeByDefault&gt;
      &lt;/activation&gt;
      &lt;properties&gt;
        &lt;gcc.executable&gt;gcc&lt;/gcc.executable&gt;
        &lt;libxml.config.executable&gt;xml2-config&lt;/libxml.config.executable&gt;
        &lt;gnustep.config.executable&gt;gnustep-config&lt;/gnustep.config.executable&gt;
      &lt;/properties&gt;
    &lt;/profile&gt;
  &lt;/profiles&gt;
&lt;/settings&gt;</message>
                    </requireProperty>
                  </rules>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <executions>
              <execution>
                <!--as part of the tests, we're going to make sure the c and obj-c code compiles.-->
                <id>compile-obj-c</id>
                <phase>test-compile</phase>
                <configuration>
                  <tasks>
                    <property name="gcc.executable" value="${gcc.executable}"/>
                    <property name="libxml.config.executable" value="${libxml.config.executable}"/>
                    <property name="gnustep.config.executable" value="${gnustep.config.executable}"/>
                    <property name="project.build.directory" value="${project.build.directory}"/>
                    <property name="project.artifactId" value="${project.artifactId}"/>

                    <ant antfile="${basedir}/gcc-compile.xml">
                      <target name="gcc"/>
                    </ant>
                  </tasks>
                </configuration>
                <goals>
                  <goal>run</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
