<?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>

  <parent>
    <groupId>org.daisy.pipeline.modules</groupId>
    <artifactId>tts-modules-parent</artifactId>
		<version>1.9</version>
		<relativePath>../../parent</relativePath>
  </parent>

  <version>2.0.0</version>
  <artifactId>tts-adapter-sapinative</artifactId>
  <packaging>bundle</packaging>

  <name>DAISY Pipeline 2 module :: TTS Adapter for SAPI</name>
  <description>Implementation of the TTS API for the SAPI native version</description>

  <dependencies>
    <dependency>
      <groupId>org.daisy.pipeline.modules</groupId>
      <artifactId>tts-common</artifactId>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>xmlunit</groupId>
      <artifactId>xmlunit</artifactId>
      <version>1.5</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <!-- note: Run mvn compile native:javah to generate again the C++ headers from -->
      <!-- the Java class. -->
      <plugin>
	<groupId>org.codehaus.mojo</groupId>
	<artifactId>native-maven-plugin</artifactId>
	<version>1.0-alpha-7</version>
	<extensions>true</extensions>
	<executions>
	  <execution>
	    <phase>none</phase>
	    <id>default-cli</id>
	    <goals>
	      <goal>javah</goal>
	    </goals>
	    <configuration>
	      <javahOS>windows</javahOS>
	      <javahOutputDirectory>../../native-libs/sapi-nar/src/main/jni</javahOutputDirectory>
	      <javahClassNames>
		<javahClassName>org.daisy.pipeline.tts.sapinative.SAPILib</javahClassName>
	      </javahClassNames>
	    </configuration>
	  </execution>
	</executions>
      </plugin>

      <!-- Extract the libraries from the NAR package -->
      <plugin>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <phase>generate-resources</phase>
            <goals>
              <goal>unpack</goal>
            </goals>
            <configuration>
              <artifactItems>
                <artifactItem>
                  <groupId>org.daisy.pipeline.bindings</groupId>
                  <artifactId>sapi-nar</artifactId>
                  <version>1.0.0</version>
                  <classifier>x64-Windows-msvc-jni</classifier>
                  <type>nar</type>
                </artifactItem>
		<artifactItem>
                  <groupId>org.daisy.pipeline.bindings</groupId>
                  <artifactId>sapi-nar</artifactId>
                  <version>1.0.0</version>
                  <classifier>x86-Windows-msvc-jni</classifier>
                  <type>nar</type>
                </artifactItem>
              </artifactItems>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
	<artifactId>maven-antrun-plugin</artifactId>
	<executions>
	  <execution>
	    <phase>generate-resources</phase>
	    <goals>
	      <goal>run</goal>
	    </goals>
	    <configuration>
              <tasks>
                <copy todir="target/generated-resources/">
                  <fileset dir="target/dependency">
                    <include name="**/*.dll" />
                  </fileset>
                </copy>
              </tasks>
	    </configuration>
	  </execution>
	</executions>
      </plugin>

      <!-- Package the dynamic library into an OSGI bundle -->
      <plugin>
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-bundle-plugin</artifactId>
        <configuration>
          <instructions>
	    <Service-Component>OSGI-INF/tts-service.xml</Service-Component>
	    <Export-Package />
          </instructions>
        </configuration>
        <executions>
          <execution>
            <id>default-bundle</id>
            <phase>none</phase>
          </execution>
          <execution>
            <id>windows-bundle</id>
            <phase>package</phase>
            <goals>
              <goal>bundle</goal>
            </goals>
            <configuration>
              <instructions>
		<Bundle-NativeCode>
		  x86/sapinative.dll;osname=Win32;processor=x86,
		  x64/sapinative.dll;osname=Win32;processor=x86-64
		</Bundle-NativeCode>
                <Include-Resource>
                  OSGI-INF/tts-service.xml=src/main/resources/OSGI-INF/tts-service.xml,
		  transform-ssml.xsl=src/main/resources/transform-ssml.xsl,
                  x64/sapinative.dll=target/generated-resources/lib/x64-Windows-msvc/jni/sapi-nar.dll,
		  x86/sapinative.dll=target/generated-resources/lib/x86-Windows-msvc/jni/sapi-nar.dll
                </Include-Resource>
              </instructions>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
      <id>notester</id>
      <build>
	<plugins>
	  <plugin>
	    <artifactId>maven-surefire-plugin</artifactId>
	    <configuration>
	      <excludes>
		<exclude>**/SAPINativeTest.java</exclude>
	      </excludes>
	    </configuration>
	  </plugin>
	</plugins>
      </build>
    </profile>
    <profile>
      <id>tester</id>
    </profile>
  </profiles>

</project>
