<?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>io.roastedroot</groupId>
    <artifactId>quickjs4j-parent</artifactId>
    <version>0.1.1</version>
    <relativePath>../pom.xml</relativePath>
  </parent>

  <artifactId>quickjs4j</artifactId>
  <packaging>jar</packaging>
  <name>QuickJs4J</name>

  <dependencies>

    <!-- Jackson used for function arg/return ser/deser -->
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-databind</artifactId>
      <version>${jackson.version}</version>
    </dependency>
    <dependency>
      <groupId>run.endive</groupId>
      <artifactId>runtime</artifactId>
      <version>${endive.version}</version>
    </dependency>
    <dependency>
      <groupId>run.endive</groupId>
      <artifactId>wasi</artifactId>
      <version>${endive.version}</version>
    </dependency>

    <!-- ============= Testing ============= -->
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-api</artifactId>
      <version>${junit.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-engine</artifactId>
      <version>${junit.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-params</artifactId>
      <version>${junit.version}</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <!-- Fetches the Javy plugin wasm; skipped when the file already exists. -->
      <plugin>
        <groupId>io.roastedroot</groupId>
        <artifactId>inlay-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>fetch-javy-plugin</id>
            <goals>
              <goal>fetch</goal>
            </goals>
            <phase>initialize</phase>
            <configuration>
              <modules>
                <module>
                  <imageRef>ghcr.io/roastedroot/quickjs4j-javy-plugin:${javy-plugin.version}</imageRef>
                  <outputFile>${project.basedir}/../javy_quickjs4j_plugin.wasm</outputFile>
                </module>
              </modules>
              <lockFile>${project.basedir}/../wkg.lock</lockFile>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-checkstyle-plugin</artifactId>
        <executions>
          <execution>
            <id>checkstyle</id>
            <goals>
              <goal>check</goal>
            </goals>
            <phase>validate</phase>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>templating-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>filtering-java-templates</id>
            <goals>
              <goal>filter-sources</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>run.endive</groupId>
        <artifactId>endive-compiler-maven-plugin</artifactId>
        <version>${endive.version}</version>
        <executions>
          <execution>
            <id>javy-plugin</id>
            <goals>
              <goal>compile</goal>
            </goals>
            <configuration>
              <name>io.roastedroot.quickjs4j.core.JavyPluginModule</name>
              <wasmFile>../javy_quickjs4j_plugin.wasm</wasmFile>
              <moduleInterface>io.roastedroot.quickjs4j.core.Engine</moduleInterface>
            </configuration>
          </execution>
        </executions>
      </plugin>

    </plugins>
  </build>
</project>
