<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>org.exoplatform.addons.jwt</groupId>
    <artifactId>jwt-authentication-parent</artifactId>
    <version>7.2.x-SNAPSHOT</version>
  </parent>
  <artifactId>jwt-authentication-packaging</artifactId>

  <packaging>pom</packaging>
  <name>Jwt Authentication - Packaging</name>
  <dependencies>
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>jwt-authentication-services</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>io.meeds.distribution</groupId>
      <artifactId>plf-tomcat-resources</artifactId>
      <type>zip</type>
      <scope>runtime</scope>
    </dependency>
  </dependencies>
  <build>
    <finalName>jwt-authentication-addon</finalName>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <id>unpack-jaas</id>
            <phase>package</phase>
            <goals>
              <goal>unpack</goal>
            </goals>
            <configuration>
              <artifactItems>
                <artifactItem>
                  <groupId>io.meeds.distribution</groupId>
                  <artifactId>plf-tomcat-resources</artifactId>
                  <type>zip</type>
                  <overWrite>false</overWrite>
                  <outputDirectory>${project.build.directory}/tomcat-resources</outputDirectory>
                </artifactItem>
              </artifactItems>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>com.google.code.maven-replacer-plugin</groupId>
        <artifactId>replacer</artifactId>
        <version>1.5.3</version>
        <executions>
          <execution>
            <id>replace-eXoWCMResources</id>
            <phase>package</phase>
            <goals>
              <goal>replace</goal>
            </goals>
            <configuration>
              <file>${project.build.directory}/tomcat-resources/conf/jaas.conf</file>
              <replacements>
                <replacement>
                  <token>org.exoplatform.services.security.j2ee.TomcatLoginModule required</token>
                  <value>org.exoplatform.addons.jwt.JwtLoginModule required
    portalContainerName=portal
    realmName=gatein-domain;
  org.exoplatform.services.security.j2ee.TomcatLoginModule requisite</value>
                </replacement>
              </replacements>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-assembly-plugin</artifactId>
        <executions>
          <execution>
            <id>package-extension</id>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
            <configuration>
              <appendAssemblyId>false</appendAssemblyId>
              <descriptors>
                <descriptor>src/main/assemblies/assembly.xml</descriptor>
              </descriptors>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>
