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

    <!--

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

    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.apache.karaf</groupId>
        <artifactId>cellar</artifactId>
        <version>4.2.0</version>
        <relativePath>../pom.xml</relativePath>
    </parent>

    <groupId>org.apache.karaf.cellar</groupId>
    <artifactId>manual</artifactId>
    <name>Apache Karaf :: Cellar :: Manual</name>
    <packaging>bundle</packaging>

    <build>
        <plugins>
            <plugin>
                <groupId>org.asciidoctor</groupId>
                <artifactId>asciidoctor-maven-plugin</artifactId>
                <version>1.5.6</version>
                <executions>
                    <execution>
                        <id>output-html</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>process-asciidoc</goal>
                        </goals>
                        <configuration>
                            <sourceHighlighter>coderay</sourceHighlighter>
                            <backend>html5</backend>
                            <doctype>article</doctype>
                            <attributes>
                                <toc />
                                <linkcss>false</linkcss>
                                <stylesheet>style/apache.css</stylesheet>
                                <imagesdir>images</imagesdir>
                            </attributes>
                        </configuration>
                    </execution>
                </executions>
                <configuration>
                    <sourceDirectory>src/main/asciidoc</sourceDirectory>
                    <headerFooter>true</headerFooter>
                    <imagesDir>src/main/asciidoc/images</imagesDir>
                    <outputDirectory>target/generated-docs/html</outputDirectory>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-scm-publish-plugin</artifactId>
                <version>3.0.0</version>
                <configuration>
                    <checkinComment>[scm-publish] Updating main site with Karaf Cellar manual</checkinComment>
                    <pubScmUrl>scm:svn:https://svn.apache.org/repos/asf/karaf/site/production/manual/cellar/latest-4</pubScmUrl>
                    <content>${project.build.directory}/generated-docs</content>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <version>3.3.0</version>
                <configuration>
                    <instructions>
                        <Web-ContextPath>/documentation-cellar</Web-ContextPath>
                        <Include-Resource>target/generated-docs</Include-Resource>
                    </instructions>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>pdf</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.asciidoctor</groupId>
                        <artifactId>asciidoctor-maven-plugin</artifactId>
                        <version>1.5.6</version>
                        <dependencies>
                            <dependency>
                                <groupId>org.asciidoctor</groupId>
                                <artifactId>asciidoctorj-pdf</artifactId>
                                <version>1.5.0-alpha.16</version>
                            </dependency>
                        </dependencies>
                        <configuration>
                            <sourceDirectory>src/main/asciidoc</sourceDirectory>
                            <outputDirectory>target/generated-docs/pdf</outputDirectory>
                            <preserveDirectories>true</preserveDirectories>
                            <headerFooter>true</headerFooter>
                            <backend>pdf</backend>
                            <attributes>
                                <project-version>${project.version}</project-version>
                                <pdf-stylesdir>${project.basedir}/src/main/theme</pdf-stylesdir>
                                <pdf-style>apache</pdf-style>
                                <pdf-fontsdir>${project.basedir}/src/main/theme/fonts</pdf-fontsdir>
                                <imagesdir>images</imagesdir>
                                <icons>font</icons>
                                <pagenums>true</pagenums>
                                <toc />
                                <idprefix />
                                <idseparator>-</idseparator>
                                <sectnums>true</sectnums>
                            </attributes>
                        </configuration>
                        <executions>
                            <execution>
                                <id>generate-pdf-doc</id>
                                <phase>generate-resources</phase>
                                <goals>
                                    <goal>process-asciidoc</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <version>1.6</version>
                        <executions>
                            <execution>
                                <id>create-documentation</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <configuration>
                                    <tasks>
                                        <mkdir dir="target" />
                                        <copy file="${project.build.directory}/generated-docs/html/index.html" tofile="target/documentation.html" />
                                        <copy file="${project.build.directory}/generated-docs/html/images/asf_logo.png" tofile="target/images/asf_logo.png" />
                                        <copy file="${project.build.directory}/generated-docs/pdf/index.pdf" tofile="target/documentation.pdf" />
                                        <attachartifact file="target/documentation.html" type="html" />
                                        <attachartifact file="target/images/asf_logo.png" type="image" />
                                        <attachartifact file="target/documentation.pdf" type="pdf" />
                                    </tasks>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>
