<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>

    <groupId>io.confluent.controlcenter</groupId>
    <artifactId>control-center-frontend</artifactId>
    <packaging>jar</packaging>
    <version>7.6.2</version>
    <name>control-center-frontend</name>
    <url>https://www.confluent.io</url>

    <organization>
        <name>Confluent, Inc.</name>
        <url>https://www.confluent.io</url>
    </organization>

    <description>
        Control Center Frontend.
    </description>

    <properties>
        <exec-maven-plugin.version>1.2.1</exec-maven-plugin.version>
        <frontend-maven-plugin.version>1.9.1</frontend-maven-plugin.version>
        <frontend-maven-plugin.nodeVersion>v8.9.0</frontend-maven-plugin.nodeVersion>
        <!-- When bumping yarnVersion, upload the new version to confluent-packaging-tools due to Java 7/TLS 1.1 and GitHub.
             See yarnDownloadRoot in config block below, and ST-734 for more context -->
        <frontend-maven-plugin.yarnVersion>v1.5.1</frontend-maven-plugin.yarnVersion>
        <maven-assembly.version>2.6</maven-assembly.version>
        <io.confluent.blueway-fe.version>7.6.2</io.confluent.blueway-fe.version>
    </properties>

    <scm>
        <connection>scm:git:git://github.com/confluentinc/blueway-fe.git</connection>
        <developerConnection>scm:git:git@github.com:confluentinc/blueway-fe.git</developerConnection>
        <url>https://github.com/confluentinc/blueway-fe</url>
        <tag>HEAD</tag>
    </scm>

  <pluginRepositories>
      <pluginRepository>
          <id>confluent</id>
          <url>https://packages.confluent.io/maven/</url>
      </pluginRepository>
  </pluginRepositories>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-site-plugin</artifactId>
                    <version>3.7.1</version>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
          <plugin>
              <groupId>com.github.eirslett</groupId>
              <artifactId>frontend-maven-plugin</artifactId>
              <version>${frontend-maven-plugin.version}</version>
              <executions>
               <execution>
                      <id>setup yarn</id>
                      <goals>
                          <goal>install-node-and-yarn</goal>
                      </goals>
                      <phase>initialize</phase>
                      <configuration>
                          <nodeVersion>${frontend-maven-plugin.nodeVersion}</nodeVersion>
                          <yarnVersion>${frontend-maven-plugin.yarnVersion}</yarnVersion>
                          <nodeDownloadRoot>https://s3-us-west-2.amazonaws.com/confluent-packaging-tools-891377121322-us-west-2/nodejs/</nodeDownloadRoot>
                          <yarnDownloadRoot>https://s3-us-west-2.amazonaws.com/confluent-packaging-tools-891377121322-us-west-2/yarn/</yarnDownloadRoot>
                      </configuration>
                  </execution>
                  <execution>
                      <id>install node modules</id>
                      <goals>
                          <goal>yarn</goal>
                      </goals>
                      <phase>initialize</phase>
                      <configuration>
                          <arguments>in</arguments>
                      </configuration>
                  </execution>
                  <execution>
                      <id>set package.json version from pom.xml</id>
                      <goals>
                          <goal>yarn</goal>
                      </goals>
                      <phase>generate-sources</phase>
                      <configuration>
                          <arguments>version --no-git-tag-version --new-version ${io.confluent.blueway-fe.version}</arguments>
                      </configuration>
                  </execution>
             </executions>
          </plugin>

        <plugin>
            <artifactId>maven-resources-plugin</artifactId>
            <version>3.1.0</version>
            <executions>
                <execution>
                    <id>copy-dist</id>
                    <phase>initialize</phase>
                    <goals>
                        <goal>copy-resources</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>${project.build.directory}</outputDirectory>
                        <resources>          
                            <resource>
                                <directory>node_modules/@confluent/control-center/dist</directory>
                            </resource>
                        </resources>              
                    </configuration>            
                </execution>
                <execution>
                    <id>copy-licenses</id>
                    <phase>initialize</phase>
                    <goals>
                        <goal>copy-resources</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>${project.basedir}/licenses</outputDirectory>
                        <resources>          
                            <resource>
                                <directory>node_modules/@confluent/control-center/dist</directory>
                                <includes>
                                    <include>licenses.txt</include>
                                </includes>
                            </resource>
                        </resources>              
                    </configuration>            
                </execution>
            </executions>
        </plugin>

          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>${maven-assembly.version}</version>
            <configuration>
              <descriptors>
                <descriptor>assembly/package.xml</descriptor>
              </descriptors>
              <attach>false</attach>
            </configuration>
            <executions>
              <execution>
                <id>make-assembly</id>
                <phase>package</phase>
                <goals>
                  <goal>single</goal>
                </goals>
              </execution>
            </executions>
          </plugin>

        </plugins>
        <resources>
            <resource>
                <directory>${project.build.directory}</directory>
                <targetPath>io/confluent/controlcenter/rest/static/dist</targetPath>
                <excludes>
                    <exclude>index.html</exclude>
                </excludes>
            </resource>
            <resource>
                <directory>${project.build.directory}</directory>
                <targetPath>io/confluent/controlcenter/rest/static</targetPath>
                <includes>
                    <include>index.html</include>
                </includes>
            </resource>
        </resources>

        <extensions>
            <extension>
                <groupId>io.confluent</groupId>
                <artifactId>aws-maven</artifactId>
                <version>1.0.0</version>
            </extension>
        </extensions>
    </build>

    <distributionManagement>
        <repository>
            <id>aws-release</id>
            <name>AWS Release Repository</name>
            <url>${confluent.release.repo}</url>
        </repository>
        <snapshotRepository>
            <id>aws-snapshot</id>
            <name>AWS Snapshot Repository</name>
            <url>${confluent.snapshot.repo}</url>
        </snapshotRepository>
    </distributionManagement>

</project>
