<?xml version="1.0"?>
<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/xsd/maven-4.0.0.xsd">

  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>org.camunda.bpm</groupId>
    <artifactId>camunda-database-settings</artifactId>
    <version>7.23.0</version>
    <relativePath>../database</relativePath>
  </parent>

  <artifactId>camunda-webapp-root</artifactId>
  <groupId>org.camunda.bpm.webapp</groupId>
  <packaging>pom</packaging>
  <name>Camunda Platform - Webapp - Root</name>

  <properties>
    <version.jetty>9.4.57.v20241219</version.jetty>

    <web.resources.override>src/main/runtime/default/webapp</web.resources.override>

    <history.level>full</history.level>

    <frontend.app.path>${project.build.directory}/webapp/</frontend.app.path>

    <frontend.development.cockpit.path>${frontend.app.path}</frontend.development.cockpit.path>
    <frontend.development.tasklist.path>${frontend.app.path}</frontend.development.tasklist.path>

    <exec.shell>bash</exec.shell>
    <exec.arg>-c</exec.arg>

    <skip.frontend.build>false</skip.frontend.build>

    <authorizationCheckRevokes>auto</authorizationCheckRevokes>

    <jdbcBatchProcessing>true</jdbcBatchProcessing>

    <license.includeTransitiveDependencies>false</license.includeTransitiveDependencies>

    <!-- frontend-sources artifact is for internal use only.
    Artifact generation is skipped when it comes to maven central deployment -->
    <skip-zip-frontend-sources>false</skip-zip-frontend-sources>
  </properties>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.camunda.bpm</groupId>
        <artifactId>camunda-core-internal-dependencies</artifactId>
        <version>${project.version}</version>
        <scope>import</scope>
        <type>pom</type>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>

    <dependency>
      <groupId>org.camunda.bpm</groupId>
      <artifactId>camunda-engine</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.camunda.commons</groupId>
      <artifactId>camunda-commons-logging</artifactId>
      <exclusions>
        <exclusion>
          <groupId>org.slf4j</groupId>
          <artifactId>slf4j-api</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <!-- tests -->

    <dependency>
      <groupId>org.camunda.commons</groupId>
      <artifactId>camunda-commons-testing</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>com.fasterxml.uuid</groupId>
      <artifactId>java-uuid-generator</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>com.h2database</groupId>
      <artifactId>h2</artifactId>
      <scope>test</scope>
    </dependency>

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

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

    <dependency>
      <groupId>org.eclipse.jetty</groupId>
      <artifactId>jetty-webapp</artifactId>
      <version>${version.jetty}</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.glassfish.jersey.core</groupId>
      <artifactId>jersey-common</artifactId>
      <version>${version.jersey2}</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-classic</artifactId>
      <scope>test</scope>
    </dependency>

  </dependencies>

  <build>
    <plugins>
      <plugin>
        <artifactId>maven-clean-plugin</artifactId>
        <inherited>false</inherited>
        <configuration>
          <filesets>
            <fileset>
              <directory>./frontend/target</directory>
            </fileset>
          </filesets>
        </configuration>
      </plugin>
      <plugin>
        <groupId>com.github.eirslett</groupId>
        <artifactId>frontend-maven-plugin</artifactId>
        <inherited>false</inherited>
        <configuration>
          <workingDirectory>./frontend</workingDirectory>
          <outputdir>${project.build.directory}/webapp</outputdir>
          <skip>${skip.frontend.build}</skip>
        </configuration>
        <executions>
          <execution>
            <id>install node and npm</id>
            <goals>
              <goal>install-node-and-npm</goal>
            </goals>
          </execution>
          <execution>
            <id>npm ci</id>
            <goals>
              <goal>npm</goal>
            </goals>
            <phase>generate-resources</phase>
            <configuration>
              <arguments>ci</arguments>
            </configuration>
          </execution>
          <execution>
            <id>Install HeroDevs XLTS dependencies</id>
            <goals>
              <goal>npm</goal>
            </goals>
            <phase>generate-resources</phase>
            <configuration>
              <arguments>run xlts-install</arguments>
            </configuration>
          </execution>
          <execution>
            <id>License check</id>
            <goals>
              <goal>npm</goal>
            </goals>
            <phase>generate-resources</phase>
            <configuration>
              <arguments>run license-check</arguments>
            </configuration>
          </execution>
          <execution>
            <id>Build</id>
            <goals>
              <goal>npm</goal>
            </goals>
            <phase>generate-resources</phase>
            <configuration>
              <arguments>run build</arguments>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
    <pluginManagement>
      <plugins>
        <!-- test plugins -->
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-surefire-plugin</artifactId>
          <configuration>
            <systemPropertyVariables>
              <myWorkingDir>${project.build.directory}</myWorkingDir>
            </systemPropertyVariables>
            <argLine>-XX:MaxMetaspaceSize=128m</argLine>
          </configuration>
        </plugin>

        <!-- code plugins -->
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-dependency-plugin</artifactId>
          <version>2.8</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-resources-plugin</artifactId>
          <version>2.6</version>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-antrun-plugin</artifactId>
          <version>1.8</version>
        </plugin>
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>build-helper-maven-plugin</artifactId>
          <version>1.9.1</version>
        </plugin>

        <plugin>
          <groupId>org.eclipse.jetty</groupId>
          <artifactId>jetty-maven-plugin</artifactId>
          <version>${version.jetty}</version>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-war-plugin</artifactId>
          <configuration>
            <webResources>
              <resource>
                <filtering>true</filtering>
                <directory>${web.resources.override}</directory>
              </resource>
              <resource>
                <filtering>false</filtering>
                <directory>target/webapp</directory>
                <excludes>
                  <exclude>**/*.html</exclude>
                </excludes>
              </resource>
              <resource>
                <filtering>true</filtering>
                <directory>target/webapp</directory>
                <!-- no filtering for favicon because linux destroys images through carriage return -->
                <includes>
                  <include>**/*.html</include>
                </includes>
              </resource>
            </webResources>
            <!-- exclude development resources (task forms etc.) -->
            <packagingExcludes>
              develop/**
            </packagingExcludes>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-jar-plugin</artifactId>
          <executions>
            <execution>
              <id>create-jar</id>
              <goals>
                <goal>jar</goal>
              </goals>
              <phase>package</phase>
              <configuration>
                <classifier>classes</classifier>
              </configuration>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-assembly-plugin</artifactId>
          <executions>
            <execution>
              <id>zip-frontend-sources</id>
              <phase>process-resources</phase>
              <goals>
                <goal>single</goal>
              </goals>
              <configuration>
                <skipAssembly>${skip-zip-frontend-sources}</skipAssembly>
                <descriptors>
                  <descriptor>assembly.xml</descriptor>
                </descriptors>
              </configuration>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>

  <modules>
    <module>assembly</module>
    <module>assembly-jakarta</module>
  </modules>

  <profiles>
    <profile>
      <id>skipFrontendBuild</id>
      <properties>
        <skip.frontend.build>true</skip.frontend.build>
      </properties>
    </profile>
  </profiles>

</project>
