
<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.exoplatform.platform</groupId>
    <artifactId>exo.platform.doc</artifactId>
    <version>3.5.3</version>
  </parent>
  <artifactId>exo.platform.doc.introduction</artifactId>
  <packaging>pom</packaging>
  <name>eXo Platform - Introduction</name>
  <properties>
    <org.exoplatform.doc-style.version>1</org.exoplatform.doc-style.version>
    <docbook.source>${project.build.directory}/docbook-src</docbook.source>
  </properties>
  <profiles>
    <profile>
      <id>distrib</id>
      <build>
        <plugins>
    <!--
    1/
     - download common style
     - unpack them in /target
    -->
  <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
              <execution>
                <id>a-unpack</id>
                <phase>generate-sources</phase>
                <goals>
                  <goal>unpack</goal>
                </goals>
                <configuration>
                  <artifactItems>                   
                    <!-- wikbook and common style -->
                    <artifactItem>
                      <groupId>org.wikbook</groupId>
                      <artifactId>wikbook.docbkxstyle</artifactId>
                      <version>${version.wikbook.plugin}</version>
                      <outputDirectory>${docbook.source}</outputDirectory>
                      <includes>**</includes>
                      <excludes>META-INF/**</excludes>
                    </artifactItem>
             	    <artifactItem>
                       <groupId>org.exoplatform.doc</groupId>
                       <artifactId>doc-style</artifactId>
                       <version>${doc-style.version}</version>
                       <outputDirectory>${docbook.source}</outputDirectory>
                       <includes>**</includes>
                       <excludes>META-INF/**</excludes>
            	    </artifactItem>
                  </artifactItems>
                </configuration>
              </execution>
            </executions>
          </plugin>
    <!--
    2/
     - move the xml, xsl, css and images from src/main/ to target/plf/
    -->
          <plugin>
            <artifactId>maven-resources-plugin</artifactId>
            <version>2.4.3</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>background/**</exclude>
                      </excludes>
                    </resource>
                  </resources>
                </configuration>
              </execution>
              <execution>
                <id>d-copy-background</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>
                      </excludes>
                    </resource>
                  </resources>
                </configuration>
              </execution>
            </executions>
          </plugin>		 
	
    <!--
    3/
     - process all the xml files (plf + other products) from target/
     - in the end, generate the html
    -->   
	    
          <plugin>
            <groupId>org.jboss.maven.plugins</groupId>
            <artifactId>maven-jdocbook-plugin</artifactId>
            <version>2.1.1</version>			
            <executions>
              <execution>
                <id>e-jdocbook-resources</id>
                <phase>process-resources</phase>
                <goals>
                  <goal>resources</goal>
                </goals>
              </execution>
              <execution>
                <id>f-jdocbook-generate</id>
                <phase>compile</phase>
                <goals>
                  <goal>generate</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <sourceDirectory>${docbook.source}</sourceDirectory>
              <sourceDocumentName>index.xml</sourceDocumentName>
              <cssResource>
                <directory>${docbook.source}</directory>
                <includes>
                  <include>css/**</include>
                </includes>
              </cssResource>
              <imageResource>
                <directory>${docbook.source}</directory>
                <includes>
                  <include>background/**</include>
                  <include>images/**</include>
                </includes>
              </imageResource>
              <formats>
                <format>
                  <formatName>html</formatName>
                  <stylesheetResource>file:${docbook.source}/xsl/xhtml.xsl</stylesheetResource>
                  <finalName>index.html</finalName>
                </format>
                <format>
                 <formatName>pdf</formatName>
                 <stylesheetResource>file:${docbook.source}/xsl/pdf.xsl</stylesheetResource>
                 <finalName>${project.artifactId}-${project.version}.pdf</finalName>
               </format>
              </formats>
              <options>
                <xincludeSupported>true</xincludeSupported>
                <xmlTransformerType>saxon</xmlTransformerType>
                <docbookVersion>1.76.1</docbookVersion>
              </options>
            </configuration>
            <extensions>true</extensions>
            <dependencies>
              <dependency>
                <groupId>org.exoplatform.doc</groupId>
                <artifactId>exo-docbook-xslt</artifactId>
                <version>${org.exoplatform.doc-style.version}</version>
              </dependency>
              <dependency>
                <groupId>org.exoplatform.doc</groupId>
                <artifactId>exo-jdocbook-style</artifactId>
                <version>${org.exoplatform.doc-style.version}</version>
                <type>jdocbook-style</type>
              </dependency>
            </dependencies>
          </plugin>
          
          <!-- Attach the HTML zip -->
          <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>1.7</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>
		          </artifacts>
		        </configuration>
		      </execution>
		    </executions>
		  </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
