<?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.crowd</groupId>
        <artifactId>atlassian-embedded-crowd</artifactId>
        <version>8.0.0-platform-01</version>
    </parent>
    <artifactId>service-accounts-plugin</artifactId>


    <name>Atlassian Embedded Crowd - Service Accounts Plugin</name>
    <description>Provides functionality related to Service Accounts.</description>
    <packaging>atlassian-plugin</packaging>

    <dependencies>
        <dependency>
          <groupId>com.atlassian.crowd</groupId>
          <artifactId>embedded-crowd-admin</artifactId>
        </dependency>
        <dependency>
            <groupId>com.atlassian.crowd</groupId>
            <artifactId>embedded-crowd-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.crowd</groupId>
            <artifactId>embedded-crowd-spi</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.crowd</groupId>
            <artifactId>embedded-crowd-core</artifactId>
            <scope>provided</scope>
            <exclusions>
                <exclusion>
                    <groupId>jakarta.servlet</groupId>
                    <artifactId>jakarta.servlet-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.atlassian.crowd</groupId>
            <artifactId>crowd-core</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.oauth2</groupId>
            <artifactId>oauth2-provider-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.oauth2</groupId>
            <artifactId>oauth2-scopes-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>jakarta.validation</groupId>
            <artifactId>jakarta.validation-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>jakarta.annotation</groupId>
            <artifactId>jakarta.annotation-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.annotations</groupId>
            <artifactId>atlassian-annotations</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.plugins</groupId>
            <artifactId>atlassian-plugins-osgi-javaconfig</artifactId>
        </dependency>
        <dependency>
            <groupId>com.atlassian.plugins.rest</groupId>
            <artifactId>atlassian-rest-v2-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.soy</groupId>
            <artifactId>soy-template-renderer-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.plugins</groupId>
            <artifactId>atlassian-plugins-webresource-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.json</groupId>
            <artifactId>atlassian-json-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>tools.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>tools.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <scope>provided</scope>
        </dependency>
      <!-- OSGi Java Config dependencies -->
        <dependency>
            <groupId>org.apache.felix</groupId>
            <artifactId>org.apache.felix.framework</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <scope>provided</scope>
        </dependency>

        <!-- Spring dependencies -->
        <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-webmvc</artifactId>
          <scope>provided</scope>
        </dependency>
        <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-context-support</artifactId>
          <scope>provided</scope>
        </dependency>
        <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-web</artifactId>
          <scope>provided</scope>
        </dependency>
        <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-core</artifactId>
          <scope>provided</scope>
        </dependency>
       <dependency>
         <groupId>jakarta.inject</groupId>
         <artifactId>jakarta.inject-api</artifactId>
         <scope>provided</scope>
       </dependency>

      <dependency>
          <!-- commons-logging is used by Spring -->
          <groupId>commons-logging</groupId>
          <artifactId>commons-logging</artifactId>
          <version>1.3.5</version>
          <scope>provided</scope>
        </dependency>

        <dependency>
          <groupId>org.apache.commons</groupId>
          <artifactId>commons-lang3</artifactId>
          <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-undertow</artifactId>
            <version>${jboss.resteasy.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-jackson2-provider</artifactId>
            <version>${jboss.resteasy.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.core</groupId>
            <artifactId>jersey-client</artifactId>
            <scope>test</scope>
        </dependency>

    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>com.atlassian.maven.plugins</groupId>
                <artifactId>amps-maven-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <containerId>${amps.containerId}</containerId>
                    <output>${project.build.directory}/output.log</output>
                    <!--
                      QuickReload is disabled because its batched-mode script throws
                      "TypeError: c(...) is not a function" as an unhandled promise rejection on every
                      page load of the RefApp shipped with platform 9. Cypress fails a test on any
                      uncaught application error, so the e2e suite cannot run with it installed.
                      Both 6.2.1 (the AMPS default) and the latest 6.3.0 are affected. Re-enable once a
                      compatible QuickReload is released.
                    -->
                    <enableQuickReload>false</enableQuickReload>

                    <!-- See here for an explanation of default instructions: -->
                    <!-- https://developer.atlassian.com/docs/advanced-topics/configuration-of-instructions-in-atlassian-plugins -->
                    <instructions>
                        <Atlassian-Plugin-Key>${atlassian.plugin.key}</Atlassian-Plugin-Key>

                        <!-- Add package import here -->
                        <Import-Package>org.springframework.osgi.*;resolution:="optional",
                            org.eclipse.gemini.blueprint.*;resolution:="optional",
                            com.atlassian.crowd.embedded.api.*,
                            com.atlassian.crowd.embedded.spi.*,
                            com.atlassian.crowd.manager.service,
                            com.atlassian.crowd.model.service,
                            com.atlassian.crowd.search,
                            com.atlassian.annotations;resolution:="optional",
                            com.atlassian.event.api;resolution:="optional",
                            com.atlassian.analytics.api.annotations;resolution:="optional",
                            javax.xml.*;resolution:=optional,
                            !javax.*,
                            *
                        </Import-Package>

                        <!-- Ensure plugin is spring powered -->
                        <Spring-Context>*</Spring-Context>
                        <Atlassian-Scan-Folders>META-INF/plugin-descriptors</Atlassian-Scan-Folders>
                    </instructions>

                    <products>
                        <product>
                            <id>refapp</id>
                            <version>${refapp.version}</version>
                            <jvmArgs>-Datlassian.darkfeature.embedded.crowd.directory.azuread.enabled=true -Datlassian.refapp.websudo.disabled=true</jvmArgs>
                            <libArtifacts>
                              <!-- crowd-ldap calls into crowd-api, so both have to come from the same
                                   Crowd release rather than the older one shipped with the RefApp. -->
                              <libArtifact>
                                <groupId>com.atlassian.crowd</groupId>
                                <artifactId>crowd-api</artifactId>
                              </libArtifact>
                              <libArtifact>
                                <groupId>com.atlassian.crowd</groupId>
                                <artifactId>crowd-common</artifactId>
                              </libArtifact>
                              <libArtifact>
                                <groupId>com.atlassian.crowd</groupId>
                                <artifactId>crowd-ldap</artifactId>
                              </libArtifact>
                            </libArtifacts>
                          <bundledArtifacts>
                            <bundledArtifact>
                              <groupId>com.atlassian.crowd</groupId>
                              <artifactId>embedded-crowd-refapp-plugin</artifactId>
                            </bundledArtifact>
                          </bundledArtifacts>
                          <pluginArtifacts>
                            <pluginArtifact>
                              <groupId>com.atlassian.crowd</groupId>
                              <artifactId>embedded-crowd-admin-plugin</artifactId>
                            </pluginArtifact>
                            <pluginArtifact>
                              <groupId>com.atlassian.crowd</groupId>
                              <artifactId>service-accounts-plugin</artifactId>
                            </pluginArtifact>
                          </pluginArtifacts>
                        </product>
                    </products>

                    <includedFeModuleManifests>
                        <includedFeModuleManifest>package.json</includedFeModuleManifest>
                        <includedFeModuleManifest>${project.basedir}/yarn.lock</includedFeModuleManifest>
                    </includedFeModuleManifests>
                    <skipVerifyFeManifestAssociations>true</skipVerifyFeManifestAssociations>
                    <feManifestAssociations>
                        <feManifestAssociation>
                            <packageName>@atlassian/dc.service-accounts-plugin</packageName>
                            <manuallyVerifiedEveryFileHasItsDependenciesDeclaredInTheManifest>
                                <outputDirectoryFiles />
                            </manuallyVerifiedEveryFileHasItsDependenciesDeclaredInTheManifest>
                        </feManifestAssociation>
                    </feManifestAssociations>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.github.eirslett</groupId>
                <artifactId>frontend-maven-plugin</artifactId>
                <version>${frontend.maven.plugin.version}</version>
                <configuration>
                    <nodeVersion>${frontend.node.version}</nodeVersion>
                    <yarnVersion>${frontend.yarn.version}</yarnVersion>
                    <installDirectory>${frontend.maven.plugin.install.directory}</installDirectory>
                    <workingDirectory>${frontend.working.directory}</workingDirectory>
                    <environmentVariables>
                        <NODE_ENV>${frontend.build.mode}</NODE_ENV>
                    </environmentVariables>
                </configuration>
                <executions>
                    <execution>
                        <id>step-1-install-node-and-yarn</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>install-node-and-yarn</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>step-2-install-dependencies</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>yarn</goal>
                        </goals>
                        <configuration>
                            <arguments>${frontend.cmd.install}</arguments>
                            <environmentVariables>
                                <NODE_ENV>development</NODE_ENV>
                            </environmentVariables>
                        </configuration>
                    </execution>
                    <execution>
                        <id>run-tests</id>
                        <phase>test</phase>
                        <goals>
                            <goal>yarn</goal>
                        </goals>
                        <configuration>
                            <arguments>ci:test</arguments>
                            <environmentVariables>
                                <NODE_ENV>development</NODE_ENV>
                            </environmentVariables>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    <profiles>
         <profile>
            <id>build-mode-is-set-by-node-env</id>
            <activation>
                <property>
                    <name>env.NODE_ENV</name>
                </property>
            </activation>
            <properties>
                <frontend.build.mode>${env.NODE_ENV}</frontend.build.mode>
            </properties>
        </profile>
        <profile>
            <id>build</id>
            <activation>
                <property>
                    <name>!watchMode</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.github.eirslett</groupId>
                        <artifactId>frontend-maven-plugin</artifactId>
                        <configuration>
                            <installDirectory>${frontend.maven.plugin.install.directory}</installDirectory>
                            <workingDirectory>${frontend.working.directory}</workingDirectory>
                        </configuration>
                        <executions>
                            <execution>
                                <id>step-3-build-frontend</id>
                                <phase>process-resources</phase>
                                <goals>
                                    <goal>yarn</goal>
                                </goals>
                                <configuration>
                                    <arguments>${frontend.cmd.build}</arguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>watch-prepare</id>
            <activation>
                <property>
                    <name>watchMode</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.github.eirslett</groupId>
                        <artifactId>frontend-maven-plugin</artifactId>
                        <configuration>
                            <installDirectory>${frontend.maven.plugin.install.directory}</installDirectory>
                            <workingDirectory>${frontend.working.directory}</workingDirectory>
                        </configuration>
                        <executions>
                            <execution>
                                <id>step-3-watch-prepare-frontend</id>
                                <phase>process-resources</phase>
                                <goals>
                                    <goal>yarn</goal>
                                </goals>
                                <configuration>
                                    <arguments>${frontend.cmd.watch.prepare}</arguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>e2e</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.github.eirslett</groupId>
                        <artifactId>frontend-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>run-e2e-tests</id>
                                <phase>test</phase>
                                <goals>
                                    <goal>yarn</goal>
                                </goals>
                                <configuration>
                                    <arguments>test:e2e:run</arguments>
                                    <environmentVariables>
                                        <NODE_ENV>development</NODE_ENV>
                                    </environmentVariables>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    <properties>
        <atlassian.plugin.key>${project.groupId}.${project.artifactId}</atlassian.plugin.key>
        <jboss.resteasy.version>6.2.15.Final</jboss.resteasy.version>
        <frontend.maven.plugin.version>1.15.10-atlassian-2</frontend.maven.plugin.version> <!-- TODO change it to 1.15-.. fork for gathering stats when the version is stable https://packages.atlassian.com/ui/repos/tree/General/maven-3rdparty-local/com/github/eirslett/frontend-maven-plugin/1.15.10-atlassian-2/frontend-maven-plugin-1.15.10-atlassian-2.pom -->
        <frontend.maven.plugin.install.directory>${project.build.directory}</frontend.maven.plugin.install.directory>
        <frontend.working.directory>${project.basedir}</frontend.working.directory>
        <frontend.node.version>v22.15.0</frontend.node.version>
        <frontend.yarn.version>v1.22.19</frontend.yarn.version> <!-- TODO change it to 4.9.1 later -->
        <frontend.cmd.install>install</frontend.cmd.install>
        <frontend.cmd.build>build</frontend.cmd.build>
        <frontend.cmd.watch.prepare>start:watch-prepare</frontend.cmd.watch.prepare>
        <frontend.build.mode>production</frontend.build.mode>
    </properties>

</project>
