<?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>io.github.chains-project</groupId>
    <artifactId>collector-sahab-parent-pom</artifactId>
    <version>0.5.0</version>
  </parent>
  <artifactId>trace-collector</artifactId>
  <name>Trace Collector</name>
  <description>Trace collector agent for Collector Sahab</description>
  <url>https://github.com/ASSERT-KTH/collector-sahab/tree/main/trace-collector</url>

  <dependencies>
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-databind</artifactId>
    </dependency>

    <!-- Bytecode instrumentation -->
    <dependency>
      <groupId>net.bytebuddy</groupId>
      <artifactId>byte-buddy-dep</artifactId>
      <version>1.14.4</version>
    </dependency>
    <dependency>
      <groupId>org.ow2.asm</groupId>
      <artifactId>asm</artifactId>
      <version>9.5</version>
    </dependency>
    <dependency>
      <groupId>org.ow2.asm</groupId>
      <artifactId>asm-tree</artifactId>
      <version>9.5</version>
    </dependency>
    <dependency>
      <groupId>org.ow2.asm</groupId>
      <artifactId>asm-util</artifactId>
      <version>9.5</version>
    </dependency>

    <dependency>
      <groupId>io.github.chains-project</groupId>
      <artifactId>collector-sahab-commons</artifactId>
      <version>${project.parent.version}</version>
    </dependency>

    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.hamcrest</groupId>
      <artifactId>hamcrest</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.maven.shared</groupId>
      <artifactId>maven-invoker</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>com.diffplug.spotless</groupId>
        <artifactId>spotless-maven-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <version>3.4.1</version>
        <configuration>
          <createDependencyReducedPom>false</createDependencyReducedPom>
          <transformers>
            <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
              <manifestEntries>
                <Premain-Class>io.github.chains_project.collector.CollectorAgent</Premain-Class>
                <Can-Retransform-Classes>true</Can-Retransform-Classes>
                <Multi-Release>true</Multi-Release>
              </manifestEntries>
            </transformer>
          </transformers>
          <relocations>
            <relocation>
              <pattern>net.bytebuddy</pattern>
              <shadedPattern>rtf.net.bytebuddy</shadedPattern>
            </relocation>
            <relocation>
              <pattern>org.objectweb.asm</pattern>
              <shadedPattern>rtf.org.objectweb.asm</shadedPattern>
            </relocation>
            <relocation>
              <pattern>kotlin</pattern>
              <shadedPattern>rtf.kotlin</shadedPattern>
            </relocation>
          </relocations>
          <filters>
            <filter>
              <!--
                                Shading signed JARs will fail without this.
                                http://stackoverflow.com/questions/999489/invalid-signature-file-when-attempting-to-run-a-jar
                            -->
              <artifact>*:*</artifact>
              <excludes>
                <exclude>META-INF/*.SF</exclude>
                <exclude>META-INF/*.DSA</exclude>
                <exclude>META-INF/*.RSA</exclude>
              </excludes>
            </filter>
          </filters>
        </configuration>
        <executions>
          <execution>
            <id>shade</id>
            <goals>
              <goal>shade</goal>
            </goals>
            <phase>package</phase>
          </execution>
          <execution>
            <id>shade-for-test</id>
            <goals>
              <goal>shade</goal>
            </goals>
            <phase>package</phase>
            <configuration>
              <outputDirectory>${project.build.directory}/classes</outputDirectory>
              <finalName>${project.artifactId}</finalName>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>
