<?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/maven-v4_0_0.xsd">

  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>org.jboss.eap</groupId>
    <artifactId>javadocs-parent</artifactId>
    <!--
    Maintain separation between the artifact id and the version to help prevent
    merge conflicts between commits changing the GA and those changing the V.
    -->
    <version>7.2.0.Beta-redhat-00002</version>
  </parent>

  <artifactId>javadocs-builder</artifactId>
  <packaging>pom</packaging>

  <name>JBoss EAP aggregate javadocs builder</name>
  <description>Generate JBoss EAP aggregate javadocs pom</description>

  <dependencies>
    <dependency>
      <groupId>org.wildfly</groupId>
      <artifactId>javadocs-pom-generator-plugin</artifactId>
      <version>${version.org.wildfly.javadocs-pom-generator-plugin}</version>
    </dependency>
  </dependencies>

  <build>
    <defaultGoal>verify</defaultGoal>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-invoker-plugin</artifactId>
        <version>3.1.0</version>
        <executions>
          <execution>
            <id>generate-javadocs-pom-file</id>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <pomIncludes>
                <pomInclude>generate-javadocs-pom-file/pom.xml</pomInclude>
              </pomIncludes>
              <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
              <settingsFile>src/it/settings.xml</settingsFile>
              <localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
              <filterProperties>
                <javadocArtifactId>${javadocArtifactId}</javadocArtifactId><!--TBD move template-pom.xml to resources to filter it to replace artifactId or change plugin to replace in code ?-->
                <version.org.wildfly.javadocs-pom-generator-plugin>${version.org.wildfly.javadocs-pom-generator-plugin}</version.org.wildfly.javadocs-pom-generator-plugin>
                <server.version>${project.version}</server.version>
                <version.org.wildfly.core>${version.org.wildfly.core}</version.org.wildfly.core>
              </filterProperties>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <id>javadocs</id>
      <activation>
        <property>
          <name>javadocs</name>
        </property>
      </activation>
      <build>
        <defaultGoal>verify</defaultGoal>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-invoker-plugin</artifactId>
            <version>3.1.0</version>
            <executions>
              <execution>
                <id>generate-javadocs-file</id>
                <goals>
                  <goal>run</goal>
                </goals>
                <configuration>
                  <mergeUserSettings>true</mergeUserSettings><!-- to get remote repositories -->
                  <pomIncludes>
                    <pomInclude>generate-javadocs-file/pom.xml</pomInclude>
                  </pomIncludes>
                  <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
                  <settingsFile>src/it/settings.xml</settingsFile>
                  <localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
                  <filterProperties>
                    <targetReleaseVersion>${targetReleaseVersion}</targetReleaseVersion>
                    <version.javadoc.plugin>${version.javadoc.plugin}</version.javadoc.plugin>
                  </filterProperties>
                  <scriptVariables>
                    <groupId>${project.groupId}</groupId>
                    <artifactId>${javadocArtifactId}</artifactId>
                    <classifier>javadoc</classifier>
                    <type>jar</type>
                    <version>${project.version}</version>
                  </scriptVariables>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

</project>
