<?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>io.orqueio.bpm</groupId>
    <artifactId>orqueio-parent</artifactId>
    <relativePath>../../parent</relativePath>
    <version>1.0.4</version>
  </parent>
<description>orqueio-webapp-webjar</description>
  <groupId>io.orqueio.bpm.webapp</groupId>
  <version>1.0.4</version>
  <artifactId>orqueio-webapp-webjar</artifactId>
  <packaging>jar</packaging>


  <name>Orque IO Platform - webapp - webjar</name>

  <properties>
    <skipTests>true</skipTests>
  </properties>

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

  <!-- add dependency so this is run after the war was build -->
  <dependencies>
    <dependency>
      <groupId>io.orqueio.bpm.webapp</groupId>
      <artifactId>orqueio-webapp-jakarta</artifactId>
      <version>${project.parent.version}</version>
      <type>jar</type>
      <classifier>classes</classifier>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <!-- first fetch and unpack the war -->
      <plugin>
        <artifactId>maven-dependency-plugin</artifactId>
        <version>2.8</version>
        <executions>
          <execution>
            <id>unpack</id>
            <phase>process-sources</phase>
            <goals>
              <goal>unpack</goal>
            </goals>
            <configuration>
              <artifactItems>
                <artifactItem>
                  <groupId>io.orqueio.bpm.webapp</groupId>
                  <artifactId>orqueio-webapp-jakarta</artifactId>
                  <version>${project.parent.version}</version>
                  <type>war</type>
                  <overWrite>true</overWrite>
                  <outputDirectory>${project.build.outputDirectory}/META-INF/resources/webjars/orqueio</outputDirectory>
                  <excludes>META-INF/**</excludes>
                </artifactItem>
              </artifactItems>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <!-- then remove the WEB-INF part except the security.json -->
      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <version>1.8</version>
        <executions>
          <execution>
            <phase>generate-resources</phase>
            <configuration>
            <skip>${skip.frontend.build}</skip>
              <target>
                <move file="${project.build.outputDirectory}/META-INF/resources/webjars/orqueio/WEB-INF/securityFilterRules.json" todir="${project.build.outputDirectory}/META-INF/resources/webjars/orqueio/" />
                <delete dir="${project.build.outputDirectory}/META-INF/resources/webjars/orqueio/WEB-INF" />
                <move file="${project.build.outputDirectory}/META-INF/resources/webjars/orqueio/plugin" tofile="${project.build.outputDirectory}/META-INF/resources/plugin" verbose="true" />
                <!-- add orqueio-welcome page -->
                <copy todir="${project.build.outputDirectory}/META-INF/resources/orqueio-welcome/">
                  <fileset dir="../orqueio-welcome/" />
                </copy>
              </target>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <id>skipFrontendBuild</id>
      <properties>
        <skip.frontend.build>true</skip.frontend.build>
      </properties>
    </profile>
  </profiles>
  <licenses>
    <license>
      <name>The Apache Software License, Version 2.0</name>
      <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
    </license>
  </licenses>

  <organization>
    <name>Orque IO</name>
    <url>https://www.orqueio.io</url>
  </organization>

  <url>https://www.orqueio.io</url>

  <developers>
    <developer>
      <id>orqueio.io</id>
      <name>Orque IO Platform Community</name>
      <organization>orqueio.io</organization>
      <organizationUrl>https://www.orqueio.io</organizationUrl>
    </developer>
  </developers>

  <scm>
    <url>https://github.com/orqueio/orqueio</url>
    <connection>scm:git:git@github.com:orqueio/orqueio.git</connection>
    <developerConnection>scm:git:git@github.com:orqueio/orqueio.git</developerConnection>
    <tag>HEAD</tag>
  </scm>
</project>
