<?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>modules-parent</artifactId>
    <version>1.15.3</version>
    <relativePath>../../parent/</relativePath>
  </parent>

  <groupId>org.daisy.pipeline.modules.braille</groupId>
  <artifactId>libhyphen-utils</artifactId>
  <version>3.4.1</version>
  <packaging>bundle</packaging>

  <name>DP2 Braille Modules :: libhyphen-utils</name>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.daisy.libs</groupId>
        <artifactId>hyphen</artifactId>
        <version>2.8.8-p1</version>
        <type>nar</type>
      </dependency>
      <dependency>
        <groupId>ch.sbs.pipeline</groupId>
        <artifactId>sbs-hyphenation-tables</artifactId>
        <version>1.23</version>
      </dependency>
      <dependency>
        <groupId>no.nlb</groupId>
        <artifactId>spell-no-patterns</artifactId>
        <version>1.1.0</version>
      </dependency>
      <dependency>
        <groupId>fi.celia</groupId>
        <artifactId>celia-hyphenation-tables</artifactId>
        <!-- this is a snapshot because Celia currently has no one who can make a proper release -->
        <version>1.5.1</version>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>
    <dependency>
      <groupId>org.daisy.pipeline</groupId>
      <artifactId>common-utils</artifactId>
    </dependency>
    <dependency>
      <groupId>org.daisy.bindings</groupId>
      <artifactId>jhyphen</artifactId>
    </dependency>
    <dependency>
      <groupId>org.daisy.pipeline.modules.braille</groupId>
      <artifactId>braille-common</artifactId>
    </dependency>
    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
    </dependency>
    <dependency>
      <groupId>org.daisy.libs</groupId>
      <artifactId>saxon-he</artifactId>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
    </dependency>
  </dependencies>
  
  <properties>
    <expose-services>
      org.daisy.pipeline.braille.libhyphen.impl.LibhyphenJnaImpl,
      org.daisy.pipeline.braille.libhyphen.impl.LibhyphenTableRegistry,
      org.daisy.pipeline.braille.libhyphen.impl.LibhyphenTablePath_libreoffice_hyphen_tables
    </expose-services>
  </properties>

  <build>
    <resources>
      <resource>
        <directory>src/main/resources</directory>
        <excludes>
          <exclude>META-INF/catalog.xml</exclude>
        </excludes>
      </resource>
      <!--
          this is only needed for testing without OSGi, actual inclusion of resources is handled by maven-bundle-plugin
      -->
      <resource>
        <directory>${project.build.directory}/dependency/libhyphen/lib/i386-Linux-gpp/shared/</directory>
        <targetPath>native/linux/x86/</targetPath>
      </resource>
      <resource>
        <directory>${project.build.directory}/dependency/libhyphen/lib/amd64-Linux-gpp/shared/</directory>
        <targetPath>native/linux/x86_64/</targetPath>
      </resource>
      <resource>
        <directory>${project.build.directory}/dependency/libhyphen/lib/x86_64-MacOSX-gpp/shared/</directory>
        <targetPath>native/macosx/x86_64/</targetPath>
      </resource>
      <resource>
        <directory>${project.build.directory}/dependency/libhyphen/lib/aarch64-MacOSX-gpp/shared/</directory>
        <targetPath>native/macosx/aarch64/</targetPath>
      </resource>
      <resource>
        <directory>${project.build.directory}/dependency/libhyphen/bin/i686-w64-mingw32-gpp/</directory>
        <targetPath>native/windows/x86/</targetPath>
      </resource>
      <resource>
        <directory>${project.build.directory}/dependency/libhyphen/bin/x86_64-w64-mingw32-gpp/</directory>
        <targetPath>native/windows/x86_64/</targetPath>
      </resource>
    </resources>
    <plugins>
      <plugin>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <id>unpack-libhyphen</id>
            <phase>generate-resources</phase>
            <goals>
              <goal>unpack</goal>
            </goals>
            <configuration>
              <outputDirectory>${project.build.directory}/dependency/libhyphen</outputDirectory>
              <artifactItems>
                <artifactItem>
                  <groupId>org.daisy.libs</groupId>
                  <artifactId>hyphen</artifactId>
                  <classifier>i386-Linux-gpp-shared</classifier>
                  <type>nar</type>
                </artifactItem>
                <artifactItem>
                  <groupId>org.daisy.libs</groupId>
                  <artifactId>hyphen</artifactId>
                  <classifier>amd64-Linux-gpp-shared</classifier>
                  <type>nar</type>
                </artifactItem>
                <artifactItem>
                  <groupId>org.daisy.libs</groupId>
                  <artifactId>hyphen</artifactId>
                  <classifier>x86_64-MacOSX-gpp-shared</classifier>
                  <type>nar</type>
                </artifactItem>
                <artifactItem>
                  <groupId>org.daisy.libs</groupId>
                  <artifactId>hyphen</artifactId>
                  <classifier>aarch64-MacOSX-gpp-shared</classifier>
                  <type>nar</type>
                </artifactItem>
                <artifactItem>
                  <groupId>org.daisy.libs</groupId>
                  <artifactId>hyphen</artifactId>
                  <classifier>i686-w64-mingw32-gpp-executable</classifier>
                  <type>nar</type>
                </artifactItem>
                <artifactItem>
                  <groupId>org.daisy.libs</groupId>
                  <artifactId>hyphen</artifactId>
                  <classifier>x86_64-w64-mingw32-gpp-executable</classifier>
                  <type>nar</type>
                </artifactItem>
              </artifactItems>
              <excludes>
                **/substrings.pl
              </excludes>
            </configuration>
          </execution>
          <execution>
            <id>unpack-sbs-tables</id>
            <phase>generate-resources</phase>
            <goals>
              <goal>unpack</goal>
            </goals>
            <configuration>
              <outputDirectory>${project.build.directory}/dependency/sbs-hyphenation-tables</outputDirectory>
              <artifactItems>
                <artifactItem>
                  <groupId>ch.sbs.pipeline</groupId>
                  <artifactId>sbs-hyphenation-tables</artifactId>
                </artifactItem>
              </artifactItems>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.daisy.pipeline.build</groupId>
        <artifactId>ds-to-spi-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>generate-spi-classes</id>
            <phase>process-sources</phase>
            <goals>
              <goal>generate-spi-classes</goal>
            </goals>
            <configuration>
              <includes>
                ${expose-services},
                org.daisy.pipeline.braille.libhyphen.impl.mac.LibhyphenNativePathForMacOS,
                org.daisy.pipeline.braille.libhyphen.impl.linux.LibhyphenNativePathForLinux,
                org.daisy.pipeline.braille.libhyphen.impl.windows.LibhyphenNativePathForWindows
              </includes>
            </configuration>
          </execution>
          <execution>
            <id>generate-spi-test-classes</id>
            <phase>process-test-sources</phase>
            <goals>
              <goal>generate-spi-test-classes</goal>
            </goals>
            <configuration>
              <includes>
                TablePath
              </includes>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-bundle-plugin</artifactId>
        <configuration>
          <instructions>
            <Import-Package>
              net.sf.saxon.*;version="${saxon.versionRange}",
              !org.daisy.common.spi,
              *
            </Import-Package>
            <Private-Package>
              ${generated-packages}
              org.daisy.pipeline.braille.libhyphen.impl
            </Private-Package>
            <!--
                exclude native and META-INF/services/org.daisy.pipeline.braille.common.NativePath
            -->
            <Include-Resource>
              src/main/resources/,
              tables/hyph_de_DE.dic
               =target/dependency/sbs-hyphenation-tables/tables/hyph_de_DE.dic,
              META-INF/services
               =target/generated-resources/spi/META-INF/services,
              META-INF/services/org.daisy.pipeline.braille.common.NativePath;literal
               =''
            </Include-Resource>
          </instructions>
        </configuration>
        <executions>
          <execution>
            <id>linux-bundle</id>
            <phase>generate-test-resources</phase>
            <goals>
              <goal>bundle</goal>
            </goals>
            <configuration>
              <classifier>linux</classifier>
              <instructions>
                <_dsannotations>org.daisy.pipeline.braille.libhyphen.impl.linux.LibhyphenNativePathForLinux</_dsannotations>
                <Bundle-SymbolicName>org.daisy.pipeline.modules.braille.libhyphen-utils-linux</Bundle-SymbolicName>
                <Export-Package />
                <Private-Package>
                  org.daisy.pipeline.braille.libhyphen.impl.linux
                </Private-Package>
                <Include-Resource>
                  META-INF/services/org.daisy.pipeline.braille.common.NativePath;literal
                   ='org.daisy.pipeline.braille.libhyphen.impl.linux.LibhyphenNativePathForLinux_SPI',
                  native/linux/x86=target/dependency/libhyphen/lib/i386-Linux-gpp/shared,
                  native/linux/x86_64=target/dependency/libhyphen/lib/amd64-Linux-gpp/shared
                </Include-Resource>
              </instructions>
            </configuration>
          </execution>
          <execution>
            <id>mac-bundle</id>
            <phase>generate-test-resources</phase>
            <goals>
              <goal>bundle</goal>
            </goals>
            <configuration>
              <classifier>mac</classifier>
              <instructions>
                <_dsannotations>org.daisy.pipeline.braille.libhyphen.impl.mac.LibhyphenNativePathForMacOS</_dsannotations>
                <Bundle-SymbolicName>org.daisy.pipeline.modules.braille.libhyphen-utils-mac</Bundle-SymbolicName>
                <Export-Package />
                <Private-Package>
                  org.daisy.pipeline.braille.libhyphen.impl.mac
                </Private-Package>
                <Include-Resource>
                  META-INF/services/org.daisy.pipeline.braille.common.NativePath;literal
                   ='org.daisy.pipeline.braille.libhyphen.impl.mac.LibhyphenNativePathForMacOS_SPI',
                  native/macosx/x86_64=target/dependency/libhyphen/lib/x86_64-MacOSX-gpp/shared,
                  native/macosx/aarch64=target/dependency/libhyphen/lib/aarch64-MacOSX-gpp/shared
                </Include-Resource>
              </instructions>
            </configuration>
          </execution>
          <execution>
            <id>windows-bundle</id>
            <phase>generate-test-resources</phase>
            <goals>
              <goal>bundle</goal>
            </goals>
            <configuration>
              <classifier>windows</classifier>
              <instructions>
                <_dsannotations>org.daisy.pipeline.braille.libhyphen.impl.windows.LibhyphenNativePathForWindows</_dsannotations>
                <Bundle-SymbolicName>org.daisy.pipeline.modules.braille.libhyphen-utils-windows</Bundle-SymbolicName>
                <Export-Package />
                <Private-Package>
                  org.daisy.pipeline.braille.libhyphen.impl.windows
                </Private-Package>
                <Include-Resource>
                  META-INF/services/org.daisy.pipeline.braille.common.NativePath;literal
                   ='org.daisy.pipeline.braille.libhyphen.impl.windows.LibhyphenNativePathForWindows_SPI',
                  native/windows/x86=target/dependency/libhyphen/bin/i686-w64-mingw32-gpp,
                  native/windows/x86_64=target/dependency/libhyphen/bin/x86_64-w64-mingw32-gpp
                </Include-Resource>
              </instructions>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.daisy.maven</groupId>
        <artifactId>xspec-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>xspecTest</id>
            <phase>none</phase>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <id>module-with-documentation</id>
      <activation>
        <property>
          <name>documentation</name>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.daisy.pipeline.build</groupId>
            <artifactId>modules-build-helper</artifactId>
            <executions>
              <execution>
                <id>package-list</id>
                <phase>prepare-package</phase>
                <goals>
                  <goal>dependencies-package-list</goal>
                </goals>
                <configuration>
                  <outputDirectory>${project.build.directory}/dependencies-package-list/</outputDirectory>
                  <includes>
                    org.daisy.pipeline.*,
                    org.daisy.common.*
                  </includes>
                </configuration>
              </execution>
              <execution>
                <id>htmlize-sources</id>
                <configuration>
                  <!--
                      include tables
                  -->
                  <includes>
                    src/main/resources/META-INF/catalog.xml,
                    src/main/resources/**/*.xpl,
                    src/main/resources/**/*.xsl,
                    src/main/resources/tables/,
                    src/main/resources/tables/*
                  </includes>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <executions>
              <execution>
                <id>attach-javadocs</id>
                <goals>
                  <goal>jar</goal>
                </goals>
                <configuration>
                  <offlineLinks>
                    <offlineLink>
                      <url>http://daisy.github.io/pipeline/api/</url>
                      <location>${project.build.directory}/dependencies-package-list/</location>
                    </offlineLink>
                  </offlineLinks>
                  <links>
                    <link>https://google.github.io/guava/releases/15.0/api/docs</link>
                  </links>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>module-with-documentation-only</id>
      <activation>
        <property>
          <name>documentation-only</name>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <executions>
              <execution>
                <id>linux-bundle</id>
                <phase>none</phase>
              </execution>
              <execution>
                <id>mac-bundle</id>
                <phase>none</phase>
              </execution>
              <execution>
                <id>windows-bundle</id>
                <phase>none</phase>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>generate-table-files</id>
      <activation>
        <activeByDefault>false</activeByDefault>
      </activation>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
              <execution>
                <id>unpack-nlb-tables</id>
                <phase>generate-resources</phase>
                <goals>
                  <goal>unpack</goal>
                </goals>
                <configuration>
                  <outputDirectory>${project.build.directory}/generated-resources/tables</outputDirectory>
                  <artifactItems>
                    <artifactItem>
                      <groupId>no.nlb</groupId>
                      <artifactId>spell-no-patterns</artifactId>
                      <type>zip</type>
                    </artifactItem>
                  </artifactItems>
                  <includes>
                    hyph_no_NO.dic
                  </includes>
                </configuration>
              </execution>
              <execution>
                <id>unpack-celia-tables</id>
                <phase>generate-resources</phase>
                <goals>
                  <goal>unpack</goal>
                </goals>
                <configuration>
                  <outputDirectory>${project.build.directory}/generated-resources/tables</outputDirectory>
                  <artifactItems>
                    <artifactItem>
                      <groupId>fi.celia</groupId>
                      <artifactId>celia-hyphenation-tables</artifactId>
                    </artifactItem>
                  </artifactItems>
                  <includes>
                    hyph/hyph-fi.dic
                  </includes>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <artifactId>maven-antrun-plugin</artifactId>
            <executions>
              <execution>
                <!-- <phase>generate-resources</phase> -->
                <phase>none</phase>
                <goals>
                  <goal>run</goal>
                </goals>
                <configuration>
                  <tasks>
                    <mkdir dir="target/checkout" />
                    <get dest="target/checkout/dictionaries.zip" src="http://cgit.freedesktop.org/libreoffice/dictionaries/snapshot/libreoffice-4.0.0.1.zip" usetimestamp="true" skipexisting="true" />
                    <unzip dest="target/generated-resources/tables" src="target/checkout/dictionaries.zip">
                      <patternset>
                        <include name="**/hyph_*.dic" />
                        <exclude name="**/hyph_de.dic" />
                        <exclude name="**/hyph_nb_NO.dic" />
                        <exclude name="**/hyph_nn_NO.dic" />
                      </patternset>
                      <mapper type="flatten" />
                    </unzip>
                  </tasks>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

  <repositories>
    <repository>
      <!-- FIXME: this only works if you have a personal access token (with "read:packages" scope) in your settings.xml
           see https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-apache-maven-registry
      -->
      <id>github-nlb</id>
      <url>https://maven.pkg.github.com/nlbdev/spell-no</url>
      <releases>
        <enabled>true</enabled>
      </releases>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
    </repository>
    <repository>
      <!-- FIXME: this only works if you have a personal access token (with "read:packages" scope) in your settings.xml
           see https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-apache-maven-registry
      -->
      <id>github-celia</id>
      <url>https://maven.pkg.github.com/celiafi/celia-hyphenation-tables</url>
      <releases>
        <enabled>true</enabled>
      </releases>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </repository>
  </repositories>

</project>