<?xml version="1.0" encoding="UTF-8"?>
<project>
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>org.kie.kogito</groupId>
    <artifactId>kogito-examples</artifactId>
    <version>0.3.0</version>
  </parent>
  <groupId>org.kie.kogito.examples</groupId>
  <artifactId>drools-polyglot-example</artifactId>

  <build>
    <plugins>
      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
      </plugin>
      <plugin>
        <!-- create the maven.compile.classpath property -->
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <phase>generate-sources</phase>
            <goals>
              <goal>build-classpath</goal>
            </goals>
            <configuration>
              <outputProperty>maven.compile.classpath</outputProperty>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <dependencies>
    <dependency>
      <groupId>org.kie.kogito</groupId>
      <artifactId>drools-core-static</artifactId>
    </dependency>
    <dependency>
      <groupId>org.kie.kogito</groupId>
      <artifactId>drools-canonical-model</artifactId>
    </dependency>
    <dependency>
      <groupId>org.kie.kogito</groupId>
      <artifactId>drools-model-compiler</artifactId>
      <exclusions>
        <exclusion>
          <groupId>org.kie.kogito</groupId>
          <artifactId>drools-core-dynamic</artifactId>
        </exclusion>
        <exclusion>
          <groupId>com.thoughtworks.xstream</groupId>
          <artifactId>xstream</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-nop</artifactId>
    </dependency>

  </dependencies>

  <profiles>
    <profile>
      <id>runjava</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <executions>
              <execution>
                <phase>package</phase>
                <goals>
                  <goal>java</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <mainClass>org.kie.kogito.examples.polyglot.Main</mainClass>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>runjs</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <executions>
              <execution>
                <phase>package</phase>
                <goals>
                  <goal>exec</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <executable>node</executable>
              <arguments>
                <argument>--vm.classpath</argument>
                <argument>${maven.compile.classpath}${path.separator}${project.build.directory}/${project.build.finalName}.jar</argument>
                <argument>--experimental-modules</argument>
                <argument>${project.basedir}/src/main/js/main.mjs</argument>
              </arguments>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

</project>
