<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.codehaus.enunciate</groupId>
    <artifactId>enunciate-parent</artifactId>
    <version>1.30.1</version>
  </parent>

  <artifactId>enunciate-php</artifactId>
  <name>Enunciate - PHP Module</name>
  <description>The Enunciate PHP module generates the PHP client code for accessing the Enunciate services.</description>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-enforcer-plugin</artifactId>
        <executions>
          <execution>
            <id>require.php.or.skip</id>
            <phase>validate</phase>
            <goals>
              <goal>enforce</goal>
            </goals>
            <configuration>
              <rules>
                <requireProperty>
                  <property>php.executable</property>
                  <message>In order to build the PHP module, you must have PHP installed.
Then, define a profile in your settings.xml file that defines the path to your 'php' executable in the property 'php.executable'.
If you just want to skip the PHP tests, set the value of the property 'php.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 PHP 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>
                <path id="enunciate.classpath">
                  <path refid="maven.test.classpath" />
                  <pathelement location="${java.home}/../lib/tools.jar" />
                </path>

                <taskdef name="enunciate" classname="org.codehaus.enunciate.main.EnunciateTask">
                  <classpath refid="enunciate.classpath" />
                </taskdef>

                <mkdir dir="${project.build.directory}/enunciate/gen" />
                <mkdir dir="${project.build.directory}/enunciate/compile" />
                <mkdir dir="${project.build.directory}/jsontests"/>

                <enunciate target="compile" basedir="${basedir}/src/test/schema"
                           generateDir="${project.build.directory}/enunciate/gen"
                           compileDir="${project.build.directory}/enunciate/compile"
                           configFile="${project.basedir}/enunciate.xml">
                  <include name="**/*.java" />
                  <classpath refid="enunciate.classpath" />
                </enunciate>

                <copy todir="${project.build.directory}/enunciate/gen/php" file="${project.build.testSourceDirectory}/../php/processjson.php"/>
                <copy todir="${project.build.directory}/enunciate/gen/php" file="${project.build.testSourceDirectory}/../php/processxml.php"/>
              </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.php.tests</name>
              <value>${php.executable}</value>
            </property>
            <property>
              <name>php.execuable</name>
              <value>${php.executable}</value>
            </property>
            <property>
              <name>processjson.php</name>
              <value>${project.build.directory}/enunciate/gen/php/processjson.php</value>
            </property>
            <property>
              <name>processxml.php</name>
              <value>${project.build.directory}/enunciate/gen/php/processxml.php</value>
            </property>
            <property>
              <name>json.tempdir</name>
              <value>${project.build.directory}/jsontests</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/schema</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-core</artifactId>
      <version>${project.version}</version>

      <classifier>tests</classifier>
      <scope>test</scope>
    </dependency>

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

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

    <dependency>
      <groupId>org.codehaus.jackson</groupId>
      <artifactId>jackson-jaxrs</artifactId>

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

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

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

  </dependencies>


</project>
