<?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.4.1</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>
        <!-- Compile scope, not `provided`: the compiler folds constant text and reads temporal
             literals by the rules the runtime holds (`Strings`, `TextAdmission`, `Temporals`), so it
             needs this present to run at all, not only for CTFE's generated `$Ctfe.check` class and
             the `Fn` a lambda-bearing invariant's bytecode references. 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>
        </dependency>
        <!-- The text rules themselves: the pattern reader and the machines the compiler's own
             analysis of patterns is built on, normalization, and the temporal grammar. -->
        <dependency>
            <groupId>net.unit8.199x</groupId>
            <artifactId>notation-199x</artifactId>
        </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>
        </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.9</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>
            <!-- What the library's written operations state is proved against their bodies once,
                 here, with the classes and the library this build ships, and what each proof came
                 to rides inside the jar. A compilation reads it rather than proving them again at
                 every start (LibraryProofsAsBuilt). -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>3.6.4</version>
                <executions>
                    <execution>
                        <id>prove-the-library</id>
                        <phase>process-classes</phase>
                        <goals>
                            <goal>java</goal>
                        </goals>
                        <configuration>
                            <mainClass>souther.compiler.check.LibraryProofsAsBuilt</mainClass>
                            <arguments>
                                <argument>${project.build.outputDirectory}/souther/compiler/check/library-proofs.txt</argument>
                            </arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
