<?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>
        <artifactId>modules-template</artifactId>
        <groupId>org.openprovenance.prov</groupId>
        <version>2.2.2</version>
    </parent>

    <artifactId>prov-template-library</artifactId>
    <version>2.2.2</version>

    <name> |---- PROV-TEMPLATE-LIBRARY</name>

    <dependencies>
        <dependency>
            <groupId>org.openprovenance.prov</groupId>
            <artifactId>prov-n</artifactId>
            <version>2.2.2</version>
        </dependency>
        <dependency>
            <groupId>org.openprovenance.prov</groupId>
            <artifactId>prov-model</artifactId>
            <version>2.2.2</version>
        </dependency>
        <dependency>
            <groupId>org.openprovenance.prov</groupId>
            <artifactId>prov-interop</artifactId>
            <version>2.2.2</version>
        </dependency>
        <dependency>
            <groupId>org.openprovenance.prov</groupId>
            <artifactId>prov-template-compiler</artifactId>
            <version>2.2.2</version>
        </dependency>
        <dependency>
            <groupId>org.openprovenance.prov</groupId>
            <artifactId>prov-template</artifactId>
            <version>2.2.2</version>
            <classifier>template-library</classifier>
            <type>zip</type>
        </dependency>
    </dependencies>

    <properties>
        <package.name>template_library</package.name>
        <package.name.cli>${package.name}_cli</package.name.cli>
        <package.name.l2p>${package.name}_l2p</package.name.l2p>
        <meta-inf-prefix>META-INF/resources/webjars</meta-inf-prefix>
        <meta-inf.webjars>${meta-inf-prefix}/${project.artifactId}/${project.version}</meta-inf.webjars>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>templating-maven-plugin</artifactId>
                <version>3.0.0</version>
                <executions>
                    <execution>
                        <id>preparing.jsweet.script</id>
                        <goals>
                            <goal>filter-sources</goal>
                        </goals>
                        <configuration>
                            <sourceDirectory>src/main/jsweet</sourceDirectory>
                            <outputDirectory>${project.build.directory}/jsweet</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>3.6.0</version>
                <executions>
                    <execution>
                        <id>unpack</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>org.openprovenance.prov</groupId>
                                    <artifactId>prov-template</artifactId>
                                    <classifier>template-library</classifier>
                                    <type>zip</type>
                                    <overWrite>false</overWrite>
                                    <outputDirectory>${project.build.directory}</outputDirectory>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>${exec.plugin.version}</version>
                <executions>
                    <execution>
                        <id>check-template-project-definitions</id>
                        <phase>generate-sources</phase>
                        <goals><goal>exec</goal></goals>
                        <configuration>
                            <executable>make</executable>
                            <arguments>
                                <argument>test.schema.projects</argument>
                            </arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>compile-template-plead</id>
                        <phase>generate-sources</phase>
                        <goals><goal>exec</goal></goals>
                        <configuration>
                            <executable>java</executable>
                            <arguments>
                                <argument>-classpath</argument>
                                <classpath />
                                <argument>org.openprovenance.prov.template.compiler.ConfigProcessor</argument>
                                <argument>src/main/resources/config/tp_plead.json</argument>
                                <argument>${project.basedir}</argument>
                                <argument>${project.basedir}/src/main/resources/cbindings</argument>
                                <argument>${project.basedir}</argument>
                                <argument>${project.build.directory}/${mini.template.library.folder}/templates</argument>
                            </arguments>
                        </configuration>
                    </execution>

                    <execution>
                        <id>compile-template-ptm</id>
                        <phase>generate-sources</phase>
                        <goals><goal>exec</goal></goals>
                        <configuration>
                            <executable>java</executable>
                            <arguments>
                                <argument>-classpath</argument>
                                <classpath />
                                <argument>org.openprovenance.prov.template.compiler.ConfigProcessor</argument>
                                <argument>src/main/resources/config/tp_ptm.json</argument>
                                <argument>${project.basedir}</argument>
                                <argument>${project.basedir}/src/main/resources/cbindings</argument>
                                <argument>${project.basedir}</argument>
                                <argument>${project.build.directory}/${mini.template.library.folder}/templates</argument>
                            </arguments>
                        </configuration>
                    </execution>

                    <execution>
                        <id>compile-template-pg</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>java</executable>
                            <arguments>
                                <argument>-classpath</argument>
                                <classpath />
                                <argument>org.openprovenance.prov.template.compiler.ConfigProcessor</argument>
                                <argument>src/main/resources/config/tp_pg.json</argument>
                                <argument>${project.basedir}</argument>
                                <argument>${project.basedir}/src/main/resources/cbindings</argument>
                                <argument>${project.basedir}</argument>
                                <argument>${project.build.directory}/${mini.template.library.folder}/templates</argument>
                            </arguments>
                        </configuration>
                    </execution>


                    <!--

                    <execution>
                        <id>python.test</id>
                        <phase>test</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>python3</executable>
                            <workingDirectory>${project.basedir}/src/test/python</workingDirectory>
                            <arguments>
                                <argument>test.py</argument>
                            </arguments>
                            <environmentVariables>
                                <PYTHONPATH>${project.build.directory}/generated-python:${project.basedir}/src/main/python:$PYTHONPATH</PYTHONPATH>
                            </environmentVariables>
                        </configuration>
                    </execution>

