<?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>com.atlassian.pom</groupId>
    <artifactId>public-pom</artifactId>
    <version>6.3.7</version>
  </parent>

  <groupId>com.atlassian.johnson-frontend</groupId>
  <artifactId>johnson-frontend-parent</artifactId>
  <packaging>pom</packaging>
  <version>3.4.2-SNAPSHOT</version>

  <name>Johnson frontend</name>
  <description>This is a frontend module for Johnson framework</description>

  <properties>
    <amps.version>8.16.0</amps.version>
    <nodeVersion>v16.15.0</nodeVersion>
    <npmVersion>8.12.1</npmVersion>
    <frontend.build.mode>production</frontend.build.mode>
    <frontend.build.cmd>build</frontend.build.cmd>
  </properties>

  <build>
    <plugins>
        <plugin>
          <groupId>com.atlassian.maven.plugins</groupId>
          <artifactId>amps-maven-plugin</artifactId>
          <version>${amps.version}</version>
          <executions>
            <execution>
              <id>copy-fe-module-manifests</id>
              <phase>prepare-package</phase>
              <goals>
                <goal>copy-fe-module-manifests</goal>
              </goals>
            </execution>
            <execution>
              <id>report-fe-manifest-associations</id>
              <goals>
                <goal>report-fe-manifest-associations</goal>
              </goals>
            </execution>
          </executions>
          <configuration>
            <includedFeModuleManifests>
              <!-- Required to know what is development only & useful for other future projects -->
              <includedFeModuleManifest>${project.basedir}/package.json</includedFeModuleManifest>
              <!-- Required so all versions of all transitive dependencies are declared -->
              <includedFeModuleManifest>${project.basedir}/package-lock.json</includedFeModuleManifest>
            </includedFeModuleManifests>
            <feManifestAssociations>
              <feManifestAssociation>
                <outputDirectoryFilesDeclaration>
                  ${project.basedir}/fe-associations-declaration.json
                </outputDirectoryFilesDeclaration>
              </feManifestAssociation>
            </feManifestAssociations>
          </configuration>
        </plugin>
      <plugin>
        <groupId>com.github.eirslett</groupId>
        <artifactId>frontend-maven-plugin</artifactId>
        <version>1.5</version>
        <configuration>
          <nodeVersion>${nodeVersion}</nodeVersion>
          <npmVersion>${npmVersion}</npmVersion>
          <installDirectory>${project.parent.build.directory}</installDirectory>
          <workingDirectory>${project.parent.basedir}</workingDirectory>
        </configuration>
        <executions>
          <execution>
            <id>install node and npm</id>
            <goals>
              <goal>install-node-and-npm</goal>
            </goals>
            <phase>initialize</phase>
          </execution>
          <execution>
            <id>run-build-for-frontend</id>
            <goals>
              <goal>npm</goal>
            </goals>
            <configuration>
              <arguments>run ${frontend.build.cmd}</arguments>
            </configuration>
            <phase>generate-resources</phase>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-resources-plugin</artifactId>
        <version>3.2.0</version>
        <executions>
          <execution>
            <id>include-frontend-build</id>
            <phase>process-resources</phase>
            <goals>
              <goal>resources</goal>
            </goals>
            <configuration>
              <resources>
                <resource>
                  <directory>${project.basedir}/build</directory>
                  <includes>
                    <include>index.js</include>
                    <include>johnson.css</include>
                  </includes>
                </resource>
              </resources>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>
