<?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>ch.sbs.pipeline</groupId>
    <artifactId>modules-parent</artifactId>
    <version>1.8</version>
    <relativePath />
  </parent>
  
  <groupId>ch.sbs.pipeline</groupId>
  <artifactId>sbs-hyphenation-tables</artifactId>
  <version>1.23</version>
  <packaging>bundle</packaging>
  
  <name>DAISY Pipeline 2 module :: sbs-hyphenation-tables</name>
  <description>German hyphenation tables used by Swiss Library for the
  Blind, Visually Impaired and Print Disabled.</description>
  <url>https://github.com/sbsdev/sbs-hyphenation-tables</url>

  <licenses>
    <license>
      <name>GNU Lesser General Public License 3.0</name>
      <url>http://www.gnu.org/licenses/lgpl.html</url>
    </license>
  </licenses>

  <properties>
    <hyphen.version>2.6.0</hyphen.version>
    <jhyphen.version>0.1.5</jhyphen.version>
    <commons-io.version>2.2</commons-io.version>
    <tagNameFormat>v@{project.version}</tagNameFormat>
  </properties>
  
  <dependencies>
    <dependency>
      <groupId>org.daisy.bindings</groupId>
      <artifactId>jhyphen</artifactId>
      <version>${jhyphen.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.8.2</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>commons-io</groupId>
      <artifactId>commons-io</artifactId>
      <version>${commons-io.version}</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <scm>
    <connection>scm:git:git://github.com/sbsdev/sbs-hyphenation-tables.git</connection>
    <developerConnection>scm:git:ssh://git@github.com:sbsdev/sbs-hyphenation-tables.git</developerConnection>
    <url>https://github.com/sbsdev/sbs-hyphenation-tables/tree/master</url>
    <tag>v1.23</tag>
  </scm>

  <build>
    <resources>
      <resource>
        <directory>src/main/resources</directory>
        <excludes>
          <exclude>tables/*</exclude>
        </excludes>
      </resource>
      <resource>
        <directory>target/generated-resources/tables</directory>
        <targetPath>tables</targetPath>
      </resource>
    </resources>
    <plugins>
      <plugin>
        <groupId>com.github.maven-nar</groupId>
        <artifactId>nar-maven-plugin</artifactId>
        <executions>
          <execution>
            <phase>generate-resources</phase>
            <goals>
              <goal>nar-validate</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <phase>generate-resources</phase>
            <goals>
              <goal>unpack</goal>
            </goals>
            <configuration>
              <artifactItems>
                <artifactItem>
                  <groupId>org.daisy.libs</groupId>
                  <artifactId>hyphen</artifactId>
                  <classifier>${nar.aol}-shared</classifier>
                  <version>${hyphen.version}</version>
                  <type>nar</type>
                </artifactItem>
                <artifactItem>
                  <groupId>org.daisy.libs</groupId>
                  <artifactId>hyphen</artifactId>
                  <classifier>${nar.aol}-executable</classifier>
                  <version>${hyphen.version}</version>
                  <type>nar</type>
                </artifactItem>
              </artifactItems>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <id>process-whitelist</id>
            <phase>process-resources</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <target>
                <mkdir dir="target/build-classes" />
                <mkdir dir="target/generated-resources/tables" />
                <property name="build.compiler" value="extJavac" />
                <javac srcdir="src/build/java" destdir="target/build-classes" classpathref="maven.plugin.classpath" source="1.6" target="1.6" />
                <java classname="GenerateWhitelist">
                  <classpath>
                    <path refid="maven.plugin.classpath" />
                    <pathelement path="target/build-classes" />
                  </classpath>
                  <sysproperty key="jna.nosys" value="true" />
                </java>
                <apply executable="src/build/sh/whitelist-to-patterns.sh" failonerror="yes" dest="target/generated-resources">
                  <srcfile />
                  <targetfile />
                  <fileset dir="target/generated-resources" includes="whitelist_*.txt" />
                  <mapper type="glob" from="*.txt" to="*.dic" />
                </apply>
                <exec executable="cat" failonerror="yes">
                  <arg value="src/main/resources/tables/hyph_de_DE.dic" />
                  <arg value="target/generated-resources/whitelist_de.dic" />
                  <arg value="target/generated-resources/whitelist_de_SBS.dic" />
                  <redirector output="target/generated-resources/hyph_de_DE.dic" />
                </exec>
                <exec executable="cat" failonerror="yes">
                  <arg value="src/main/resources/tables/hyph_de_DE_OLDSPELL.dic" />
                  <arg value="target/generated-resources/whitelist_de_DE_OLDSPELL.dic" />
                  <redirector output="target/generated-resources/hyph_de_DE_OLDSPELL.dic" />
                </exec>
                <exec executable="target/dependency/bin/${nar.aol}/substrings.pl" failonerror="yes">
                  <arg value="target/generated-resources/hyph_de_DE.dic" />
                  <arg value="target/generated-resources/tables/hyph_de_DE.dic" />
                  <redirector output="/dev/null" />
                </exec>
                <exec executable="target/dependency/bin/${nar.aol}/substrings.pl" failonerror="yes">
                  <arg value="target/generated-resources/hyph_de_DE_OLDSPELL.dic" />
                  <arg value="target/generated-resources/tables/hyph_de_DE_OLDSPELL.dic" />
                  <redirector output="/dev/null" />
                </exec>
              </target>
            </configuration>
          </execution>
        </executions>
        <dependencies>
          <dependency>
            <groupId>org.daisy.bindings</groupId>
            <artifactId>jhyphen</artifactId>
            <version>${jhyphen.version}</version>
          </dependency>
          <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>${commons-io.version}</version>
          </dependency>
        </dependencies>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <systemPropertyVariables>
            <jna.nosys>true</jna.nosys>
          </systemPropertyVariables>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-bundle-plugin</artifactId>
        <configuration>
          <instructions>
            <Import-Package>org.daisy.pipeline.braille.libhyphen</Import-Package>
            <Service-Component>OSGI-INF/sbs-hyphenation-tables.xml</Service-Component>
          </instructions>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.vafer</groupId>
        <artifactId>jdeb</artifactId>
        <configuration>
          <dataSet>
            <data>
              <type>directory</type>
              <src>target/generated-resources/tables</src>
              <mapper>
                <type>perm</type>
                <prefix>/usr/share/hyphen</prefix>
              </mapper>
            </data>
          </dataSet>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>
