<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>io.metersphere</groupId>
    <artifactId>metersphere-scriptengine</artifactId>
    <version>1.2.1</version>
  </parent>
  <groupId>io.metersphere</groupId>
  <artifactId>python-scriptengine</artifactId>
  <version>1.2.1</version>
  <dependencies>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-engine</artifactId>
      <version>5.9.2</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.graalvm.polyglot</groupId>
      <artifactId>polyglot</artifactId>
      <version>${graalvm.version}</version>
    </dependency>
    <dependency>
      <groupId>org.graalvm.polyglot</groupId>
      <artifactId>python-community</artifactId>
      <version>${graalvm.version}</version>
      <type>pom</type>
    </dependency>
    <dependency>
      <groupId>org.graalvm.polyglot</groupId>
      <artifactId>llvm-community</artifactId>
      <version>${graalvm.version}</version>
      <type>pom</type>
    </dependency>
  </dependencies>
  <build>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.11.0</version>
        <configuration>
          <source>${java.version}</source>
          <target>${java.version}</target>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>3.1.2</version>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>3.1.0</version>
        <executions>
          <execution>
            <goals>
              <goal>exec</goal>
            </goals>
          </execution>
          <execution>
            <id>no-runtime-compilation</id>
            <goals>
              <goal>exec</goal>
            </goals>
            <configuration>
              <executable>${java.home}/bin/java</executable>
              <arguments>
                <argument>--module-path</argument>
                <modulepath />
                <argument>-m</argument>
                <argument>embedding/io.metersphere.js.scriptengine.Main</argument>
              </arguments>
            </configuration>
          </execution>
        </executions>
        <configuration>
          <executable>${java.home}/bin/java</executable>
          <arguments>
            <argument>--module-path</argument>
            <modulepath />
            <argument>-m</argument>
            <argument>embedding/io.metersphere.js.scriptengine.Main</argument>
          </arguments>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-jlink-plugin</artifactId>
        <version>3.1.0</version>
        <extensions>true</extensions>
        <configuration>
          <ignoreSigningInformation>true</ignoreSigningInformation>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <profiles>
    <profile>
      <id>native</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.graalvm.buildtools</groupId>
            <artifactId>native-maven-plugin</artifactId>
            <version>0.9.25</version>
            <extensions>true</extensions>
            <executions>
              <execution>
                <id>build-native</id>
                <phase>package</phase>
                <goals>
                  <goal>compile-no-fork</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <imageName>${project.artifactId}</imageName>
              <mainClass>io.metersphere.js.scriptengine.Main</mainClass>
              <buildArgs>
                <buildArg>--no-fallback</buildArg>
                <buildArg>-J-Xmx20g</buildArg>
              </buildArgs>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>not-graalvm-jdk</id>
      <activation>
        <file>
          <missing>${java.home}/lib/graalvm</missing>
        </file>
      </activation>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>3.6.0</version>
            <executions>
              <execution>
                <id>copy-dependencies</id>
                <phase>process-resources</phase>
                <goals>
                  <goal>copy</goal>
                </goals>
                <configuration>
                  <outputDirectory>${project.build.directory}/compiler</outputDirectory>
                  <artifactItems>
                    <artifactItem>
                      <groupId>org.graalvm.sdk</groupId>
                      <artifactId>collections</artifactId>
                      <version>${graalvm.version}</version>
                      <type>jar</type>
                      <destFileName>collections.jar</destFileName>
                    </artifactItem>
                    <artifactItem>
                      <groupId>org.graalvm.sdk</groupId>
                      <artifactId>word</artifactId>
                      <version>${graalvm.version}</version>
                      <type>jar</type>
                      <destFileName>word.jar</destFileName>
                    </artifactItem>
                    <artifactItem>
                      <groupId>org.graalvm.truffle</groupId>
                      <artifactId>truffle-compiler</artifactId>
                      <version>${graalvm.version}</version>
                      <type>jar</type>
                      <destFileName>truffle-compiler.jar</destFileName>
                    </artifactItem>
                    <artifactItem>
                      <groupId>org.graalvm.compiler</groupId>
                      <artifactId>compiler</artifactId>
                      <version>${graalvm.version}</version>
                      <type>jar</type>
                      <destFileName>compiler.jar</destFileName>
                    </artifactItem>
                  </artifactItems>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>3.1.2</version>
            <configuration>
              <argLine>-XX:+UnlockExperimentalVMOptions
                                -XX:+EnableJVMCI
                                --upgrade-module-path=${project.build.directory}/compiler</argLine>
            </configuration>
          </plugin>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>1.6.0</version>
            <executions>
              <execution>
                <id>default-cli</id>
                <goals>
                  <goal>exec</goal>
                </goals>
                <configuration>
                  <executable>${java.home}/bin/java</executable>
                  <arguments>
                    <argument>--module-path</argument>
                    <modulepath />
                    <argument>-XX:+UnlockExperimentalVMOptions</argument>
                    <argument>-XX:+EnableJVMCI</argument>
                    <argument>--upgrade-module-path=${project.build.directory}/compiler/</argument>
                    <argument>-m</argument>
                    <argument>embedding/io.metersphere.js.scriptengine.Main</argument>
                  </arguments>
                </configuration>
              </execution>
              <execution>
                <id>no-runtime-compilation</id>
                <goals>
                  <goal>exec</goal>
                </goals>
                <configuration>
                  <executable>${java.home}/bin/java</executable>
                  <arguments>
                    <argument>--module-path</argument>
                    <modulepath />
                    <argument>-m</argument>
                    <argument>embedding/io.metersphere.js.scriptengine.Main</argument>
                  </arguments>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
              <execution>
                <id>copy-dependencies</id>
                <phase>package</phase>
                <goals>
                  <goal>copy-dependencies</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <outputDirectory>${project.build.directory}/lib</outputDirectory>
              <overWriteReleases>false</overWriteReleases>
              <overWriteSnapshots>false</overWriteSnapshots>
              <overWriteIfNewer>true</overWriteIfNewer>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
