<?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">
    <parent>
        <artifactId>modules-explanations</artifactId>
        <groupId>org.openprovenance.prov</groupId>
        <version>2.2.2</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <name>|---- NLG WRAPPER</name>
    <artifactId>nlg-wrapper</artifactId>

    <repositories>
        <repository>
            <id>clojars</id>
            <name>clojars</name>
            <url>https://repo.clojars.org/</url>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>uk.ac.abdn</groupId>
            <artifactId>SimpleNLG</artifactId>
            <version>4.4.8</version>
            <exclusions>
                <exclusion>
                    <groupId>gov.nih.nlm.nls.lexAccess.Api</groupId>
                    <artifactId>LexAccess2011dist</artifactId>
                </exclusion>
            </exclusions>
        </dependency>


        <dependency>
            <groupId>com.fasterxml.jackson.dataformat</groupId>
            <artifactId>jackson-dataformat-xml</artifactId>
            <version>${jackson.version}</version>
            <scope>compile</scope>
        </dependency>


        <dependency>
            <groupId>org.scala-lang</groupId>
            <artifactId>scala-library</artifactId>
            <version>${scala.library.version}</version> <!-- 2.12.1 -->
        </dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>${jackson.version}</version>
            <scope>compile</scope>
        </dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
            <version>${jackson.version}</version>
            <scope>compile</scope>
        </dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <version>${jackson.version}</version>
            <scope>compile</scope>
        </dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.module</groupId>
            <artifactId>jackson-module-scala_${scala.binary.version}</artifactId>
            <version>${jackson.version}</version>
        </dependency>

        <!--
        <dependency>
            <groupId>org.glassfish.jaxb</groupId>
            <artifactId>jaxb-runtime</artifactId>
            <version>${jaxb.api.version}</version>
        </dependency>
        -->

        <dependency>
            <groupId>gov.nih.nlm.nls.lexaccess</groupId>
            <artifactId>lexaccess-dist</artifactId>
            <version>2013</version>
        </dependency>

        <dependency>
            <groupId>org.scalatest</groupId>
            <artifactId>scalatest_${scala.binary.version}</artifactId>
            <version>${scalatest.version}</version> <!-- 3.1.0-RC3 -->
            <scope>test</scope>
        </dependency>

    </dependencies>


    <properties>
        <maven.javadoc.skip>true</maven.javadoc.skip>
        <cached.dictionary.folder>${basedir}/dictionary</cached.dictionary.folder>
        <deployed.dictionary.folder>${project.build.directory}/dictionary</deployed.dictionary.folder>
    </properties>


    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
        <testResources>
            <testResource>
                <directory>src/test/resources</directory>
                <filtering>true</filtering>
            </testResource>
        </testResources>

        <plugins>

            <plugin>
                <groupId>net.alchim31.maven</groupId>
                <artifactId>scala-maven-plugin</artifactId>
                <version>${scala.plugin.version}</version>
                <executions>
                    <execution>
                        <id>scala-compile-first</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>add-source</goal>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>scala-test-compile</id>
                        <phase>process-test-resources</phase>
                        <goals>
                            <goal>testCompile</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>attach-javadocs</id>
                        <goals>
                            <goal>doc-jar</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>attach-sources</id>
                        <goals>
                            <goal>add-source</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <args>
                        <arg>-deprecation</arg>
                        <arg>-feature</arg>
                    </args>
                    <jvmArgs>
                        <jvmArg>-Xms64m</jvmArg>
                        <jvmArg>-Xmx1024m</jvmArg>
                    </jvmArgs>
                </configuration>
            </plugin>


            <!-- enable scalatest -->
            <plugin>
                <groupId>org.scalatest</groupId>
                <artifactId>scalatest-maven-plugin</artifactId>
                <version>${scalatest.mvn.plugin.version}</version>
                <configuration>
                    <reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
                    <junitxml>.</junitxml>
                    <filereports>WDF TestSuite.txt</filereports>
                    <!--	  <argLine>-Xmx1500m -Xms32M -Xprof</argLine>  -->
                    <testFailureIgnore>${test.failure.ignore}</testFailureIgnore>
                </configuration>
                <executions>
                    <execution>
                        <id>test</id>
                        <goals>
                            <goal>test</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>${antrun.plugin.version}</version>
                <executions>
                    <execution>
                        <phase>process-resources</phase>
                        <configuration>
                            <target>
                                <mkdir dir="${deployed.dictionary.folder}" />
                                <copy file="${cached.dictionary.folder}/lexAccess2013.script" todir="${deployed.dictionary.folder}" />
                                <!--<copy file="${cached.dictionary.folder}/lexAccess2013.properties" todir="${deployed.dictionary.folder}" /> -->
                                <unzip src="${cached.dictionary.folder}/lexAccess2013.data.zip" dest="${deployed.dictionary.folder}" />
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>


        </plugins>
    </build>

    <profiles>
        <profile>
        <id>exists-lexicon</id>
        <activation>
            <file>
                <exists>${cached.dictionary.folder}/lexAccess2013.data.zip</exists>
            </file>
        </activation>
        <properties>
            <test.failure.ignore>false</test.failure.ignore>
        </properties>
        </profile>

        <profile>
            <id>missing-lexicon</id>
            <activation>
                <file>
                    <missing>${cached.dictionary.folder}/lexAccess2013.data.zip</missing>
                </file>
            </activation>
            <properties>
                <test.failure.ignore>false</test.failure.ignore>
            </properties>
            <build>
                <plugins>
                    <!-- Download the lexicon -->
                    <plugin>
                        <groupId>com.googlecode.maven-download-plugin</groupId>
                        <artifactId>download-maven-plugin</artifactId>
                        <version>1.7.1</version>
                        <executions>
                            <execution>
                                <id>install-lexaccess</id>
                                <phase>process-sources</phase>
                                <goals>
                                    <goal>wget</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <url>https://data.lhncbc.nlm.nih.gov/public/lsg/lexAccess/release/lexAccess2013.tgz</url>
                            <unpack>true</unpack>
                            <outputDirectory>${project.build.directory}/lexAccess/</outputDirectory>
                            <md5>283e11bcebe6dfac35f8b6d92e50788d</md5>
                        </configuration>
                    </plugin>

                    <!-- install the lexicon.zip in the dictionary folder (in which a .gitignore avoids commit to github) -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <version>${antrun.plugin.version}</version>
                        <executions>
                            <execution>
                                <phase>process-sources</phase>
                                <configuration>
                                    <target>
                                        <zip destfile="${cached.dictionary.folder}/lexAccess2013.data.zip" basedir="${project.build.directory}/lexAccess/lexAccess2013/data/HSqlDb/" includes="lexAccess2013.data" />
                                       <!--  <copy file="${project.build.directory}/lexAccess/lexAccess2013/data/HSqlDb/lexAccess2013.properties" todir="${cached.dictionary.folder}" /> -->
                                       <!--  <copy file="${project.build.directory}/lexAccess/lexAccess2013/data/HSqlDb/lexAccess2013.script" todir="${cached.dictionary.folder}" /> -->
                                    </target>
                                </configuration>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>


                </plugins>
            </build>

        </profile>
    </profiles>
</project>
