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

<!--
 * See the NOTICE file distributed with this work for additional
 * information regarding copyright ownership.
 *
 * 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">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>org.xwiki.rendering</groupId>
    <artifactId>xwiki-rendering-legacy</artifactId>
    <version>16.4.0-rc-1</version>
  </parent>
  <artifactId>xwiki-rendering-legacy-api</artifactId>
  <name>XWiki Rendering - Legacy - API</name>
  <packaging>jar</packaging>
  <description>Legacy module for xwiki-rendering-api</description>
  <properties>
    <xwiki.jacoco.instructionRatio>0.07</xwiki.jacoco.instructionRatio>
    <!-- The features provided by this module so that it's found when resolving extension -->
    <xwiki.extension.features>org.xwiki.rendering:xwiki-rendering-api</xwiki.extension.features>
  </properties>
  <dependencies>
    <!-- Trigger xwiki-rendering-api dependencies (but without xwiki-rendering-api jar itself) -->
    <dependency>
      <groupId>org.xwiki.rendering</groupId>
      <artifactId>xwiki-rendering-api</artifactId>
      <version>${project.version}</version>
      <type>pom</type>
      <exclusions>
        <!-- Trigger legacy version -->
        <exclusion>
          <groupId>org.xwiki.commons</groupId>
          <artifactId>xwiki-commons-component-api</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>org.xwiki.commons</groupId>
      <artifactId>xwiki-commons-legacy-component-api</artifactId>
      <version>${commons.version}</version>
    </dependency>

    <!-- We need this dependency so that the wrapped module is built before this one -->
    <dependency>
      <groupId>org.xwiki.rendering</groupId>
      <artifactId>xwiki-rendering-api</artifactId>
      <version>${project.version}</version>
      <!-- We don't want to draw this dependency since we're wrapping it -->
      <scope>provided</scope>
      <exclusions>
        <!-- Trigger legacy version -->
        <exclusion>
          <groupId>org.xwiki.commons</groupId>
          <artifactId>xwiki-commons-component-api</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <!-- Testing Dependencies -->
    <dependency>
      <groupId>org.xwiki.commons</groupId>
      <artifactId>xwiki-commons-tool-test-component</artifactId>
      <version>${commons.version}</version>
      <scope>test</scope>
      <exclusions>
        <!-- Trigger legacy version -->
        <exclusion>
          <groupId>org.xwiki.commons</groupId>
          <artifactId>xwiki-commons-component-api</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
  </dependencies>
  <build>
    <plugins>
      <!-- Apply Compatibility Aspects -->
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>aspectj-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>backward-compatibility-aspects</id>
            <goals>
              <goal>compile</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <weaveDependencies>
            <weaveDependency>
              <groupId>org.xwiki.rendering</groupId>
              <artifactId>xwiki-rendering-api</artifactId>
            </weaveDependency>
          </weaveDependencies>
        </configuration>
      </plugin>
      <!-- Exclude AspectJ's builddef.lst file form the generated JAR since it's not useful there. -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <configuration>
          <excludes>
            <exclude>**/builddef.lst</exclude>
          </excludes>
        </configuration>
      </plugin>
      <plugin>
        <!-- Merge components.txt files -->
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <phase>process-classes</phase>
            <configuration>
              <target>
                <concat destfile="${project.build.directory}/classes/META-INF/components.txt" append="true">
                  <filelist dir="${basedir}/src/main/resources/META-INF/" files="components.txt" />
                </concat>
              </target>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <!-- Make sure we run the tests only with the aspectified JARs since otherwise components will be registered
           twice for example. -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <classpathDependencyExcludes>
            <classpathDependencyExcludes>org.xwiki.rendering:xwiki-rendering-api:jar</classpathDependencyExcludes>
          </classpathDependencyExcludes>
        </configuration>
      </plugin>
      <plugin>
        <groupId>fr.inria.gforge.spoon</groupId>
        <artifactId>spoon-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>spoon-main</id>
            <configuration>
              <processorProperties combine.children="append">
                <processorProperty>
                  <name>org.xwiki.tool.spoon.ComponentAnnotationProcessor</name>
                  <properties>
                    <!-- TODO: Remove when Spoon is fixed and doesn't emit the following warning when this property is
                         not specified:
                           warning: No value found for property 'componentsTxtPath' in processor ...
                         See https://github.com/INRIA/spoon/issues/3339
                    -->
                    <property>
                      <name>componentsTxtPath</name>
                      <value>target/classes/META-INF/components.txt</value>
                    </property>
                    <property>
                      <!-- Skip foreign declaration checks since we merge the components.txt -->
                      <name>skipForeignDeclarations</name>
                      <value>true</value>
                    </property>
                  </properties>
                </processorProperty>
              </processorProperties>
            </configuration>
          </execution>
          <execution>
            <id>spoon-test</id>
            <configuration>
              <!-- TODO: Remove once https://github.com/INRIA/spoon/issues/3583 is fixed -->
              <skip>true</skip>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>