-->
                </executions>

            </plugin>



            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>${antrun.plugin.version}</version>
                <executions>
                    <execution>
                        <id>antrun-sources</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <target>
                                <move todir="${project.build.directory}/generated-sources/${package.name.cli}">
                                    <fileset dir="${project.build.directory}/${package.name}/${package.name.cli}/src/main/java">
                                        <include name="**/*" />
                                    </fileset>
                                </move>
                                <move todir="${project.build.directory}/generated-sources/${package.name.l2p}">
                                    <fileset dir="${project.build.directory}/${package.name}/${package.name.l2p}/src/main/java">
                                        <include name="**/*" />
                                    </fileset>
                                </move>
                                <copy todir="${project.build.directory}/cbindings">
                                    <fileset dir="src/main/resources/cbindings">
                                        <include name="**/*" />
                                    </fileset>
                                </copy>
                            </target>
                        </configuration>
                    </execution>
                    <execution>
                        <id>antrun-jsweet</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <target>
                                <echo message="Running JSweet by calling mvn with MAVEN_OPTS" />
                                <exec executable="mvn">
                                    <env key="MAVEN_OPTS" value="--add-opens jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-opens jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED  --add-opens jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED  --add-opens jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED --add-opens jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED --add-opens jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED  --add-opens jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED" />
                                    <arg value="-Dlibrary.source=${project.build.directory}/generated-sources/${package.name.cli}" />
                                    <arg value="-f" />
                                    <arg value="${project.build.directory}/jsweet/pom-jsweet.xml" />
                                    <arg value="jsweet:jsweet" />
                                </exec>
                            </target>
                        </configuration>
                    </execution>
                    <execution>
                        <id>antrun.run.test</id>
                        <phase>test</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <!--suppress UnresolvedMavenProperty -->
                            <target name="do.run.test">
                                <exec executable="npm" dir="${project.basedir}">
                                    <arg value="test" />
                                </exec>
                            </target>
                        </configuration>
                    </execution>

                </executions>
            </plugin>



            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <version>${build.helper.plugin.version}</version>
                <executions>
                    <execution>
                        <id>sources</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>add-source</goal>
                        </goals>
                        <configuration>
                            <sources>
                                <source>${project.build.directory}/generated-sources/${package.name.cli}</source>
                                <source>${project.build.directory}/generated-sources/${package.name.l2p}</source>
                            </sources>
                        </configuration>
                    </execution>

                    <execution>
                        <id>resources</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>add-resource</goal>
                        </goals>
                        <configuration>
                            <resources>
                                <resource>
                                    <directory>${project.build.directory}/resources</directory>
                                    <targetPath />
                                </resource>
                                <resource>
                                    <directory>${project.build.directory}/js</directory>
                                    <targetPath>${meta-inf.webjars}/js</targetPath>
                                </resource>
                                <resource>
                                    <directory>${project.build.directory}/${package.name}/${package.name.cli}/src/main/js</directory>
                                    <targetPath>${meta-inf.webjars}/js</targetPath>
                                </resource>
                                <resource>
                                    <directory>${project.build.directory}/ts</directory>
                                    <targetPath>${meta-inf.webjars}/ts</targetPath>
                                </resource>
                                <resource>
                                    <directory>${project.build.directory}/cbindings</directory>
                                    <targetPath>${meta-inf.webjars}/cbindings</targetPath>
                                </resource>
                                <resource>
                                    <directory>${project.build.directory}/${mini.template.library.folder}/templates</directory>
                                    <targetPath>${meta-inf.webjars}/templates</targetPath>
                                </resource>
                                <resource>
                                    <directory>${project.build.directory}/${mini.template.library.folder}/mbindings</directory>
                                    <targetPath>${meta-inf.webjars}/mbindings</targetPath>
                                </resource>

                                <resource>
                                    <directory>${project.build.directory}/${package.name}/${package.name.cli}/src/main/css</directory>
                                    <targetPath>${meta-inf.webjars}/css</targetPath>
                                    <includes>
                                        <include>*.css</include>
                                    </includes>
                                </resource>

                                <resource>
                                    <directory>${project.build.directory}/${package.name}/${package.name.cli}/src/main/resources</directory>
                                    <targetPath>${meta-inf.webjars}/schema</targetPath>
                                    <includes>
                                        <include>*.json</include>
                                    </includes>
                                </resource>

                                <resource>
                                    <directory>${project.build.directory}/${package.name}/${package.name.cli}/src/main/resources</directory>
                                    <targetPath>${meta-inf.webjars}/sql</targetPath>
                                    <includes>
                                        <include>*.sql</include>
                                    </includes>
                                </resource>


                                <resource>
                                    <directory>${project.build.directory}/${package.name}/${package.name.cli}/src/main/resources/${meta-inf-prefix}/${package.name.cli}/0.1.0/html</directory>
                                    <targetPath>${meta-inf.webjars}/html</targetPath>
                                    <includes>
                                        <include>*.html</include>
                                    </includes>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <descriptors>
                        <descriptor>target/classes/assembly/python-assembly.xml</descriptor>
                    </descriptors>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <id>make-assembly</id>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

        </plugins>
    </build>


</project>