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

    Copyright (C) 2009 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/maven-v4_0_0.xsd">
  <parent>
    <groupId>org.exoplatform</groupId>
    <artifactId>foundation-parent</artifactId>
    <version>12</version>
    <relativePath />
  </parent>

  <modelVersion>4.0.0</modelVersion>
  <artifactId>exo-jcr-services</artifactId>
  <version>1.15.10-GA</version>
  <packaging>jar</packaging>
  <name>eXo JCR :: Ext :: Services</name>
  <description>Exoplatform SAS 'eXo JCR Ext Services' project.</description>
  
  <scm>
    <connection>scm:git:git://github.com/exoplatform/jcr-services.git</connection>
    <developerConnection>scm:git:git@github.com:exoplatform/jcr-services.git</developerConnection>
    <url>https://fisheye.exoplatform.org/browse/jcr-services-dev</url>
  </scm>
  
  <properties>
     <org.exoplatform.kernel.version>2.4.10-GA</org.exoplatform.kernel.version>
     <org.exoplatform.core.version>2.5.10-GA</org.exoplatform.core.version>
     <org.exoplatform.ws.version>2.3.10-GA</org.exoplatform.ws.version>
     <org.exoplatform.jcr.version>1.15.10-GA</org.exoplatform.jcr.version>
     
     <wikbook.source>${pom.basedir}/src/main/wikbook</wikbook.source>
     <wikbook.target>${project.build.directory}/wikbook</wikbook.target>
     <wikbook.version>0.9.26</wikbook.version>

     <version.release.plugin>2.2.1</version.release.plugin>
     <version.buildnumber.plugin>1.0</version.buildnumber.plugin>
  </properties>
  
  <dependencies>
    <dependency>
      <groupId>org.exoplatform.kernel</groupId>
      <artifactId>exo.kernel.commons.test</artifactId>
      <version>${org.exoplatform.kernel.version}</version>
      <scope>test</scope>
    </dependency>     
    <dependency>
      <groupId>org.exoplatform.jcr</groupId>
      <artifactId>exo.jcr.component.ext</artifactId>
      <version>${org.exoplatform.jcr.version}</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.exoplatform.core</groupId>
      <artifactId>exo.core.component.organization.tests</artifactId>
      <version>${org.exoplatform.core.version}</version>
      <classifier>test-sources</classifier>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-log4j12</artifactId>
      <version>1.6.1</version>         
      <scope>test</scope>
    </dependency>    
    <dependency>
      <groupId>commons-io</groupId>
      <artifactId>commons-io</artifactId>
      <version>1.3.2</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.hsqldb</groupId>
      <artifactId>hsqldb</artifactId>
      <version>2.0.0</version>
      <scope>test</scope>
    </dependency>    
    <dependency>
      <groupId>org.wikbook</groupId>
      <artifactId>wikbook.docbkxstyle</artifactId>
      <version>${wikbook.version}</version>
      <scope>provided</scope>
    </dependency>    
  </dependencies>
  <build>
    <sourceDirectory>src/main/java</sourceDirectory>
    <outputDirectory>target/classes</outputDirectory>
    <testSourceDirectory>src/test/java</testSourceDirectory>
    <testOutputDirectory>target/test-classes</testOutputDirectory>
    <resources>
      <resource>
        <directory>src/main/java</directory>
        <includes>
          <include>**/*.xml</include>
          <include>**/*.html</include>
          <include>**/*.css</include>
        </includes>
      </resource>
    </resources>
    <testResources>
      <testResource>
        <directory>src/test/resources</directory>
        <includes>
          <include>**/*.properties</include>
          <include>**/*.xml</include>
          <include>login.conf</include>
        </includes>
      </testResource>
      <testResource>
        <directory>src/test/java</directory>
        <includes>
          <include>**/*.xml</include>
        </includes>
      </testResource>
    </testResources>
    <plugins>
      <!-- copy images to wikbook src -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-resources-plugin</artifactId>
        <executions>
          <execution>
            <id>prepare</id>
            <phase>compile</phase>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <configuration>
              <outputDirectory>${wikbook.target}/src/resources/images</outputDirectory>
              <resources>
                <resource>
                  <directory>src/main/wikbook/images</directory>
                  <filtering>true</filtering>
                </resource>
              </resources>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <!-- The wikbook maven plugin generates the docbook document from the wiki source -->
      <plugin>
        <groupId>org.wikbook</groupId>
        <artifactId>wikbook.maven</artifactId>
        <version>${wikbook.version}</version>
        <executions>
          <execution>
            <phase>prepare-package</phase>
            <goals>
              <goal>transform</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <sourceDirectory>${wikbook.source}/en/en-US</sourceDirectory>
          <sourceFileName>book.wiki</sourceFileName>
          <destinationDirectory>${wikbook.target}/src</destinationDirectory>
          <destinationFileName>index.xml</destinationFileName>

          <emitDoctype>false</emitDoctype>
          <beforeBookBodyXML><![CDATA[<xi:include href="bookinfo.ext" xmlns:xi="http://www.w3.org/2001/XInclude" />]]></beforeBookBodyXML>
          <validationMode>lax</validationMode>
          <syntaxId>confluence/1.0</syntaxId>
        </configuration>
      </plugin>
      <!-- Unpacks the docbook style resources for the docbkx plugin -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <version>2.1</version>
        <executions>
          <execution>
            <id>a</id>
            <phase>prepare-package</phase>
            <goals>
              <goal>unpack-dependencies</goal>
            </goals>
            <configuration>
              <includeGroupIds>org.wikbook</includeGroupIds>
              <includeArtifactIds>wikbook.docbkxstyle</includeArtifactIds>
              <excludes>META-INF/**</excludes>
              <outputDirectory>${wikbook.target}/src/resources</outputDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>
      
            <!-- Dockbx plugin that generates content -->
      <plugin>
        <groupId>com.agilejava.docbkx</groupId>
        <artifactId>docbkx-maven-plugin</artifactId>
        <version>2.0.7</version>
        <executions>
          <execution>
            <id>Generate HTML</id>
            <goals>
              <goal>generate-html</goal>
            </goals>
            <phase>package</phase>
            <configuration>
              <htmlCustomization>${wikbook.target}/src/resources/xsl/html.xsl</htmlCustomization>
              <htmlStylesheet>css/html.css</htmlStylesheet>
              <imgSrcPath>images/</imgSrcPath>
              <admonGraphicsPath>images/admons/</admonGraphicsPath>
            </configuration>
          </execution>
          <execution>
            <id>Generate PDF</id>
            <goals>
              <goal>generate-pdf</goal>
            </goals>
            <phase>package</phase>
            <configuration>
              <foCustomization>${wikbook.target}/src/resources/xsl/fopdf.xsl</foCustomization>
              <imgSrcPath>${wikbook.target}/src/resources/images/</imgSrcPath>
              <admonGraphicsPath>${wikbook.target}/src/resources/images/admons/</admonGraphicsPath>
            </configuration>
          </execution>
        </executions>
        <configuration>
          <sourceDirectory>${wikbook.target}/src</sourceDirectory>
          <targetDirectory>${wikbook.target}/output</targetDirectory>
          <includes>index.xml</includes>
          <!-- Highlight source code -->
          <highlightSource>1</highlightSource>
          <!-- We need to support xinclude -->
          <xincludeSupported>true</xincludeSupported>
          <!--
           |  See http://www.sagehill.net/docbookxsl/AnnotateListing.html
           |  Callouts on imported text
          -->
          <useExtensions>1</useExtensions>
          <calloutsExtension>1</calloutsExtension>

          <!-- Copy any docbook XML -->
          <preProcess>
            <copy todir="${wikbook.target}/src">
              <fileset dir="${wikbook.source}/en/en-US">
                <include name="**/*.ext" />
              </fileset>
              <fileset dir="${wikbook.source}/en/en-US">
                <include name="**/*.xml" />
              </fileset>
            </copy>
          </preProcess>

          <!-- Copy the image for HTML-->
          <postProcess>
            <copy todir="${wikbook.target}/output">
              <fileset dir="${wikbook.target}/src/resources">
                <include name="**/*.css" />
                <include name="**/*.png" />
                <include name="**/*.gif" />
                <include name="**/*.jpg" />
                <include name="**/*.jpeg" />
              </fileset>
            </copy>
          </postProcess>
        </configuration>
        <dependencies>
          <dependency>
            <groupId>org.docbook</groupId>
            <artifactId>docbook-xml</artifactId>
            <version>4.4</version>
            <scope>runtime</scope>
          </dependency>
        </dependencies>
      </plugin>
      
      <!-- Unpacking Organization Service TCK tests-->
      <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-dependency-plugin</artifactId>
         <executions>
            <execution>
               <id>unpack</id>
               <phase>generate-test-sources</phase>
               <goals>
                  <goal>unpack</goal>
               </goals>
               <configuration>
                  <artifactItems>
                     <artifactItem>
                        <groupId>org.exoplatform.core</groupId>
                        <artifactId>exo.core.component.organization.tests</artifactId>
                        <classifier>test-sources</classifier>
                        <type>jar</type>
                        <overWrite>false</overWrite>
                     </artifactItem>
                  </artifactItems>
                  <outputDirectory>${project.build.directory}/org-service-tck-tests</outputDirectory>
               </configuration>
            </execution>
         </executions>
      </plugin>
      
      <!-- Adding Organization Service TCK resources and test sources-->
      <plugin>
         <groupId>org.codehaus.mojo</groupId>
         <artifactId>build-helper-maven-plugin</artifactId>
         <version>1.3</version>
         <executions>
            <execution>
               <id>add-test-resource</id>
               <phase>generate-test-sources</phase>
               <goals>
                  <goal>add-test-resource</goal>
               </goals>
               <configuration>
                  <resources>
                     <resource>
                        <directory>${project.build.directory}/org-service-tck-tests</directory>
                     </resource>
                  </resources>
               </configuration>
            </execution> 
            <execution>
               <id>add-test-source</id>
               <phase>generate-test-sources</phase>
               <goals>
                  <goal>add-test-source</goal>
               </goals>
               <configuration>
                  <sources>
                     <source>${project.build.directory}/org-service-tck-tests</source>
                  </sources>
               </configuration>
            </execution>
         </executions>
      </plugin>         
      
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <argLine>${env.MAVEN_OPTS} -Djava.security.manager=org.exoplatform.commons.test.TestSecurityManager -Djava.security.policy=${project.build.directory}/test-classes/test.policy</argLine>
          <!-- Including Organization Service TCK-->
          <includes>
              <include>org/exoplatform/services/tck/organization/Test*.java</include>
              <include>org/exoplatform/services/jcr/ext/organization/Test*.java</include>
              <include>org/exoplatform/services/jcr/ext/audit/*Test.java</include>
          </includes>                 
          <excludes>
             <exclude>org/exoplatform/services/tck/organization/AbstractOrganizationServiceTest.java</exclude>
          </excludes>   
        </configuration>
      </plugin>
         <plugin>
            <artifactId>maven-antrun-plugin</artifactId>
            <executions>
               <execution>
                  <id>prepare-test-policy</id>
                  <phase>process-test-resources</phase>
                  <configuration>
                     <tasks>
                        <echo>Creating Access Policy for tests</echo>
                        <makeurl file="${settings.localRepository}" property="localRepositoryURL" />
                        <makeurl file="${project.build.outputDirectory}" property="outputDirectoryURL" />
                        <makeurl file="${project.build.testOutputDirectory}" property="testOutputDirectoryURL" />
                        <copy todir="${project.build.testOutputDirectory}" overwrite="true">
                           <fileset dir="${project.basedir}/src/test/resources/">
                              <include name="test.policy" />
                           </fileset>
                           <filterset>
                              <filter token="MAVEN_REPO" value="${localRepositoryURL}" />
                              <filter token="MAIN_CLASSES" value="${outputDirectoryURL}" />
                              <filter token="TEST_CLASSES" value="${testOutputDirectoryURL}" />
                           </filterset>
                        </copy>
                     </tasks>                     
                  </configuration>
                  <goals>
                     <goal>run</goal>
                  </goals>
               </execution>
            </executions>
            <dependencies>
               <dependency>
                  <groupId>ant</groupId>
                  <artifactId>ant-optional</artifactId>
                  <version>1.5.3-1</version>
               </dependency>
            </dependencies>
         </plugin>
    </plugins>
  </build>
  
</project>
