<?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/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>org.camunda</groupId>
    <artifactId>camunda-bpm-release-parent</artifactId>
    <version>2.3.0</version>
    <relativePath />
  </parent>

  <groupId>org.camunda.feel</groupId>
  <artifactId>feel-engine</artifactId>
  <version>1.18.0</version>
  <name>FEEL Scala Engine</name>

  <properties>
    <scala.version>2.13.14</scala.version>
    <scala.binary.version>2.13.6</scala.binary.version>
    <version.log4j>2.23.1</version.log4j>
    <version.uuid>5.1.0</version.uuid>

    <plugin.version.shade>3.6.0</plugin.version.shade>
    <plugin.version.gpg>1.6</plugin.version.gpg>
    <plugin.version.javadoc>2.9.1</plugin.version.javadoc>

    <encoding>UTF-8</encoding>

    <project.build.sourceEncoding>${encoding}</project.build.sourceEncoding>
    <project.build.resourceEncoding>${encoding}</project.build.resourceEncoding>
    <skip-third-party-bom>false</skip-third-party-bom>
  </properties>

  <dependencyManagement>
    <dependencies>

      <dependency>
        <groupId>org.scala-lang</groupId>
        <artifactId>scala-library</artifactId>
        <version>${scala.version}</version>
      </dependency>

      <dependency>
        <groupId>org.scalatest</groupId>
        <artifactId>scalatest_2.13</artifactId>
        <version>3.2.10</version>
      </dependency>

      <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.7.25</version>
      </dependency>

      <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-api</artifactId>
        <version>${version.log4j}</version>
      </dependency>

      <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-core</artifactId>
        <version>${version.log4j}</version>
      </dependency>

      <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-slf4j-impl</artifactId>
        <version>${version.log4j}</version>
      </dependency>

    </dependencies>
  </dependencyManagement>

  <dependencies>

    <dependency>
      <groupId>org.scala-lang</groupId>
      <artifactId>scala-library</artifactId>
    </dependency>

    <dependency>
      <groupId>com.lihaoyi</groupId>
      <artifactId>fastparse_2.13</artifactId>
      <version>3.1.1</version>
    </dependency>

    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
    </dependency>

    <dependency>
      <groupId>com.fasterxml.uuid</groupId>
      <artifactId>java-uuid-generator</artifactId>
      <version>${version.uuid}</version>
    </dependency>

    <dependency>
      <groupId>org.scalatest</groupId>
      <artifactId>scalatest_2.13</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-api</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-core</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-slf4j-impl</artifactId>
      <scope>test</scope>
    </dependency>

  </dependencies>

  <build>
    <defaultGoal>clean install</defaultGoal>

    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-site-plugin</artifactId>
          <version>3.20.0</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-project-info-reports-plugin</artifactId>
          <version>3.7.0</version>
        </plugin>
        <plugin>
          <artifactId>maven-jar-plugin</artifactId>
          <version>3.4.2</version>
          <configuration>
            <useDefaultManifestFile>false</useDefaultManifestFile>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-gpg-plugin</artifactId>
          <configuration>
            <gpgArguments>
              <arg>--pinentry-mode</arg>
              <arg>loopback</arg>
            </gpgArguments>
          </configuration>
        </plugin>

      </plugins>
    </pluginManagement>

    <plugins>

      <plugin>
        <groupId>net.alchim31.maven</groupId>
        <artifactId>scala-maven-plugin</artifactId>
        <version>4.9.2</version>
        <configuration>
          <scalaCompatVersion>${scala.binary.version}</scalaCompatVersion>
          <scalaVersion>${scala.version}</scalaVersion>
        </configuration>
        <executions>
          <execution>
            <id>scala-compile-first</id>
            <phase>process-resources</phase>
            <goals>
              <goal>add-source</goal>
              <goal>compile</goal>
            </goals>
          </execution>
          <execution>
            <id>scala-test-compile</id>
            <phase>process-test-resources</phase>
            <goals>
              <goal>testCompile</goal>
            </goals>
          </execution>
          <execution>
            <id>scala-doc</id>
            <phase>package</phase>
            <goals>
              <goal>doc-jar</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>3.5.0</version>
        <configuration>
          <skipTests>true</skipTests>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.scalatest</groupId>
        <artifactId>scalatest-maven-plugin</artifactId>
        <version>2.2.0</version>
        <configuration>
          <reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
          <junitxml>.</junitxml>
          <filereports>TestSuite.txt</filereports>
        </configuration>
        <executions>
          <execution>
            <id>test</id>
            <goals>
              <goal>test</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <version>3.7.1</version>
        <configuration>
          <descriptors>
            <descriptor>assembly-complete.xml</descriptor>
          </descriptors>
        </configuration>
        <executions>
          <execution>
            <id>make-assembly</id>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.antipathy</groupId>
        <artifactId>mvn-scalafmt_2.13</artifactId>
        <version>1.1.1684076452.9f83818</version>
        <configuration>
          <configLocation>${project.basedir}/.scalafmt.conf</configLocation>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>clirr-maven-plugin</artifactId>
        <version>2.8</version>
        <executions>
          <execution>
            <goals>
              <goal>check</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <excludes>
            <!-- public API only -->
            <exclude>org/camunda/feel/impl/**</exclude>
            <!-- Clirr has problems with the inner classes that are generated by Scala (ending with "$") -->
            <exclude>org/camunda/feel/**/*$</exclude>
            <exclude>org/camunda/feel/**/*$anonfun*</exclude>
          </excludes>
          <ignored>
            <ignored>
              <!-- ignore changes of the FEEL engine constructor, Java application should use the builder instead -->
              <className>org/camunda/feel/FeelEngine</className>
              <differenceType>7004</differenceType>
              <method>FeelEngine(*)</method>
            </ignored>
            <!-- ignore changes of a private generated method -->
            <ignored>
              <className>org/camunda/feel/FeelEngine</className>
              <differenceType>7006</differenceType>
              <method>* $anonfun*(*)</method>
              <to>*</to>
            </ignored>
            <!-- Clirr has problems with the inner methods that are generated by Scala (containing "$") -->
            <ignored>
              <className>org/camunda/feel/FeelEngine</className>
              <differenceType>7004</differenceType>
              <method>* $anonfun*(*)</method>
            </ignored>
            <ignored>
              <className>org/camunda/feel/**</className>
              <differenceType>7002</differenceType>
              <method>* $anonfun*(*)</method>
            </ignored>
            <ignored>
              <!-- allow new methods in the interface-->
              <className>org/camunda/feel/**</className>
              <differenceType>7012</differenceType>
              <method>*</method>
            </ignored>
            <!-- ignore changes in the abstract syntax tree - only used by the interpreter -->
            <ignored>
              <className>org/camunda/feel/syntaxtree/Interval</className>
              <differenceType>8001</differenceType>
            </ignored>
            <ignored>
              <className>org/camunda/feel/syntaxtree/IntervalBoundary</className>
              <differenceType>8001</differenceType>
            </ignored>
            <ignored>
              <className>org/camunda/feel/syntaxtree/ClosedIntervalBoundary</className>
              <differenceType>8001</differenceType>
            </ignored>
            <ignored>
              <className>org/camunda/feel/syntaxtree/OpenIntervalBoundary</className>
              <differenceType>8001</differenceType>
            </ignored>
            <ignored>
              <className>org/camunda/feel/syntaxtree/Range</className>
              <differenceType>8001</differenceType>
            </ignored>
            <!-- ignore visibility change of internal fields -->
            <ignored>
              <className>org/camunda/feel/FeelEngine</className>
              <differenceType>7009</differenceType>
              <method>* interpreter()</method>
            </ignored>
            <ignored>
              <className>org/camunda/feel/FeelEngine</className>
              <differenceType>7009</differenceType>
              <method>* validator()</method>
            </ignored>
            <!-- ignore auto-generated Scala functions -->
            <ignored>
              <className>org/camunda/feel/syntaxtree/**</className>
              <differenceType>7002</differenceType>
              <method>scala.Function1 andThen(scala.Function1)</method>
            </ignored>
            <ignored>
              <className>org/camunda/feel/syntaxtree/**</className>
              <differenceType>7002</differenceType>
              <method>scala.Function1 compose(scala.Function1)</method>
            </ignored>
            <!-- ignore changes in FeelEngineBuilder -->
            <ignored>
              <className>org/camunda/feel/api/FeelEngineBuilder</className>
              <differenceType>7002</differenceType>
              <method>scala.Function1 curried()</method>
            </ignored>
            <ignored>
              <className>org/camunda/feel/api/FeelEngineBuilder</className>
              <differenceType>7002</differenceType>
              <method>scala.Function1 tupled()</method>
            </ignored>
          </ignored>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <version>${plugin.version.shade}</version>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
            <configuration>
              <shadedArtifactAttached>true</shadedArtifactAttached>
              <shadedClassifierName>scala-shaded</shadedClassifierName>
              <!-- avoid creating a reduced pom - see https://github.com/camunda/feel-scala/issues/450 -->
              <createDependencyReducedPom>false</createDependencyReducedPom>
              <promoteTransitiveDependencies>false</promoteTransitiveDependencies>
              <createSourcesJar>true</createSourcesJar>
              <keepDependenciesWithProvidedScope>true</keepDependenciesWithProvidedScope>

              <artifactSet>
                <excludes>
                  <exclude>org.slf4j:slf4j-api</exclude>
                </excludes>
              </artifactSet>

              <filters>
                <filter>
                  <artifact>*:*</artifact>
                  <excludes>
                    <exclude>META-INF/MANIFEST.MF</exclude>
                  </excludes>
                </filter>
              </filters>

              <relocations>
                <relocation>
                  <pattern>scala</pattern>
                  <shadedPattern>camundajar.impl.scala</shadedPattern>
                </relocation>

                <relocation>
                  <pattern>fastparse</pattern>
                  <shadedPattern>camundajar.impl.fastparse</shadedPattern>
                </relocation>
                <relocation>
                  <pattern>geny</pattern>
                  <shadedPattern>camundajar.impl.geny</shadedPattern>
                </relocation>
                <relocation>
                  <pattern>sourcecode</pattern>
                  <shadedPattern>camundajar.impl.sourcecode</shadedPattern>
                </relocation>

              </relocations>

            </configuration>
          </execution>
        </executions>
      </plugin>

      <!-- license plugin -->
      <plugin>
        <groupId>com.mycila</groupId>
        <artifactId>license-maven-plugin</artifactId>
        <configuration>
          <includes>
            <include>**/*.scala</include>
            <include>**/*.java</include>
          </includes>
          <mapping>
            <java>SLASHSTAR_STYLE</java>
            <scala>SLASHSTAR_STYLE</scala>
          </mapping>
        </configuration>
      </plugin>

    </plugins>

  </build>

  <profiles>
    <!-- profile to auto format -->
    <profile>
      <id>autoFormat</id>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.antipathy</groupId>
            <artifactId>mvn-scalafmt_2.13</artifactId>
            <executions>
              <execution>
                <id>scala-format</id>
                <phase>validate</phase>
                <goals>
                  <goal>format</goal>
                </goals>
              </execution>
            </executions>
          </plugin>

          <plugin>
            <groupId>com.mycila</groupId>
            <artifactId>license-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>add-license</id>
                <goals>
                  <goal>format</goal>
                </goals>
                <phase>process-sources</phase>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

    <!-- profile to perform strict validation checks -->
    <profile>
      <id>checkFormat</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.antipathy</groupId>
            <artifactId>mvn-scalafmt_2.13</artifactId>
            <executions>
              <execution>
                <id>scala-format</id>
                <phase>validate</phase>
                <goals>
                  <goal>format</goal>
                </goals>
              </execution>
            </executions>
          </plugin>

          <plugin>
            <groupId>com.mycila</groupId>
            <artifactId>license-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>check-license</id>
                <goals>
                  <goal>check</goal>
                </goals>
                <phase>validate</phase>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </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>

  <scm>
    <connection>scm:git:https://${env.GITHUB_TOKEN_USR}:${env.GITHUB_TOKEN_PSW}@github.com/camunda/feel-scala.git</connection>
    <developerConnection>scm:git:https://${env.GITHUB_TOKEN_USR}:${env.GITHUB_TOKEN_PSW}@github.com/camunda/feel-scala.git</developerConnection>
    <tag>1.18.0</tag>
    <url>https://github.com/camunda/feel-scala</url>
  </scm>

</project>
