<?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>
        <groupId>org.pragmatica-lite</groupId>
        <artifactId>peglib-parent</artifactId>
        <version>0.6.0</version>
        <relativePath>../pom.xml</relativePath>
    </parent>

    <artifactId>peglib</artifactId>
    <packaging>jar</packaging>

    <name>Peglib</name>
    <description>PEG parser library for Java with CST/AST support, inspired by cpp-peglib</description>
    <url>https://github.com/siy/java-peglib</url>

    <dependencies>
        <!-- Peglib Runtime — small set of types shared with generated parsers. -->
        <dependency>
            <groupId>org.pragmatica-lite</groupId>
            <artifactId>peglib-runtime</artifactId>
        </dependency>

        <!-- Pragmatica Lite Core -->
        <dependency>
            <groupId>org.pragmatica-lite</groupId>
            <artifactId>core</artifactId>
        </dependency>

        <!-- Testing -->
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <includes>
                        <include>**/*Test.java</include>
                        <include>**/*Example.java</include>
                    </includes>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.pragmatica-lite</groupId>
                <artifactId>jbct-maven-plugin</artifactId>
                <version>0.25.0</version>
                <configuration>
                    <!-- Scope JBCT linting to v6 paths only.
                         Legacy 0.5.x packages (parser, generator, analyzer, action, error,
                         grammar, tree, PegParser) are intentionally exempt during 0.6.0
                         redesign and are not refactored to JBCT rules.

                         JBCT-conformance refactor (May 2026): all 123 lint errors flagged by
                         0.25.0 strict mode have been fixed (drop defensive throws on internal
                         helpers, Option<T> for nullable returns, Result<Unit> for emit
                         visitors, @SuppressWarnings on JDK-API-mandated throws). Lint passes
                         with 0 errors, 288 warnings (style suggestions only).

                         5 files (TokenArray, DfaBuilder, ParserCompiler, LexerCompiler,
                         ParserGenerator) hit unstable cases in the 0.25.0 formatter where
                         repeated `jbct:format` passes don't converge to a self-consistent
                         layout. Skip remains true until either the formatter is fixed
                         upstream or those files are hand-formatted. The JBCT-rule refactor
                         itself is complete and the v6 codebase is now structurally compliant. -->
                    <sourceDirectory>${project.basedir}/src/main/java/org/pragmatica/peg/v6</sourceDirectory>
                    <skip>true</skip>
                </configuration>
                <executions>
                    <execution>
                        <id>check</id>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>bench</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>build-helper-maven-plugin</artifactId>
                        <version>3.6.0</version>
                        <executions>
                            <execution>
                                <id>add-jmh-sources</id>
                                <phase>generate-sources</phase>
                                <goals>
                                    <goal>add-source</goal>
                                </goals>
                                <configuration>
                                    <sources>
                                        <source>src/jmh/java</source>
                                    </sources>
                                </configuration>
                            </execution>
                            <execution>
                                <id>add-jmh-resources</id>
                                <phase>generate-resources</phase>
                                <goals>
                                    <goal>add-resource</goal>
                                </goals>
                                <configuration>
                                    <resources>
                                        <resource>
                                            <directory>src/test/resources</directory>
                                        </resource>
                                    </resources>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <configuration>
                            <annotationProcessorPaths>
                                <path>
                                    <groupId>org.openjdk.jmh</groupId>
                                    <artifactId>jmh-generator-annprocess</artifactId>
                                    <version>1.37</version>
                                </path>
                            </annotationProcessorPaths>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <version>3.5.0</version>
                        <configuration>
                            <mainClass>org.openjdk.jmh.Main</mainClass>
                            <classpathScope>compile</classpathScope>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-shade-plugin</artifactId>
                        <version>3.5.3</version>
                        <executions>
                            <execution>
                                <id>benchmarks-uberjar</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>shade</goal>
                                </goals>
                                <configuration>
                                    <finalName>benchmarks</finalName>
                                    <transformers>
                                        <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                            <mainClass>org.openjdk.jmh.Main</mainClass>
                                        </transformer>
                                        <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
                                    </transformers>
                                    <filters>
                                        <filter>
                                            <artifact>*:*</artifact>
                                            <excludes>
                                                <exclude>META-INF/*.SF</exclude>
                                                <exclude>META-INF/*.DSA</exclude>
                                                <exclude>META-INF/*.RSA</exclude>
                                            </excludes>
                                        </filter>
                                    </filters>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
            <dependencies>
                <dependency>
                    <groupId>org.openjdk.jmh</groupId>
                    <artifactId>jmh-core</artifactId>
                    <version>1.37</version>
                </dependency>
                <dependency>
                    <groupId>org.openjdk.jmh</groupId>
                    <artifactId>jmh-generator-annprocess</artifactId>
                    <version>1.37</version>
                    <scope>provided</scope>
                </dependency>
            </dependencies>
        </profile>
    </profiles>
</project>
