<?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>
    <relativePath>../pom.xml</relativePath>
    <!--
    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.3.3.GA-redhat-00004</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>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-invoker-plugin</artifactId>
          <version>3.1.0</version>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>

  <profiles>

    <!-- Javadocs for ee-dist -->
    <profile>
      <id>ee-dist-javadocs</id>
      <activation>
        <property>
          <name>!javadocs.ee-dist.skip</name>
        </property>
      </activation>
      <build>
        <defaultGoal>verify</defaultGoal>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-invoker-plugin</artifactId>
            <executions>
              <!-- generate javadocs pom for wildfly ee-dist -->
              <execution>
                <id>generate-ee-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-ee-dist-generate-pom</cloneProjectsTo>
                  <settingsFile>src/it/settings.xml</settingsFile>
                  <localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
                  <filterProperties>
                    <server.dist>wildfly-ee-dist</server.dist>
                    <server.version>${project.version}</server.version>
                    <core.version>${version.org.wildfly.core}</core.version>
                    <template.filename>template-ee-pom.xml</template.filename>
                    <version.org.wildfly.javadocs-pom-generator-plugin>${version.org.wildfly.javadocs-pom-generator-plugin}</version.org.wildfly.javadocs-pom-generator-plugin>
                  </filterProperties>
                  <scriptVariables>
                    <targetFolder>generate-ee-javadocs-file</targetFolder>
                  </scriptVariables>
                </configuration>
              </execution>
              <!-- generate javadocs for wildfly ee-dist -->
              <execution>
                <id>generate-ee-javadocs-file</id>
                <goals>
                  <goal>run</goal>
                </goals>
                <configuration>
                  <mergeUserSettings>true</mergeUserSettings><!-- to get remote repositories -->
                  <pomIncludes>
                    <pomInclude>generate-ee-javadocs-file/pom.xml</pomInclude>
                  </pomIncludes>
                  <cloneProjectsTo>${project.build.directory}/it-ee-dist-generate-javadocs</cloneProjectsTo>
                  <settingsFile>src/it/settings.xml</settingsFile>
                  <!--localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath-->
                  <filterProperties>
                    <target.release.version>${javadocs.target.release.version}</target.release.version>
                    <version.javadoc.plugin>${version.javadoc.plugin}</version.javadoc.plugin>
                  </filterProperties>
                  <scriptVariables>
                    <groupId>${project.groupId}</groupId>
                    <artifactId>${javadocs.ee-dist.artifactId}</artifactId>
                    <classifier>javadoc</classifier>
                    <type>jar</type>
                    <version>${project.version}</version>
                  </scriptVariables>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

    <!-- Javadocs for dist -->
    <profile>
      <id>dist-javadocs</id>
      <activation>
        <property>
          <name>!javadocs.dist.skip</name>
        </property>
      </activation>
      <build>
        <defaultGoal>verify</defaultGoal>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-invoker-plugin</artifactId>
            <executions>
              <!-- generate javadocs pom for wildfly dist -->
              <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-dist-generate-pom</cloneProjectsTo>
                  <settingsFile>src/it/settings.xml</settingsFile>
                  <localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
                  <filterProperties>
                    <server.dist>wildfly-dist</server.dist>
                    <server.version>${project.version}</server.version>
                    <core.version>${version.org.wildfly.core}</core.version>
                    <template.filename>template-pom.xml</template.filename>
                    <version.org.wildfly.javadocs-pom-generator-plugin>${version.org.wildfly.javadocs-pom-generator-plugin}</version.org.wildfly.javadocs-pom-generator-plugin>
                  </filterProperties>
                  <scriptVariables>
                    <targetFolder>generate-javadocs-file</targetFolder>
                  </scriptVariables>
                </configuration>
              </execution>
              <!-- generate javadocs for wildfly dist -->
              <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-dist-generate-javadocs</cloneProjectsTo>
                  <settingsFile>src/it/settings.xml</settingsFile>
                  <!--localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath-->
                  <filterProperties>
                    <target.release.version>${javadocs.target.release.version}</target.release.version>
                    <xp.target.release.version>${javadocs.xp.target.release.version}</xp.target.release.version>
                    <version.javadoc.plugin>${version.javadoc.plugin}</version.javadoc.plugin>
                  </filterProperties>
                  <scriptVariables>
                    <groupId>${project.groupId}</groupId>
                    <artifactId>${javadocs.dist.artifactId}</artifactId>
                    <classifier>javadoc</classifier>
                    <type>jar</type>
                    <version>${project.version}</version>
                  </scriptVariables>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

  </profiles>
</project>
