<?xml version="1.0"?>
<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.neo4j</groupId>
        <artifactId>cypher-v6-parser-parent</artifactId>
        <version>5.23.0</version>
        <relativePath>../pom.xml</relativePath>
    </parent>

    <modelVersion>4.0.0</modelVersion>
    <artifactId>cypher-v6-antlr-parser</artifactId>
    <packaging>jar</packaging>
    <name>Cypher 6 ANTLR based parser</name>

    <description>Cypher 6 ANTLR based parser</description>

    <properties>
        <moduleName>org.neo4j.cypher.internal.parser.antlr4</moduleName>
        <spotless.check.skip>true</spotless.check.skip>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.antlr</groupId>
            <artifactId>antlr4-runtime</artifactId>
        </dependency>
        <dependency>
            <groupId>org.neo4j</groupId>
            <artifactId>cypher-antlr-common</artifactId>
            <version>${project.version}</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <!-- disable scala-maven-plugin, because we have no scala -->
                <groupId>net.alchim31.maven</groupId>
                <artifactId>scala-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>scala-compile</id>
                        <phase>none</phase>
                    </execution>
                </executions>
                <configuration>
                    <skip>true</skip>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <executions>
                    <execution>
                        <id>default</id>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <!-- Antlr generates start imports so ignore it -->
                                <RestrictImports>
                                    <excludedSourceRoot>${basedir}/src/main/java/</excludedSourceRoot>
                                </RestrictImports>
                            </rules>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <!-- Profile to generate the lexer and parser, update license headers and format the code with spotless -->
        <profile>
            <id>generate-antlr</id>
            <activation>
                <property>
                    <name>generate.antlr</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.antlr</groupId>
                        <artifactId>antlr4-maven-plugin</artifactId>
                        <version>${antlr.version}</version>
                        <executions>
                            <execution>
                                <id>antlr</id>
                                <goals>
                                    <goal>antlr4</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <options><contextSuperClass>org.neo4j.cypher.internal.parser.AstRuleCtx</contextSuperClass></options>
                            <listener>false</listener> <!-- We have our own optimised listener -->
                            <visitor>false</visitor>
                            <outputDirectory>${basedir}/src/main/java/</outputDirectory>
                            <treatWarningsAsErrors>true</treatWarningsAsErrors>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>com.mycila</groupId>
                        <artifactId>license-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>check-licenses</id>
                                <goals>
                                    <goal>format</goal>
                                </goals>
                                <phase>process-sources</phase>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>com.diffplug.spotless</groupId>
                        <artifactId>spotless-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>format-code</id>
                                <goals>
                                    <goal>apply</goal>
                                </goals>
                                <phase>process-sources</phase>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
