<!--
       Licensed to the Apache Software Foundation (ASF) under one
       or more contributor license agreements.  See the NOTICE file
       distributed with this work for additional information
       regarding copyright ownership.  The ASF licenses this file
       to you under the Apache License, Version 2.0 (the
       "License"); you may not use this file except in compliance
       with the License.  You may obtain a copy of the License at

         http://www.apache.org/licenses/LICENSE-2.0

       Unless required by applicable law or agreed to in writing,
       software distributed under the License is distributed on an
       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
       KIND, either express or implied.  See the License for the
       specific language governing permissions and limitations
       under the License.
-->
<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.odftoolkit</groupId>
        <artifactId>odftoolkit</artifactId>
        <version>0.12.0</version>
    </parent>

    <artifactId>xslt-runner</artifactId>
    <name>ODF XSLT-Runner</name>
    <version>0.12.0</version>

    <organization>
        <name>The Document Foundation</name>
        <url>https://www.documentfoundation.org/</url>
    </organization>


    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <maven.build.timestamp.format>yyyy-MM-dd'T'HH:mm:ss</maven.build.timestamp.format>
        <odf12.input>src/test/resources/odf12/</odf12.input>
        <odf13.input>src/test/resources/odf13/</odf13.input>
        <rng2normalization.stylesheet>src/test/resources/xslt/rng/rng2normalization.xsl</rng2normalization.stylesheet>
        <rnghtml.stylesheet>src/test/resources/xslt/rng/addRefs4rng-html.xsl</rnghtml.stylesheet>
        <rng2docbook.stylesheet>src/test/resources/xslt/rng/rng2docbook.xsl</rng2docbook.stylesheet>
        <odf.defaultvalue.extraction>src/test/resources/xslt/getAttributeDefaults.xsl</odf.defaultvalue.extraction>
        <!-- version has to be used twice in pom.xml and can not be handled by dependencyManagement of root pom.xml -->
        <version.saxon-he>9.9.1-8</version.saxon-he>
    </properties>

    <dependencies>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>odfdom-java</artifactId>
            <version>0.12.0</version>
        </dependency>
        <dependency>
            <!-- a reliable XSLT processor -->
            <groupId>net.sf.saxon</groupId>
            <artifactId>Saxon-HE</artifactId>
            <version>${version.saxon-he}</version>
            <!-- test scope does not work with exec-maven-plugin below -->
            <scope>compile</scope>
        </dependency>
    </dependencies>

    <!-- Build Settings -->
    <build>
        <plugins>
            <!-- SAXON XSLT 2.0 processor -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>xml-maven-plugin</artifactId>
                <version>1.1.0</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>transform</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <transformationSets>
                        <transformationSet>
                            <dir>${odf12.input}/rng-normalization</dir>
                            <includes>OpenDocument-v1.2-os-schema_original_but_manual_space_adoption.rng</includes>
                            <stylesheet>${rng2normalization.stylesheet}</stylesheet>
                            <fileMappers>
                                <fileMapper implementation="org.codehaus.plexus.components.io.filemappers.FileExtensionMapper">
                                    <targetExtension>.xml</targetExtension>
                                </fileMapper>
                            </fileMappers>
                        </transformationSet>
                        <!--
                        <transformationSet>
                            <dir>${odf13.input}</dir>
                            <includes>*.odt</includes>
                            <stylesheet>${odf.defaultvalue.extraction}</stylesheet>
                            <fileMappers>
                                <fileMapper implementation="org.codehaus.plexus.components.io.filemappers.FileExtensionMapper">
                                    <targetExtension>.xml</targetExtension>
                                </fileMapper>
                            </fileMappers>
                        </transformationSet>-->
                        <!--
                        <transformationSet>
                            <dir>${odf12.input}</dir>
                            <includes>*.rng</includes>
                            <stylesheet>${rng2docbook.stylesheet}</stylesheet>
                            <fileMappers>
                                <fileMapper implementation="org.codehaus.plexus.components.io.filemappers.FileExtensionMapper">
                                    <targetExtension>.docbook</targetExtension>
                                </fileMapper>
                            </fileMappers>
                        </transformationSet>
                        <transformationSet>
                            <dir>${odf12.input}</dir>
                            <includes>*.html</includes>
                            <stylesheet>${rnghtml.stylesheet}</stylesheet>
                            <outputProperties>
                                <outputProperty>
                                    <name>omit-xml-declaration</name>
                                    <value>yes</value>
                                </outputProperty>
                                <outputProperty>
                                    <name>version</name>
                                    <value>5</value>
                                </outputProperty>
                            </outputProperties>
                            <fileMappers>
                                <fileMapper implementation="org.codehaus.plexus.components.io.filemappers.FileExtensionMapper">
                                    <targetExtension>.html</targetExtension>
                                </fileMapper>
                            </fileMappers>
                        </transformationSet>
                        <transformationSet>
                            <dir>${odf13.input}</dir>
                            <includes>*.rng</includes>
                            <stylesheet>${rng2docbook.stylesheet}</stylesheet>
                            <fileMappers>
                                <fileMapper implementation="org.codehaus.plexus.components.io.filemappers.FileExtensionMapper">
                                    <targetExtension>.docbook</targetExtension>
                                </fileMapper>
                            </fileMappers>
                        </transformationSet>
                        <transformationSet>
                            <dir>${odf13.input}</dir>
                            <includes>*.html</includes>
                            <stylesheet>${rnghtml.stylesheet}</stylesheet>
                            <outputProperties>
                                <outputProperty>
                                    <name>omit-xml-declaration</name>
                                    <value>yes</value>
                                </outputProperty>
                                <outputProperty>
                                    <name>version</name>
                                    <value>5</value>
                                </outputProperty>
                            </outputProperties>
                            <fileMappers>
                                <fileMapper implementation="org.codehaus.plexus.components.io.filemappers.FileExtensionMapper">
                                    <targetExtension>.html</targetExtension>
                                </fileMapper>
                            </fileMappers>
                        </transformationSet>
                    -->
                    </transformationSets>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>net.sf.saxon</groupId>
                        <artifactId>Saxon-HE</artifactId>
                        <version>${version.saxon-he}</version>
                        <scope>runtime</scope>
                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.6.0</version>
                <executions>
                    <execution>
                        <id>defaultvalues-odf1.2</id>
                        <phase>integration-test</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <!-- see https://tdf.github.io/odftoolkit/docs/xsltrunner/ODFXSLTRunner.html
                            java -jar odfxsltrunner.jar <style sheet>; [-v] [-f <factory>] [-p <path in package&gt;] [-l log file] [-x <extract path> ...] -o <input package> <output file> [name=value ...] -->
                        <configuration>
                            <executable>${java.home}/bin/java</executable>
                            <executableDependency>
                                <groupId>net.sf.saxon</groupId>
                                <artifactId>Saxon-HE</artifactId>
                            </executableDependency>
                            <arguments>
                                <argument>-cp</argument>
                                <argument>target/xslt-runner-${project.version}-jar-with-dependencies.jar</argument>
                                <argument>org.odftoolkit.odfxsltrunner.Main</argument>
                                <argument>${odf.defaultvalue.extraction}</argument>
                                <argument>-v</argument>
                                <argument>-f</argument>
                                <argument>net.sf.saxon.TransformerFactoryImpl</argument>
                                <argument>-o</argument>
                                <argument>src/test/resources/odf12/OpenDocument-v1.2-os-part1.odt</argument>
                                <argument>target/generated-resources/xml/xslt/OpenDocument-v1.2-os-part1-defaults.xml</argument>
                            </arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>defaultvalues-odf1.3</id>
                        <phase>integration-test</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <!-- see https://tdf.github.io/odftoolkit/docs/xsltrunner/ODFXSLTRunner.html
                            java -jar odfxsltrunner.jar <style sheet>; [-v] [-f <factory>] [-p <path in package&gt;] [-l log file] [-x <extract path> ...] -o <input package> <output file> [name=value ...] -->
                        <configuration>
                            <executable>${java.home}/bin/java</executable>
                            <executableDependency>
                                <groupId>net.sf.saxon</groupId>
                                <artifactId>Saxon-HE</artifactId>
                            </executableDependency>
                            <arguments>
                                <argument>-cp</argument>
                                <argument>target/xslt-runner-${project.version}-jar-with-dependencies.jar</argument>
                                <argument>org.odftoolkit.odfxsltrunner.Main</argument>
                                <argument>${odf.defaultvalue.extraction}</argument>
                                <argument>-v</argument>
                                <argument>-f</argument>
                                <argument>net.sf.saxon.TransformerFactoryImpl</argument>
                                <argument>-o</argument>
                                <argument>src/test/resources/odf13/OpenDocument-v1.3-cs01-part3-schema.odt</argument>
                                <argument>target/generated-resources/xml/xslt/OpenDocument-v1.3-cs01-part3-defaults.xml</argument>
                            </arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <!-- configuration defined in the parent pom.xml -->
            </plugin>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                    <archive>
                        <manifest>
                            <mainClass>org.odftoolkit.odfxsltrunner.Main</mainClass>
                        </manifest>
                    </archive>
                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <configuration>
                    <!-- Workaround: Build the project using the same JDK version as the project is targetting.
                        see https://issues.apache.org/jira/browse/MJAVADOC-562
                        see https://bugs.openjdk.java.net/browse/JDK-8212233
                    -->
                    <source>${jdk.version}</source>
                    <doctitle>${project.name} v${project.version}</doctitle>
                    <bottom>${javadoc.bottom}</bottom>
                    <isOffline>false</isOffline>
                    <splitindex>true</splitindex>
                    <windowtitle>${project.name} API v${project.version} - https://odftoolkit.org/</windowtitle>
                    <docfilessubdirs>true</docfilessubdirs>
                </configuration>
                <executions>
                    <execution>
                        <id>attach-javadocs</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                        <configuration>
                            <doclint>none</doclint>
                            <additionalOptions>
                                <additionalOption>${javadoc.opts}</additionalOption>
                            </additionalOptions>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-source-plugin</artifactId>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <goals>
                            <goal>jar-no-fork</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    <profiles>
        <profile>
            <id>doclint-java8-disable</id>
            <activation>
                <jdk>[1.8,)</jdk>
            </activation>
            <properties>
                <javadoc.opts>-Xdoclint:none</javadoc.opts>
            </properties>
        </profile>
    </profiles>
</project>
