<?xml version="1.0" encoding="UTF-8"?>
<!--
 Copyright 2020 Goldman Sachs

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
-->

<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">
    <parent>
        <groupId>org.finos.legend.pure</groupId>
        <artifactId>legend-pure-core</artifactId>
        <version>5.28.0</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <name>Legend Pure - Base - M3 Core</name>
    <artifactId>legend-pure-m3-core</artifactId>
    <packaging>jar</packaging>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <executions>
                    <execution>
                        <id>compile</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>default-compile</id>
                        <phase>process-classes</phase>
                    </execution>
                </executions>
                <configuration>
                    <source>${maven.compiler.source}</source>
                    <target>${maven.compiler.target}</target>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>initialize</phase>
                        <configuration>
                            <target>
                                <copy todir="target/antlr">
                                    <fileset dir="src/main/antlr4/org/finos/legend/pure/m3/serialization/grammar/m3parser/antlr/core" />
                                </copy>
                                <copy todir="target/antlr">
                                    <fileset dir="../../legend-pure-core/legend-pure-m4/src/main/antlr4/org/finos/legend/pure/m4/serialization/grammar/core" />
                                </copy>
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.antlr</groupId>
                <artifactId>antlr4-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>antlr4</goal>
                        </goals>
                        <configuration>
                            <visitor>true</visitor>
                            <listener>true</listener>
                            <treatWarningsAsErrors>true</treatWarningsAsErrors> <!-- DO NOT CHANGE THIS -->
                            <excludes>
                                <exclude>**/org/finos/legend/pure/m3/serialization/grammar/m3parser/antlr/core/*</exclude>
                            </excludes>
                            <libDirectory>target/antlr</libDirectory>
                            <outputDirectory>${project.build.directory}/generated-sources</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-resources</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.outputDirectory}/antlr</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>
                                        src/main/antlr4/org/finos/legend/pure/m3/serialization/grammar/m3parser/antlr/core
                                    </directory>
                                    <filtering>true</filtering>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>Generate M3 Support Classes</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>java</goal>
                        </goals>
                        <configuration>
                            <mainClass>org.finos.legend.pure.m3.bootstrap.generator.CoreInstanceGenerator</mainClass>
                            <arguments>
                                <argument>${project.build.directory}/generated-sources/</argument>
                                <argument>${project.basedir}/src/main/resources</argument>
                                <argument>/platform/pure/grammar/m3.pure</argument>
                            </arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>Generate Other Support Classes</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>java</goal>
                        </goals>
                        <configuration>
                            <mainClass>org.finos.legend.pure.m3.generator.bootstrap.M3CoreInstanceGenerator</mainClass>
                            <additionalClasspathElements>
                                <additionalClasspathElement>${project.basedir}/src/main/resources
                                </additionalClasspathElement>
                            </additionalClasspathElements>
                            <arguments>
                                <argument>${project.build.directory}/generated-sources/</argument>
                                <argument>M3Platform</argument>
                                <argument>
                                    /platform/pure/grammar/milestoning.pure,
                                    /platform/pure/routing.pure,
                                    /platform/pure/anonymousCollections.pure,
                                    /platform/pure/relation.pure,
                                    /platform/pure/routing.pure
                                </argument>
                            </arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>Generate PAR</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>java</goal>
                        </goals>
                        <configuration>
                            <mainClass>org.finos.legend.pure.m3.generator.par.PureJarGenerator</mainClass>
                            <arguments>
                                <argument>${project.version}</argument>
                                <argument>platform</argument>
                                <argument>${project.build.outputDirectory}</argument>
                            </arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>Generate PCT Essential</id>
                        <phase>process-classes</phase>
                        <goals>
                            <goal>java</goal>
                        </goals>
                        <configuration>
                            <mainClass>org.finos.legend.pure.m3.pct.functions.generation.FunctionsGeneration</mainClass>
                            <arguments>
                                <argument>${project.build.directory}/classes/pct-reports/</argument>
                                <argument>org.finos.legend.pure.m3.PlatformCodeRepositoryProvider.essentialFunctions</argument>
                            </arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>Generate PCT Grammar</id>
                        <phase>process-classes</phase>
                        <goals>
                            <goal>java</goal>
                        </goals>
                        <configuration>
                            <mainClass>org.finos.legend.pure.m3.pct.functions.generation.FunctionsGeneration</mainClass>
                            <arguments>
                                <argument>${project.build.directory}/classes/pct-reports/</argument>
                                <argument>org.finos.legend.pure.m3.PlatformCodeRepositoryProvider.grammarFunctions</argument>
                            </arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>test-jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>

        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
                <includes>
                    <include>org/finos/legend/pure/platform.properties</include>
                </includes>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <excludes>
                    <exclude>org/finos/legend/pure/platform.properties</exclude>
                </excludes>
            </resource>
        </resources>
    </build>

    <dependencies>
        <dependency>
            <groupId>org.finos.legend.pure</groupId>
            <artifactId>legend-pure-m4</artifactId>
        </dependency>
        <dependency>
            <groupId>org.finos.legend.pure</groupId>
            <artifactId>legend-pure-m3-bootstrap-generator</artifactId>
        </dependency>

        <dependency>
            <groupId>org.eclipse.collections</groupId>
            <artifactId>eclipse-collections-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.eclipse.collections</groupId>
            <artifactId>eclipse-collections</artifactId>
        </dependency>

        <dependency>
            <groupId>org.antlr</groupId>
            <artifactId>antlr4-runtime</artifactId>
        </dependency>

        <dependency>
            <groupId>com.googlecode.json-simple</groupId>
            <artifactId>json-simple</artifactId>
        </dependency>

        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
        </dependency>

        <dependency>
            <groupId>io.prometheus</groupId>
            <artifactId>simpleclient</artifactId>
            <version>0.8.1</version>
        </dependency>

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

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
        </dependency>
        <dependency>
            <groupId>org.eclipse.collections</groupId>
            <artifactId>eclipse-collections-testutils</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.opentracing</groupId>
            <artifactId>opentracing-util</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.opentracing</groupId>
            <artifactId>opentracing-api</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>
</project>
