<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-parent</artifactId>
    <version>2.0.0</version>
  </parent>

  <artifactId>enunciate-c-xml-client</artifactId>
  <name>Enunciate - C XML Client Module</name>
  <description>The Enunciate C XML client module generates the C client code for accessing the XML components of the Web service API.</description>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-enforcer-plugin</artifactId>
        <executions>
          <execution>
            <id>require.gcc.or.skip</id>
            <phase>validate</phase>
            <goals>
              <goal>enforce</goal>
            </goals>
            <configuration>
              <rules>
                <requireProperty>
                  <property>gcc.executable</property>
                  <message>In order to build the C module, you must have gcc installed along with libxml.
Define a profile in your settings.xml file that defines the path to your 'gcc'
executable in the property 'gcc.executable'. Also set a property named 'libxml.config.executable' that
specifies the executable that exposes your libxml compiler flags and library includes.
If you just want to skip the C tests, set the value of the property 'gcc.executable' to be 'true'.
(And don't ask any questions about why that works. Maven mess.)</message>
                </requireProperty>
              </rules>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <!--
        we need to generate some C client-side classes for testing purposes.
        we'll use the Enunciate ant task to do it.
        -->
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <id>enunciate</id>
            <phase>generate-test-resources</phase>
            <configuration>
              <tasks>
                <taskdef name="enunciate" classname="com.webcohesion.enunciate.EnunciateTask">
                  <classpath refid="maven.test.classpath" />
                </taskdef>

                <mkdir dir="${project.build.directory}/ctests"/>

                <enunciate basedir="${basedir}/src/test/samples" configFile="${basedir}/src/test/samples/enunciate.xml" buildDir="${project.build.directory}/enunciate">
                  <include name="**/*.java" />
                  <classpath refid="maven.test.classpath" />
                </enunciate>

                <copy todir="${project.build.directory}/enunciate/c-xml-client/src" file="${project.build.testSourceDirectory}/../c/processxml.c"/>
              </tasks>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
          <execution>
            <id>compile-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="project.build.directory" value="${project.build.directory}"/>
                <ant antfile="${basedir}/gcc-compile.xml">
                  <target name="gcc"/>
                </ant>
              </tasks>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <systemProperties>
            <property>
              <name>skip.c.tests</name>
              <value>${gcc.executable}</value>
            </property>
            <property>
              <name>processxml.exe</name>
              <value>${project.build.directory}/ctests/processxml</value>
            </property>
            <property>
              <name>xml.tempdir</name>
              <value>${project.build.directory}/ctests</value>
            </property>
          </systemProperties>
        </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>
            <id>add-test-source</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>add-test-source</goal>
            </goals>
            <configuration>
              <sources>
                <source>${basedir}/src/test/samples</source>
              </sources>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <dependencies>
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>enunciate-core</artifactId>
      <version>${project.version}</version>
    </dependency>

    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>enunciate-jaxb</artifactId>
      <version>${project.version}</version>
    </dependency>

    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>enunciate-jaxrs</artifactId>
      <version>${project.version}</version>
    </dependency>

    <dependency>
      <groupId>org.freemarker</groupId>
      <artifactId>freemarker</artifactId>
    </dependency>

    <dependency>
      <groupId>joda-time</groupId>
      <artifactId>joda-time</artifactId>

      <!--for testing the xmladapters only-->
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>enunciate-rt-util</artifactId>
      <version>${project.version}</version>

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

  </dependencies>


</project>
