<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">
    <modelVersion>4.0.0</modelVersion>
    <groupId>chocopy</groupId>
    <artifactId>chocopy</artifactId>
    <packaging>jar</packaging>
    <version>2.2-SNAPSHOT</version>
    <name>chocopy</name>
    <url>http://maven.apache.org</url>

    <!-- Set this property to true on the command-line for very verbose output -->
    <properties>
        <chocopy.debug>false</chocopy.debug>
    </properties>

    <build>
        <!-- Specify JFlex and CUP plugins here; execute in profiles -->
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>de.jflex</groupId>
                    <artifactId>jflex-maven-plugin</artifactId>
                    <version>1.6.1</version>
                </plugin>
                <plugin>
                    <groupId>com.github.vbmacher</groupId>
                    <artifactId>cup-maven-plugin</artifactId>
                    <version>11b-20160615</version>
                </plugin>
                <plugin>
                    <artifactId>maven-assembly-plugin</artifactId>
                    <version>3.1.0</version>
                </plugin>
                <plugin>
                    <artifactId>maven-jar-plugin</artifactId>
                    <version>3.1.0</version>
                </plugin>
                <plugin>
                    <artifactId>maven-site-plugin</artifactId>
                    <version>3.7.1</version>
                </plugin>
            </plugins>
        </pluginManagement>

        <plugins>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                    <finalName>assignment</finalName>
                    <appendAssemblyId>false</appendAssemblyId>
                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id>
                        <phase>package</phase> <!-- bind to the packaging phase -->
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
                <configuration>
                    <encoding>UTF-8</encoding>
                    <source>1.8</source>
                    <target>1.8</target>
                    <parameters>true</parameters>
                    <debug>true</debug>
                </configuration>
            </plugin>
        </plugins>

        <resources>
          <resource>
            <directory>src/main/asm</directory>
            <includes>
              <include>**/*.s</include>
              <include>**/*.os</include>
            </includes>
            <excludes>
              <exclude>**/reference/*.s</exclude>
            </excludes>
          </resource>
        </resources>
    </build>

    <profiles>
        <profile>
            <id>reference</id>
            <activation>
                <!-- This profile is activated whenever we have the reference sources available -->
                <file>
                    <exists>src/main/java/chocopy/reference/</exists>
                </file>
            </activation>
            <build>
                <plugins>
                    <!-- Do not include student skeletons in the reference JAR -->
                    <plugin>
                        <artifactId>maven-jar-plugin</artifactId>
                        <configuration>
                            <excludes>
                                <exclude>**/pa1/*</exclude>
                                <exclude>**/pa2/*</exclude>
                                <exclude>**/pa3/*</exclude>
                            </excludes>
                        </configuration>
                    </plugin>
                    <!-- Name the generated JAR differently so that it is different from the student version -->
                    <plugin>
                        <artifactId>maven-assembly-plugin</artifactId>
                        <configuration>
                            <descriptorRefs>
                                <descriptorRef>jar-with-dependencies</descriptorRef>
                            </descriptorRefs>
                            <finalName>chocopy-ref</finalName>
                            <appendAssemblyId>false</appendAssemblyId>
                        </configuration>
                    </plugin>
                    <!-- Run JFlex to generate reference lexer -->
                    <plugin>
                        <groupId>de.jflex</groupId>
                        <artifactId>jflex-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>jflex-reference</id>
                                <goals>
                                    <goal>generate</goal>
                                </goals>
                                <configuration>
                                    <lexDefinitions>
                                        <lexDefinition>src/main/jflex/chocopy/reference/ChocoPy.jflex</lexDefinition>
                                    </lexDefinitions>
                                    <dump>${chocopy.debug}</dump>
                                    <verbose>true</verbose>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <!-- Run CUP to generate reference parser -->
                    <plugin>
                        <groupId>com.github.vbmacher</groupId>
                        <artifactId>cup-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>cup-reference</id>
                                <goals>
                                    <goal>generate</goal>
                                </goals>
                                <configuration>
                                    <cupDefinition>src/main/cup/chocopy/reference/ChocoPy.cup</cupDefinition>
                                    <packageName>chocopy.reference</packageName>
                                    <className>ChocoPyParser</className>
                                    <symbolsName>ChocoPyTokens</symbolsName>
                                    <dumpTables>${chocopy.debug}</dumpTables>
                                    <dumpStates>${chocopy.debug}</dumpStates>
                                    <dumpGrammar>${chocopy.debug}</dumpGrammar>
                                    <locations>true</locations>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <!-- No debug -->
                    <plugin>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <configuration>
                            <debug>true</debug>
                            <debuglevel>none</debuglevel>
                        </configuration>
                    </plugin>
                    <!-- Copy dependencies to target/ -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <version>3.1.1</version>
                        <executions>
                            <execution>
                                <id>copy-dependencies</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>copy-dependencies</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>pa1</id>
            <activation>
                <!-- This profile is activated whenever we are in a PA1 distribution -->
                <file>
                    <exists>src/main/java/chocopy/pa1</exists>
                </file>
            </activation>
            <build>
                <plugins>
                    <!-- Run JFlex on the student version -->
                    <plugin>
                        <groupId>de.jflex</groupId>
                        <artifactId>jflex-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>jflex-pa1</id>
                                <goals>
                                    <goal>generate</goal>
                                </goals>
                                <configuration>
                                    <lexDefinitions>
                                        <lexDefinition>src/main/jflex/chocopy/pa1/ChocoPy.jflex</lexDefinition>
                                    </lexDefinitions>
                                    <dump>${chocopy.debug}</dump>
                                    <verbose>true</verbose>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <!-- Run CUP on the student version -->
                    <plugin>
                        <groupId>com.github.vbmacher</groupId>
                        <artifactId>cup-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>cup-pa1</id>
                                <goals>
                                    <goal>generate</goal>
                                </goals>
                                <configuration>
                                    <cupDefinition>src/main/cup/chocopy/pa1/ChocoPy.cup</cupDefinition>
                                    <packageName>chocopy.pa1</packageName>
                                    <className>ChocoPyParser</className>
                                    <symbolsName>ChocoPyTokens</symbolsName>
                                    <dumpTables>${chocopy.debug}</dumpTables>
                                    <dumpStates>${chocopy.debug}</dumpStates>
                                    <dumpGrammar>${chocopy.debug}</dumpGrammar>
                                    <locations>true</locations>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>pa2</id>
            <activation>
                <!-- This profile is activated whenever we are in a PA2 distribution -->
                <file>
                    <exists>src/main/java/chocopy/pa2</exists>
                </file>
            </activation>
        </profile>
        <profile>
            <id>pa3</id>
            <activation>
                <!-- This profile is activated whenever we are in a PA3 distribution -->
                <file>
                    <exists>src/main/java/chocopy/pa3</exists>
                </file>
            </activation>
        </profile>
    </profiles>


    <repositories>
      <repository>
        <id>venus164-repo</id>
        <name>Repository for Venus164</name>
        <url>https://raw.githubusercontent.com/chocopy/venus/maven-repository/</url>
      </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>net.sourceforge.argparse4j</groupId>
            <artifactId>argparse4j</artifactId>
            <version>0.8.1</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.9.10</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.module</groupId>
            <artifactId>jackson-module-parameter-names</artifactId>
            <version>2.9.10</version>
        </dependency>
        <dependency>
            <groupId>com.github.vbmacher</groupId>
            <artifactId>java-cup-runtime</artifactId>
            <version>11b-20160615</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/de.jflex/jflex -->
        <dependency>
            <groupId>de.jflex</groupId>
            <artifactId>jflex</artifactId>
            <version>1.6.1</version>
        </dependency>
        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-stdlib</artifactId>
            <version>1.2.71</version>
        </dependency>
        <dependency>
            <groupId>edu.berkeley.eecs.venus164</groupId>
            <artifactId>venus164</artifactId>
            <version>0.2.4</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>net.sf.proguard</groupId>
            <artifactId>proguard-base</artifactId>
            <version>6.0.3</version>
        </dependency>
    </dependencies>
</project>
