<?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.souther-lang</groupId>
        <artifactId>souther-parent</artifactId>
        <version>0.2.0</version>
    </parent>

    <artifactId>souther-compiler</artifactId>
    <name>Souther Compiler</name>

    <description>
        The Souther compiler: lexer, parser, type checker, and a ClassFile-API backend
        that emits JVM bytecode directly. No external dependencies beyond the JDK.
    </description>

    <dependencies>
        <!-- souther-syntax carries the lossless CST and the diagnostics (SourcePos, CompileException,
             Diagnostic) the whole pipeline is built on. -->
        <dependency>
            <groupId>org.souther-lang</groupId>
            <artifactId>souther-syntax</artifactId>
        </dependency>
        <!-- souther-fmt backs the `souther fmt` CLI subcommand (see Main). It is not part of the
             compile/typecheck/codegen pipeline, but the CLI dispatcher lives in this module, so the
             formatter is on the compile classpath. It only pulls in souther-syntax, already a dependency. -->
        <dependency>
            <groupId>org.souther-lang</groupId>
            <artifactId>souther-fmt</artifactId>
        </dependency>
        <!-- The formatter's own tests carry the corpus and the rewrites they sweep. A check that
             the canonical form means what the source meant needs the frontend, so it is written
             here and reads those fixtures from where the formatter keeps them. -->
        <dependency>
            <groupId>org.souther-lang</groupId>
            <artifactId>souther-fmt</artifactId>
            <version>${project.version}</version>
            <type>test-jar</type>
            <scope>test</scope>
        </dependency>
        <!-- souther-runtime is `provided`: the compiler loads a generated `$Ctfe.check` class to
             verify a constant newtype construction at compile time (CTFE, ADR-0032), and a
             lambda-bearing invariant's bytecode references the runtime `Fn`. It is not bundled;
             CTFE degrades gracefully to the run-time check if it is absent. Raoh stays test-only —
             CTFE runs the bare invariant, not the Raoh-returning decoder/__construct. -->
        <dependency>
            <groupId>org.souther-lang</groupId>
            <artifactId>souther-runtime</artifactId>
            <scope>provided</scope>
        </dependency>
        <!-- raoh core: the derived decoders/encoders `souther run` drives through (Runner), and the
             leaf codecs for primitive-typed inputs/outputs. -->
        <dependency>
            <groupId>net.unit8.raoh</groupId>
            <artifactId>raoh</artifactId>
        </dependency>
        <!-- raoh-json: the `souther run` input is JSON, so it decodes with the JSON source: the
             same decoders the boundary reads JSON with, where a temporal is a parsed string rather
             than a java.time value (issue #119). -->
        <dependency>
            <groupId>net.unit8.raoh</groupId>
            <artifactId>raoh-json</artifactId>
        </dependency>
        <dependency>
            <groupId>net.unit8.raoh</groupId>
            <artifactId>raoh-jooq</artifactId>
            <scope>test</scope>
        </dependency>
        <!-- Jackson 3: parses the `souther run` input JSON to plain objects and renders the encoded
             output back to JSON text (Runner); also exercises a generated jsonDecoder() in tests. -->
        <dependency>
            <groupId>tools.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>3.2.2</version>
        </dependency>
        <!-- jOOQ (provided by raoh-jooq) is needed at runtime to load/verify a generated
             recordDecoder()'s $DecRecord bytecode in tests. -->
        <dependency>
            <groupId>org.jooq</groupId>
            <artifactId>jooq</artifactId>
            <version>3.21.7</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.souther-lang</groupId>
            <artifactId>souther-test-support</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <!-- `souther doc` answers from the specification this compiler was built from, so the
                 repo-root specification.adoc rides inside the jar rather than being looked up on
                 the user's disk. -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <id>bundle-specification</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.outputDirectory}/META-INF/souther</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>${project.basedir}/..</directory>
                                    <includes>
                                        <include>specification.adoc</include>
                                    </includes>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
