<?xml version="1.0" encoding="UTF-8"?>
<!--

    Copyright (C) 2010 eXo Platform SAS.

    This is free software; you can redistribute it and/or modify it
    under the terms of the GNU Lesser General Public License as
    published by the Free Software Foundation; either version 2.1 of
    the License, or (at your option) any later version.

    This software is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this software; if not, write to the Free
    Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
    02110-1301 USA, or see the FSF site: http://www.fsf.org.

-->
<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.exoplatform.platform</groupId>
    <artifactId>exo.platform.doc</artifactId>
    <version>3.5.9</version>
  </parent>
  <artifactId>exo.platform.doc.developer</artifactId>
  <packaging>pom</packaging>
  <name>eXo Platform - Developer Guide</name>

  <profiles>
    <profile>
      <id>distrib</id>

      <dependencies>
        <dependency>
          <groupId>org.exoplatform.doc</groupId>
          <artifactId>doc-style</artifactId>
          <version>${org.exoplatform.doc.doc-style.version}</version>
          <type>jar</type>
        </dependency>
        <dependency>
          <groupId>org.exoplatform.ide</groupId>
          <artifactId>exo-ide-user-guide</artifactId>
          <version>${org.exoplatform.ide.version}</version>
          <classifier>doc</classifier>
          <type>zip</type>
        </dependency>
      </dependencies>

      <properties>
        <wikbook.source>${project.basedir}/src/main/resources/wikbook-src</wikbook.source>
        <docbook.source>${project.build.directory}/docbook-src</docbook.source>
        <ide.source>${project.build.directory}/ide-doc</ide.source>
      </properties>

      <build>
        <plugins>
          <!-- 
            1)  Unpack the Common style and IDE resources
          -->
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>${maven-dependency-plugin.version}</version>
            <executions>
              <execution>
                <id>a-unpack</id>
                <phase>generate-sources</phase>
                <goals>
                  <goal>unpack</goal>
                </goals>
                <configuration>
                  <artifactItems>
                    <artifactItem>
                      <groupId>org.exoplatform.doc</groupId>
                      <artifactId>doc-style</artifactId>
                      <version>${org.exoplatform.doc.doc-style.version}</version>
                      <outputDirectory>${docbook.source}</outputDirectory>
                      <includes>**</includes>
                      <excludes>META-INF/**</excludes>
                    </artifactItem>
                    <artifactItem>
                      <groupId>org.exoplatform.ide</groupId>
                      <artifactId>exo-ide-user-guide</artifactId>
                      <version>${org.exoplatform.ide.version}</version>
                      <classifier>doc</classifier>
                      <type>zip</type>
                      <outputDirectory>${ide.source}</outputDirectory>
                      <includes>**</includes>
                      <excludes>META-INF/**</excludes>
                    </artifactItem>
                  </artifactItems>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <!--
           2a) Copy the Wikbook and Docbook sources to target
          -->
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-resources-plugin</artifactId>
            <version>${maven-resources-plugin.version}</version>
            <executions>
              <execution>
                <id>b-copy-resources</id>
                <phase>generate-sources</phase>
                <goals>
                  <goal>copy-resources</goal>
                </goals>
                <configuration>
                  <outputDirectory>${project.build.directory}/</outputDirectory>
                  <resources>
                    <resource>
                      <directory>src/main/resources</directory>
                      <excludes>
                        <exclude>images/**</exclude>
                        <exclude>background/**</exclude>
                      </excludes>
                    </resource>
                  </resources>
                </configuration>
              </execution>
              <!--
              2b) Copy the images and background icons to the Docbook sources directory
              -->
              <execution>
                <id>c-copy-images</id>
                <phase>generate-sources</phase>
                <goals>
                  <goal>copy-resources</goal>
                </goals>
                <configuration>
                  <outputDirectory>${docbook.source}</outputDirectory>
                  <resources>
                    <resource>
                      <directory>src/main/resources</directory>
                      <excludes>
                        <exclude>docbook-src/**</exclude>
                        <exclude>wikbook-src/**</exclude>
                      </excludes>
                    </resource>
                  </resources>
                </configuration>
              </execution>
            </executions>
          </plugin>

          <!--
            3)  The Wikbook Maven plugin generates the Docbook document from the Wiki source
          -->
          <plugin>
            <groupId>org.wikbook</groupId>
            <artifactId>wikbook.maven</artifactId>
            <version>${version.wikbook.plugin}</version>
            <executions>
              <execution>
                <id>d-generate-docbook</id>
                <phase>generate-sources</phase>
                <goals>
                  <goal>transform</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <bookId>DeveloperGuide</bookId>
              <sourceDirectory>${wikbook.source}</sourceDirectory>
              <sourceFileName>book.wiki</sourceFileName>
              <destinationDirectory>${docbook.source}</destinationDirectory>
              <destinationFileName>index.xml</destinationFileName>
              <emitDoctype>true</emitDoctype>
              <beforeBookBodyXML><![CDATA[
              <xi:include href="bookinfo.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
           ]]></beforeBookBodyXML>
              <syntaxId>confluence/1.0</syntaxId>
            </configuration>
          </plugin>
          <!--
          4/ Use Antrun to replace RoleNotInToc
          -->
          <plugin>
            <artifactId>maven-antrun-plugin</artifactId>
            <version>1.6</version>
            <executions>
              <execution>
                <id>f-add-role</id>
                <phase>generate-sources</phase>
                <configuration>
                  <target>
                    <replace file="${docbook.source}/index.xml">
                      <replacetoken><![CDATA[RoleNotInToc"]]></replacetoken>
                      <replacevalue><![CDATA[" role="NotInToc"]]></replacevalue>
                    </replace>
                  </target>
                </configuration>
                <goals>
                  <goal>run</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <!--
            5) Process all the XML files to generate HTML and PDF formats
          -->
          <plugin>
            <groupId>org.jboss.maven.plugins</groupId>
            <artifactId>maven-jdocbook-plugin</artifactId>
            <version>${maven-jdocbook-plugin.version}</version>
            <extensions>true</extensions>
            <dependencies>
              <dependency>
                <groupId>org.exoplatform.doc</groupId>
                <artifactId>exo-docbook-xslt</artifactId>
                <version>${docbook-xslt.version}</version>
              </dependency>
            </dependencies>
            <executions>
              <!--
              5a) The Dev Guide resources
              -->
              <execution>
                <id>f-jdocbook-resources-dev</id>
                <phase>process-resources</phase>
                <goals>
                  <goal>resources</goal>
                </goals>
                <configuration>
                  <sourceDirectory>${docbook.source}</sourceDirectory>
                  <imageResource>
                    <directory>${docbook.source}</directory>
                    <includes>
                      <include>images/**</include>
                      <include>background/**</include>
                    </includes>
                  </imageResource>
                  <cssResource>
                    <directory>${docbook.source}</directory>
                    <includes>
                      <include>css/**</include>
                    </includes>
                  </cssResource>
                </configuration>
              </execution>
              <!--
              5b) The IDE resources
              -->
              <execution>
                <id>f-jdocbook-resources-ide</id>
                <phase>process-resources</phase>
                <goals>
                  <goal>resources</goal>
                </goals>
                <configuration>
                  <sourceDirectory>${ide.source}/org.exoplatform.ide.user</sourceDirectory>
                  <publishDirectory>${project.build.directory}/docbook/publish/ide-user-guide/</publishDirectory>
                  <imageResource>
                    <directory>${ide.source}/org.exoplatform.ide.user</directory>
                    <includes>
                      <include>images/**</include>
                    </includes>
                  </imageResource>
                  <cssResource>
                    <directory>${docbook.source}</directory>
                    <includes>
                      <include>css/**</include>
                    </includes>
                  </cssResource>
                </configuration>
              </execution>
              <!--
              5c) The Dev Guide compilation
              -->
              <execution>
                <id>f-generate-docs-dev</id>
                <goals>
                  <goal>generate</goal>
                </goals>
                <phase>compile</phase>
                <configuration>
                  <sourceDirectory>${docbook.source}</sourceDirectory>
                  <imageResource>
                    <directory>${docbook.source}</directory>
                    <includes>
                      <include>images/**</include>
                      <include>background/**</include>
                    </includes>
                  </imageResource>
                  <cssResource>
                    <directory>${docbook.source}</directory>
                    <includes>
                      <include>css/**</include>
                    </includes>
                  </cssResource>
                </configuration>
              </execution>
              <!--
              5d) The IDE compilation
              -->
              <execution>
                <id>f-generate-docs-ide</id>
                <goals>
                  <goal>generate</goal>
                </goals>
                <phase>compile</phase>
                <configuration>
                  <sourceDirectory>${ide.source}/org.exoplatform.ide.user</sourceDirectory>
                  <publishDirectory>${project.build.directory}/docbook/publish/ide-user-guide/</publishDirectory>
                  <imageResource>
                    <directory>${ide.source}/org.exoplatform.ide.user</directory>
                    <includes>
                      <include>images/**</include>
                    </includes>
                  </imageResource>
                  <cssResource>
                    <directory>${docbook.source}</directory>
                    <includes>
                      <include>css/**</include>
                    </includes>
                  </cssResource>
                </configuration>
              </execution>
            </executions>
            <!--
            6) Common configurations
            -->
            <configuration>
              <sourceDocumentName>index.xml</sourceDocumentName>
              <options>
                <xincludeSupported>true</xincludeSupported>
                <xmlTransformerType>saxon</xmlTransformerType>
                <docbookVersion>${docbook.version}</docbookVersion>
              </options>
              <formats>
                <format>
                  <formatName>pdf</formatName>
                  <stylesheetResource>file:${docbook.source}/xsl/pdf.xsl</stylesheetResource>
                  <finalName>${project.artifactId}-${project.version}.pdf</finalName>
                </format>
                <format>
                  <formatName>html</formatName>
                  <stylesheetResource>file:${docbook.source}/xsl/xhtml.xsl</stylesheetResource>
                  <finalName>index.html</finalName>
                </format>
              </formats>
            </configuration>
          </plugin>
          <!--
            6) Assemble and attach the final artifacts (HTML, Docbook, PDF)
           -->
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <executions>
              <execution>
                <id>g-assemble-archives</id>
                <phase>package</phase>
                <goals>
                  <goal>single</goal>
                </goals>
                <configuration>
                  <descriptors>
                    <descriptor>src/main/assembly/docbook.xml</descriptor>
                    <descriptor>src/main/assembly/html.xml</descriptor>
                  </descriptors>
                  <appendAssemblyId>true</appendAssemblyId>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <version>${helper-maven-plugin.version}</version>
            <executions>
              <execution>
                <id>h-attach-pdf</id>
                <phase>package</phase>
                <goals>
                  <goal>attach-artifact</goal>
                </goals>
                <configuration>
                  <artifacts>
                    <artifact>
                      <file>
                        ${project.build.directory}/docbook/publish/en-US/pdf/${project.artifactId}-${project.version}.pdf
                      </file>
                      <type>pdf</type>
                    </artifact>
                    <artifact>
                      <file>
                        ${project.build.directory}/docbook/publish/ide-user-guide/en-US/pdf/${project.artifactId}-${project.version}.pdf
                      </file>
                      <type>pdf</type>
                      <classifier>ide</classifier>
                    </artifact>
                  </artifacts>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
