<?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>

    <groupId>org.souther-lang</groupId>
    <artifactId>souther-parent</artifactId>
    <version>0.4.0</version>
    <packaging>pom</packaging>

    <name>Souther</name>
    <description>Souther: a JVM language that turns SMDD spec models into implementation models.</description>
    <url>https://github.com/souther-lang/souther</url>

    <licenses>
        <license>
            <name>Eclipse Public License - v 2.0</name>
            <url>https://www.eclipse.org/legal/epl-2.0/</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <developers>
        <developer>
            <id>kawasima</id>
            <name>kawasima</name>
            <url>https://github.com/kawasima</url>
        </developer>
    </developers>

    <modules>
        <module>souther-test-support</module>
        <module>souther-runtime</module>
        <module>souther-syntax</module>
        <module>souther-compiler</module>
        <module>souther-build-driver</module>
        <module>souther-fmt</module>
        <module>souther-lsp</module>
        <module>souther-cli</module>
        <module>souther-bench</module>
        <module>souther-program-api-test</module>
        <module>souther-architecture-test</module>
    </modules>

    <scm>
        <connection>scm:git:https://github.com/souther-lang/souther.git</connection>
        <developerConnection>scm:git:git@github.com:souther-lang/souther.git</developerConnection>
        <url>https://github.com/souther-lang/souther</url>
    </scm>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <!-- What a Java has to be, and what it has to be given, to run this compiler. Each is written
             here once: the classes are compiled for the one, the launchers and the tests hand the
             JVM the other, and `META-INF/souther/tooling.json` states both to whatever has to know
             before it starts a JVM. Where something cannot be filtered from here, a test holds it
             to what is written here. -->
        <souther.java.minimum>25</souther.java.minimum>
        <souther.jvm.stack>4m</souther.jvm.stack>
        <maven.compiler.release>${souther.java.minimum}</maven.compiler.release>
        <raoh.version>0.9.0</raoh.version>
        <!-- Raoh takes Jackson as provided, so the version on every classpath is this one. -->
        <jackson.version>3.2.3</jackson.version>
        <!-- The text rules the language shares with Raoh: case conversion, normalization, white
             space, the temporal grammar and the pattern language. Which strings these accept is a
             rule of the specification, so a version that changes an answer is a change to the
             language and is taken by hand, never by a dependency update. -->
        <notation199x.version>0.2.0</notation199x.version>
        <jspecify.version>1.0.1</jspecify.version>
        <!-- Where compiled classes go, named so the `m2e` profile below can send the editor's
             somewhere else. A build outside the editor uses the Maven defaults. -->
        <build.classes>${project.basedir}/target/classes</build.classes>
        <build.test.classes>${project.basedir}/target/test-classes</build.test.classes>
        <errorprone.version>2.50.0</errorprone.version>
        <checkstyle.plugin.version>3.6.0</checkstyle.plugin.version>
        <!-- What the pre-commit hook hands to Checkstyle: the directory it wrote the staged files
             into. A build that is not the hook leaves it at the root module's sources, which do
             not exist, so the goal has nothing to read. -->
        <checkstyle.staged.dir>${project.basedir}/src/main/java</checkstyle.staged.dir>
        <checkstyle.version>14.3.0</checkstyle.version>
        <nullaway.version>0.14.2</nullaway.version>
        <!-- What NullAway is asked for, written once. The gate below and the `lint` profile both
             ask, and a gate configured differently in each is a gate whose answer depends on which
             build asked. -->
        <nullaway.args>-Xep:NullAway:ERROR -XepOpt:NullAway:OnlyNullMarked=true -XepOpt:NullAway:JSpecifyMode=true</nullaway.args>
        <!-- The nullness gate an ordinary build runs, carried by the modules that declare
             `@NullMarked` — souther-runtime, today. Nothing else in Error Prone: this is the one
             rule those modules state about themselves, and the other five hundred checks are the
             `lint` profile's.

             It is a property because the profile empties it. javac takes one `-Xplugin:ErrorProne`
             per compilation and reports the second as a plugin it cannot find, so under `lint`,
             which puts the plugin on every module, a module carrying its own would be handing javac
             two. Emptying this leaves the profile's the only one, and NullAway is in both spellings,
             so the gate does not lift when the profile takes over. -->
        <errorprone.gate>-Xplugin:ErrorProne -XepDisableAllChecks ${nullaway.args}</errorprone.gate>
        <!-- Every warning javac gives is an error. It is a property because the `lint` profile
             empties it: under that profile Error Prone's findings arrive as javac warnings too, and
             there are 889 of them — a backlog of its own, which this is not the thing to turn into
             a build failure. What this holds is javac's own warnings. -->
        <javac.werror>-Werror</javac.werror>
        <!-- The build protocol souther-build-driver implements. Not this project's version and not
             tracked to it: it moves when the interface between a build plugin and a driver moves,
             which is why it is released from souther-lang/souther-build-api and named here like any
             other outside dependency. -->
        <souther.build.api.version>1.1.0</souther.build.api.version>
        <junit.version>6.1.3</junit.version>
        <!-- Named rather than written where it is used: `souther init` writes a project whose own
             tests are run by Surefire, and what it hands that project is this number. -->
        <surefire.version>3.6.0</surefire.version>
        <!-- The coverage agent a run under `-Pcoverage-by-class` carries. Named once because two
             places need the same number: the profile that starts the agent and the test-support
             module that compiles against its runtime. -->
        <jacoco.version>0.8.15</jacoco.version>
        <!-- How many JVMs the tests are spread over. Named here so -DforkCount=N reaches it: a
             literal in the plugin's configuration outranks the property surefire declares, so the
             override the comment below offers was not one, and a fork count could not be measured
             until it was.

             A ceiling, and not a share of the machine. A share takes the whole of whatever it is
             run on, and what it is run on is usually a machine somebody is also working on: a fork
             brings its own compiler and collector threads, so a share of the cores is all of them
             once those are counted. Held to a share the suite finishes sooner and nothing else on
             the machine gets done while it runs, which is a trade the person waiting was never
             asked about.

             `NC` cannot say this. It is a multiplier, so the figure that gives this ceiling on a
             large machine gives less than one core on a small one, and a run on two cores would
             come down to a single JVM. The ceiling is written as itself, and a machine with fewer
             cores than this is told the number it has — which is what CI is passed. -->
        <forkCount>4</forkCount>
        <!-- How a fork compiles and collects. Named for the same reason the fork count is: a literal
             in the plugin's configuration is not overridable, and what these are worth has to be
             measurable against the suite as it stands rather than the one they were chosen on.
             The stack is not among them — it is written beside this one where the argument is
             built, because it is what this compiler is supported on rather than a way of running
             the tests faster, and a run measuring a collector would otherwise drop it. -->
        <test.jvm.args>-XX:TieredStopAtLevel=1 -XX:+UseSerialGC</test.jvm.args>
        <!-- The tag a test carries when what it costs is worth more than asking it on every change.
             Left out of a plain run and asked for by emptying this. What such a test claims is
             written beside it as its own annotation and is nothing this decides. -->
        <test.excluded.groups>nightly</test.excluded.groups>
        <!-- What a row of an example is held to while the suite runs. The shipped default is a
             hundred million, which is what a model somebody wrote deserves; the models here write a
             literal or a small record, and dozens of them hold a helper that loops on purpose,
             because what they are about is a row that does not come back. A looping row is walked
             to the limit before anything is reported about it, so the limit is what those tests
             cost: the compiler's suite is 140s under the shipped default and 73s under this one.
             Twenty times what `DoesNotComeBack` allows a row it expects to finish, so a model doing
             real work has room, and reached in milliseconds by one that loops. Named here so
             -Dtest.example.step.limit=N reaches it. -->
        <test.example.step.limit>1000000</test.example.step.limit>
        <!-- Whether this module is left out of what is published to Central. A module that is not
             a Maven artifact anyone depends on sets it in its own pom, so it is left out of a
             release and of a snapshot alike. -->
        <souther.publish.skip>false</souther.publish.skip>
        <!-- The Enforcer the release and snapshot profiles check with. -->
        <enforcer.version>3.5.0</enforcer.version>
        <!-- What the build copies into an artifact from outside every module's own src, as paths
             from the root. A publication refuses an ignored file in any of them, as each module
             refuses one in its src (bin/require-clean-checkout.sh), because a copy would carry it
             into a jar though git never sees it. WhatACleanCheckoutAsksIsWhatTheBuildReadsTest holds
             this to what the poms copy from. -->
        <souther.build.reads>syntax specification.adoc</souther.build.reads>
    </properties>

    <!-- Where a dependency pinned at a snapshot version is resolved from: the Central Portal's
         snapshot repository, which is where the libraries this build takes publish theirs. Read
         for snapshots and for nothing else, so every release still comes from Central. -->
    <repositories>
        <repository>
            <id>central-portal-snapshots</id>
            <url>https://central.sonatype.com/repository/maven-snapshots/</url>
            <releases>
                <enabled>false</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>net.unit8.raoh</groupId>
                <artifactId>raoh</artifactId>
                <version>${raoh.version}</version>
            </dependency>
            <dependency>
                <groupId>net.unit8.raoh</groupId>
                <artifactId>raoh-json</artifactId>
                <version>${raoh.version}</version>
            </dependency>
            <dependency>
                <groupId>net.unit8.raoh</groupId>
                <artifactId>raoh-jooq</artifactId>
                <version>${raoh.version}</version>
            </dependency>
            <dependency>
                <groupId>tools.jackson.core</groupId>
                <artifactId>jackson-databind</artifactId>
                <version>${jackson.version}</version>
            </dependency>
            <!-- Without its JSpecify, which it declares at compile scope: souther-runtime keeps the
                 annotations off every downstream classpath (see its pom), and this is how they
                 would reach one. Declared here so that every module taking it takes it so. -->
            <dependency>
                <groupId>net.unit8.199x</groupId>
                <artifactId>notation-199x</artifactId>
                <version>${notation199x.version}</version>
                <exclusions>
                    <exclusion>
                        <groupId>org.jspecify</groupId>
                        <artifactId>jspecify</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>org.jspecify</groupId>
                <artifactId>jspecify</artifactId>
                <version>${jspecify.version}</version>
            </dependency>
            <dependency>
                <groupId>org.souther-lang</groupId>
                <artifactId>souther-build-api</artifactId>
                <version>${souther.build.api.version}</version>
            </dependency>
            <dependency>
                <groupId>org.souther-lang</groupId>
                <artifactId>souther-test-support</artifactId>
                <version>${project.version}</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.souther-lang</groupId>
                <artifactId>souther-runtime</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>org.souther-lang</groupId>
                <artifactId>souther-syntax</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>org.souther-lang</groupId>
                <artifactId>souther-compiler</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>org.souther-lang</groupId>
                <artifactId>souther-build-driver</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>org.souther-lang</groupId>
                <artifactId>souther-fmt</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>org.souther-lang</groupId>
                <artifactId>souther-lsp</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>org.souther-lang</groupId>
                <artifactId>souther-cli</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>org.junit</groupId>
                <artifactId>junit-bom</artifactId>
                <version>${junit.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <outputDirectory>${build.classes}</outputDirectory>
        <testOutputDirectory>${build.test.classes}</testOutputDirectory>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-resources-plugin</artifactId>
                    <version>3.5.0</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>${surefire.version}</version>
                    <configuration>
                        <!-- Whole test classes run to completion in a fork. Forks
                             rather than threads: four classes capture `System.out` to read what the
                             CLI printed, and a stream is one per JVM however many threads share it.
                             A fork also settles the rest of it — a class loaded per fork, a static
                             initialiser run per fork — so nothing here depends on what another test
                             did first. Override with -DforkCount=N; 1 is one JVM for everything. -->
                        <forkCount>${forkCount}</forkCount>
                        <reuseForks>true</reuseForks>
                        <!-- Left out of a plain run: a test tagged this way costs more than what
                             asking it on every change is worth, and compiling the corpora is most
                             of that. A run that means to ask them empties this —
                             `-Dtest.excluded.groups=` — which is what the nightly build does and
                             nothing a change waits on. -->
                        <excludedGroups>${test.excluded.groups}</excludedGroups>
                        <!-- Classes go to the forks by what they took last time, which is recorded
                             in a `.surefire-*` file beside the module. Handed out in file order
                             instead, one fork draws the longest class and a share of the rest, and
                             the build waits on that fork: the compiler's suite is 156s of tests
                             over sixteen forks, and it came to 28s rather than the 14s its longest
                             class alone would cost. A checkout with no record behaves as before. -->
                        <runOrder>balanced</runOrder>
                        <!-- C1 only, and a collector that runs no threads of its own. A test class
                             is a few seconds of work, over well before C2 has finished compiling
                             what it profiled, and with a JVM per core the compiler and collector
                             threads of every fork are competing for the cores the tests are on.
                             Measured on the compiler's suite, whole build, eight forks: 49s without
                             these, 27s with them. -->
                        <!-- The stack this compiler is supported on, and the tests are held to the
                             same one: a source at the structural bound needs about a megabyte, and
                             what is checked here has to be checked on the stack the bound was set
                             for. A test that wants a smaller one makes its own thread. -->
                        <argLine>${test.jvm.args} -Xss${souther.jvm.stack}</argLine>
                        <systemPropertyVariables>
                            <souther.example.step.limit>${test.example.step.limit}</souther.example.step.limit>
                        </systemPropertyVariables>
                    </configuration>
                </plugin>
                <!-- The pre-commit hook's checker, configured here and bound to no lifecycle phase.
                     A binding would put it in `mvn verify`, which is CI's build and already answers
                     the same question through Error Prone; this one is for the answer a commit can
                     wait for. The hook calls the goal by name, `checkstyle:check`, so no ordinary
                     build runs it.

                     The rule it reads is config/checkstyle.xml. What it reads it over is
                     `checkstyle.staged.dir`, which the hook sets to a directory holding what `git`
                     has staged — the content the commit will carry, and not what the working tree
                     happens to hold. `sourceDirectories` takes no command-line property of its own,
                     which is why the directory arrives through one declared here. Unset, it names
                     the root module's sources, and the root module has none. -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-checkstyle-plugin</artifactId>
                    <version>${checkstyle.plugin.version}</version>
                    <configuration>
                        <configLocation>${project.basedir}/config/checkstyle.xml</configLocation>
                        <sourceDirectories>
                            <sourceDirectory>${checkstyle.staged.dir}</sourceDirectory>
                        </sourceDirectories>
                        <includeTestSourceDirectory>false</includeTestSourceDirectory>
                        <inputEncoding>UTF-8</inputEncoding>
                        <consoleOutput>true</consoleOutput>
                        <logViolationsToConsole>true</logViolationsToConsole>
                        <!-- `failsOnError` is about Checkstyle failing, not about a file
                             violating a rule: on it, the goal stops at the first violation and
                             reports a count instead of naming the import. Off, it prints each
                             violation and `failOnViolation` ends the build afterwards. -->
                        <failsOnError>false</failsOnError>
                        <failOnViolation>true</failOnViolation>
                        <violationSeverity>error</violationSeverity>
                    </configuration>
                    <dependencies>
                        <dependency>
                            <groupId>com.puppycrawl.tools</groupId>
                            <artifactId>checkstyle</artifactId>
                            <version>${checkstyle.version}</version>
                        </dependency>
                    </dependencies>
                </plugin>
                <!-- What publishes to the Sonatype Central Portal, and only from the `release`
                     and `snapshot` profiles, each of which holds the tree to the source its
                     coordinate names before anything goes up. A plain `deploy` has nowhere to
                     go. A module that is not a Maven artifact sets `souther.publish.skip`. -->
                <plugin>
                    <groupId>org.sonatype.central</groupId>
                    <artifactId>central-publishing-maven-plugin</artifactId>
                    <version>0.11.0</version>
                    <configuration>
                        <publishingServerId>central</publishingServerId>
                        <autoPublish>true</autoPublish>
                        <skipPublishing>${souther.publish.skip}</skipPublishing>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <!-- Nothing but javac here. Error Prone and the nullness gate are in the `lint`
                 profile below, which CI runs. -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.16.0</version>
                <configuration>
                    <compilerArgs>
                        <!-- Every warning javac can give, and none of them is a thing to walk past.
                             A warning nobody has to act on is read by nobody, and 152 of them had
                             collected before anyone counted: 87 documentation comments attached to
                             nothing, 20 serializable classes with no serialized form written down,
                             13 calls to a deprecated method, 10 casts to what the value already
                             was. Each was a fact about the code that javac already knew and the
                             build was throwing away. -->
                        <arg>-Xlint:all</arg>
                        <arg>${javac.werror}</arg>
                        <!-- javac prints a hundred warnings per compilation and stops counting, and
                             a hundred errors likewise. A report that stops at a round number reads
                             as the whole of what was found — a change that breaks two hundred call
                             sites is read as breaking a hundred — so both limits are raised past
                             anything this build produces. -->
                        <arg>-Xmaxwarns</arg>
                        <arg>100000</arg>
                        <arg>-Xmaxerrs</arg>
                        <arg>100000</arg>
                    </compilerArgs>
                </configuration>
                <executions>
                    <!-- What ships keeps the lines a stack trace names and drops the names of local
                         variables, which only a debugger reads: the table of them is the largest
                         part of a class file that is not its code, and the CLI jar carries every
                         class this reactor compiles. The tests keep them, since a test is what
                         gets stepped through. -->
                    <execution>
                        <id>default-compile</id>
                        <configuration>
                            <debuglevel>lines,source</debuglevel>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <!-- The commit being built, read from git by the build rather than passed in. Only the
                 full id is taken: branch, user and time would differ between two builds of the
                 same commit. -->
            <plugin>
                <groupId>io.github.git-commit-id</groupId>
                <artifactId>git-commit-id-maven-plugin</artifactId>
                <version>9.0.1</version>
                <executions>
                    <execution>
                        <id>read-revision</id>
                        <phase>initialize</phase>
                        <goals>
                            <goal>revision</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <skipPoms>false</skipPoms>
                    <runOnlyOnce>true</runOnlyOnce>
                    <injectAllReactorProjects>true</injectAllReactorProjects>
                    <failOnNoGitDirectory>false</failOnNoGitDirectory>
                    <generateGitPropertiesFile>false</generateGitPropertiesFile>
                    <commitIdGenerationMode>full</commitIdGenerationMode>
                    <includeOnlyProperties>
                        <includeOnlyProperty>^git\.commit\.id\.full$</includeOnlyProperty>
                        <includeOnlyProperty>^git\.tags$</includeOnlyProperty>
                    </includeOnlyProperties>
                </configuration>
            </plugin>
            <!-- Implementation-Version and Implementation-Revision in every jar's manifest. A
                 compiled Souther module records the compiler that produced it, and the version
                 string comes from here: Maven fills it from the project version, so the root pom
                 stays the one place the version is written. The revision is the commit the jar was
                 built from, so a consumer that resolved the jar can place it against a commit
                 without going through a tag. -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.5.1</version>
                <configuration>
                    <archive>
                        <manifest>
                            <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                        </manifest>
                        <manifestEntries>
                            <Implementation-Revision>${git.commit.id.full}</Implementation-Revision>
                        </manifestEntries>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <!-- Error Prone, the JSpecify nullness gate included. On in CI, which sets `CI` in the
             environment, and available anywhere as `mvn -Plint clean verify`.

             Not in a development build. Measured on `clean test-compile`, whole reactor, one run
             each: 8.7s with none of this, 12.0s with NullAway alone, 38.0s with the default checks
             as well; and on the incremental build one edited source costs, 10.7s without it
             against 13.5s with. A finding therefore reaches CI without having been seen locally,
             and `mvn -Plint clean verify` is how to answer one. What it buys is the checks that
             are errors by default — the first run of it found a `String` handed to a
             `Map<NumericTerm, ...>`, which had left two tests asserting something about a domain
             they were never given.

             `clean` is not optional. The checks are javac's plugin, so a compilation Maven skips
             as up to date runs none of them and reports nothing.

             NullAway reads the JSpecify annotations souther-runtime carries, and `OnlyNullMarked`
             is what decides where it looks — the packages that declare `@NullMarked`, and no
             others. Adopting a package is one line in its `package-info.java`. Declaring the whole
             of souther-compiler annotated instead reports 1024 findings at once, which is a
             migration and not a check.

             `compilePolicy` and `should-stop` are Error Prone's arguments, not ours: its checks
             read the flow graph, and javac builds one per class only under that policy. The
             exports the plugin needs to reach javac's internals are in `.mvn/jvm.config`, because
             the compiler runs in the Maven JVM; without them the build stops at
             `IllegalAccessError` before any source is read.

             `combine.children` is what keeps the error and warning limits the build above sets:
             without it a profile's list of arguments replaces that list rather than adding to
             it, and a lint run would stop counting at a hundred.

             `-Werror` is not emptied here, so a finding of any check below that is not turned off
             stops the build. That is what makes the list below a ledger: a check is answered at
             every site, or it is off and says why. A finding that only printed is one nobody
             reads, which is how the backlog this closes was collected. -->
        <!-- Naming a test is asking for it to run, whatever it is about. Without this the tag below
             is applied on top of `-Dtest=`, and naming a tagged class runs nothing: with
             `-Dsurefire.failIfNoSpecifiedTests=false`, which is what iterating on one class is
             done with, that comes back as a green build over no tests at all. -->
        <profile>
            <id>a-named-test</id>
            <activation>
                <property>
                    <name>test</name>
                </property>
            </activation>
            <properties>
                <test.excluded.groups/>
            </properties>
        </profile>

        <!-- What each test class covered, one file per class under every module's
             `target/coverage-by-class/`. The agent records; `CoverageByClass` in test-support cuts
             the record at each class boundary; `bin/CoverageSubsumption.java` reads the files and
             names the classes whose every branch some other class also ran. Asked for as

                 mvn -o test -Pcoverage-by-class -Dtest.excluded.groups=

             — with the nightly classes included, because a class only the nightly duplicates is a
             fact the reader wants to see, and the reader marks those rather than this run leaving
             them out. Off by default: the agent slows every class, and a plain run has no reader
             for what it writes. -->
        <profile>
            <id>coverage-by-class</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.jacoco</groupId>
                        <artifactId>jacoco-maven-plugin</artifactId>
                        <version>${jacoco.version}</version>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>prepare-agent</goal>
                                </goals>
                                <configuration>
                                    <!-- The agent writes nothing of its own; the listener takes
                                         its data at each class boundary. -->
                                    <output>none</output>
                                    <includes>
                                        <include>souther.*</include>
                                    </includes>
                                    <propertyName>jacoco.agent.args</propertyName>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <!-- `@{}` rather than `${}`: the agent's arguments are set by a goal
                                 that runs after the model is read, and only a late reference sees
                                 them. -->
                            <argLine>${test.jvm.args} -Xss${souther.jvm.stack} @{jacoco.agent.args}</argLine>
                            <systemPropertyVariables>
                                <souther.test.coverage.dir>${project.build.directory}/coverage-by-class</souther.test.coverage.dir>
                            </systemPropertyVariables>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>lint</id>
            <activation>
                <property>
                    <name>env.CI</name>
                </property>
            </activation>
            <properties>
                <!-- The gate a module carries, emptied: this profile's plugin argument below is the
                     only one javac may be given. -->
                <errorprone.gate/>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <configuration>
                            <compilerArgs combine.children="append">
                                <arg>-XDcompilePolicy=simple</arg>
                                <arg>--should-stop=ifError=FLOW</arg>
                                <!-- UnicodeInCode is off for good. It reads a non-ASCII identifier
                                     as a thing that confuses a reader, and this compiler's tests
                                     call methods the language named in Japanese: the check would be
                                     asking the tests to stop covering what Souther supports. -->
                                <!-- RemoveUnusedImports ships as a suggestion, and a suggestion is
                                     a thing a build prints and nobody reads: 173 of them had
                                     collected across 114 files before anyone counted. An import
                                     that names what its file never uses tells a reader the file
                                     depends on something it does not, and the reader who most
                                     needs that to be true is the one deciding whether a package
                                     may be split or whether a boundary is being crossed. Raised
                                     to an error so that the next one stops the build it arrived
                                     in. The check reads documentation too, so an import only a
                                     {@link} mentions is not one of these. -->
                                <!-- Off, because what each reports this compiler writes on purpose
                                     and the check cannot be told so:
                                     ReferenceEquality — identity is the question a rewrite, an enum
                                     constant reached through its interface, a sentinel and an
                                     occurrence-keyed walk each ask;
                                     BadInstanceof — a call whose result is bound and null-checked
                                     in one condition, which inside an expression has no other
                                     spelling;
                                     StringSplitter — its remedy is Guava's `Splitter`, and what is
                                     left splits on a delimiter, where dropping what follows the
                                     last one is the reading wanted;
                                     UnnecessaryParentheses — what is left is `"$p" + (n++)`, where
                                     the parentheses are how the increment is seen;
                                     BooleanLiteral — what is left stands where an `Object` goes,
                                     and `false` there is not `Boolean.FALSE` but a value a ternary
                                     will promote to a number;
                                     IdentityHashMapUsage — a walk keys on the node it reached, and
                                     the remedy would put the concrete class through record
                                     components and signatures that say `Map`;
                                     ClassInitializationDeadlock — a sealed interface holding a
                                     constant of one of its own arms is how a nullary case is
                                     written here, and there are dozens;
                                     ArrayRecordComponent — none of these records is compared or
                                     keyed on, so what it warns of does not arise;
                                     ImmutableEnumChecker — every one of these fields is built with
                                     `List.of`, `Set.copyOf` or an unmodifiable wrapper, and saying
                                     so to the check means annotating the types, which would put
                                     Error Prone's annotations on the compile path;
                                     StringConcatToTextBlock — what is left is a source fixture, and
                                     a fixture is written to be read against the case it is for: one
                                     Java line carries several source lines where the case is about
                                     what the formatter does to them, and the leading spaces are the
                                     input. A text block re-lays both out;
                                     EffectivelyPrivate — every one of these is the canonical
                                     constructor of a record nested in a public sealed interface,
                                     where `public` is not a choice: a record's canonical
                                     constructor may not be less accessible than the record, and a
                                     record declared in an interface is public whatever is written;
                                     VoidUsed — the `Void` parameter belongs to `TreePathScanner`,
                                     and an override takes the parameters of what it overrides;
                                     NotJavadoc — what is left documents a member of an anonymous
                                     or local class, where javadoc publishes nothing and an editor
                                     shows the comment all the same;
                                     AvoidCommonTypeNames — `Number`, `Integer`, `Short`,
                                     `Readable` and `Record` are the language's own words here, and
                                     each is nested where what it is a case of says so;
                                     InlineFormatString — what is left is a named source fixture
                                     with a comment saying what case it is for, and inlining it
                                     puts twenty lines of Souther inside the call and takes the
                                     name and the comment away;
                                     RethrowReflectiveOperationExceptionAsLinkageError — what is
                                     left is a test harness loading what a compile emitted, where
                                     the failure is the test's and the message names the method it
                                     could not run; a `LinkageError` says a class would not link;
                                     JavaLocalTimeGetNano and JavaLocalDateTimeGetNano — every one
                                     asks whether there is a fraction of a second at all, which is
                                     the field on its own and nothing beside it. -->
                                <!-- Errors, because each is cheap to answer and silent to miss:
                                     ObjectToString, DuplicateBranches, UnusedVariable, UnusedMethod,
                                     SameNameButDifferent, MissingOverride, OperatorPrecedence and
                                     StringCaseLocaleUsage.
                                     The last is not style: a case fold with no locale is the
                                     platform's, and on a Turkish one `INFO` lowercases to `ınfo`,
                                     which a search misses and a snapshot writes down. The name
                                     check is not
                                     against writing one name for one distinction at two levels — it
                                     is against a use that does not say which of them it means. -->
                                <arg>-Xplugin:ErrorProne -Xep:UnicodeInCode:OFF -Xep:BadInstanceof:OFF -Xep:ReferenceEquality:OFF -Xep:StringSplitter:OFF -Xep:UnnecessaryParentheses:OFF -Xep:BooleanLiteral:OFF -Xep:IdentityHashMapUsage:OFF -Xep:ClassInitializationDeadlock:OFF -Xep:ArrayRecordComponent:OFF -Xep:ImmutableEnumChecker:OFF -Xep:StringConcatToTextBlock:OFF -Xep:EffectivelyPrivate:OFF -Xep:VoidUsed:OFF -Xep:NotJavadoc:OFF -Xep:AvoidCommonTypeNames:OFF -Xep:InlineFormatString:OFF -Xep:RethrowReflectiveOperationExceptionAsLinkageError:OFF -Xep:JavaLocalTimeGetNano:OFF -Xep:JavaLocalDateTimeGetNano:OFF -Xep:RemoveUnusedImports:ERROR -Xep:ObjectToString:ERROR -Xep:DuplicateBranches:ERROR -Xep:UnusedVariable:ERROR -Xep:UnusedMethod:ERROR -Xep:SameNameButDifferent:ERROR -Xep:MissingOverride:ERROR -Xep:OperatorPrecedence:ERROR -Xep:StringCaseLocaleUsage:ERROR ${nullaway.args}</arg>
                            </compilerArgs>
                            <annotationProcessorPaths>
                                <path>
                                    <groupId>com.google.errorprone</groupId>
                                    <artifactId>error_prone_core</artifactId>
                                    <version>${errorprone.version}</version>
                                </path>
                                <path>
                                    <groupId>com.uber.nullaway</groupId>
                                    <artifactId>nullaway</artifactId>
                                    <version>${nullaway.version}</version>
                                </path>
                            </annotationProcessorPaths>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <!-- An editor's Java support builds these modules through m2e, and m2e points an Eclipse
             project's output at whatever the pom names: ECJ then writes into target/classes, which
             is where maven-compiler-plugin reads staleness from. A class file newer than its source
             is indistinguishable from an up-to-date build, so javac is skipped and whatever ECJ
             left is what runs — including the classes it writes under proceedOnError, whose bodies
             throw `Unresolved compilation problem` at run time. Sending the editor's output
             somewhere else leaves target/classes with one writer.

             m2e sets the `m2e.version` property while it resolves a pom and a command-line build
             never does, so this profile is on in the editor and off everywhere else. The editor
             settings that would otherwise carry this are in `.vscode/`, which is not in the
             repository: a rule that has to hold for every checkout belongs here. -->
        <profile>
            <id>m2e</id>
            <activation>
                <property>
                    <name>m2e.version</name>
                </property>
            </activation>
            <properties>
                <build.classes>${project.basedir}/target/jdt-classes</build.classes>
                <build.test.classes>${project.basedir}/target/jdt-test-classes</build.test.classes>
            </properties>
        </profile>
        <!-- Activate for a Central release: `mvn -Prelease deploy`. Holds the build to what the
             tag for its version records and to dependencies that are releases, cleans every module
             before building it, attaches sources and javadoc, GPG-signs every artifact, and uploads
             them to the Central Portal as one deployment, which is published once the Portal has
             validated it (autoPublish). A snapshot is the `snapshot` profile's. Normal build/test
             is untouched. -->
        <profile>
            <id>release</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-enforcer-plugin</artifactId>
                        <version>${enforcer.version}</version>
                        <executions>
                            <execution>
                                <id>a-release-depends-on-releases</id>
                                <phase>initialize</phase>
                                <goals>
                                    <goal>enforce</goal>
                                </goals>
                                <configuration>
                                    <rules>
                                        <requireReleaseDeps>
                                            <message>A release is what its tag builds, and a snapshot dependency builds to whatever was published under it last.</message>
                                        </requireReleaseDeps>
                                    </rules>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <!-- A release is built from the commit tagged for its version and nothing else.
                         The revision written into the manifest names a commit, which describes the
                         jar only if nothing that commit does not record went into it. Asked of git
                         in the tree being built: the git-commit-id plugin's own `git.dirty` ignores
                         untracked files and, in a linked worktree, answers for the main checkout.
                         The tree as a whole, and what the build reads from outside every module's
                         src, are asked once; each module asks of its own src; and each module is
                         cleaned before it is built, so nothing an earlier build wrote is in it. -->
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <version>3.5.1</version>
                        <executions>
                            <execution>
                                <id>require-clean-checkout</id>
                                <phase>initialize</phase>
                                <inherited>false</inherited>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <configuration>
                                    <executable>${project.basedir}/bin/require-clean-checkout.sh</executable>
                                    <commandlineArgs>${souther.build.reads}</commandlineArgs>
                                </configuration>
                            </execution>
                            <execution>
                                <id>require-recorded-sources</id>
                                <phase>initialize</phase>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <configuration>
                                    <executable>${maven.multiModuleProjectDirectory}/bin/require-clean-checkout.sh</executable>
                                    <arguments>
                                        <argument>${project.basedir}/src</argument>
                                    </arguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-clean-plugin</artifactId>
                        <version>3.5.0</version>
                        <executions>
                            <execution>
                                <id>clean-before-building</id>
                                <phase>initialize</phase>
                                <goals>
                                    <goal>clean</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>io.github.git-commit-id</groupId>
                        <artifactId>git-commit-id-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>validate-release-source</id>
                                <phase>initialize</phase>
                                <goals>
                                    <goal>validateRevision</goal>
                                </goals>
                                <configuration>
                                    <validationProperties>
                                        <validationProperty>
                                            <name>revision is a commit</name>
                                            <value>${git.commit.id.full}</value>
                                            <shouldMatchTo>^[0-9a-f]{40}$</shouldMatchTo>
                                        </validationProperty>
                                        <validationProperty>
                                            <name>HEAD is tagged for this version</name>
                                            <value>${git.tags}</value>
                                            <shouldMatchTo>(^|,)v${project.version}(,|$)</shouldMatchTo>
                                        </validationProperty>
                                    </validationProperties>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                        <version>3.4.0</version>
                        <executions>
                            <execution>
                                <id>attach-sources</id>
                                <goals>
                                    <goal>jar-no-fork</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>3.12.0</version>
                        <configuration>
                            <doclint>none</doclint>
                            <failOnError>false</failOnError>
                            <quiet>true</quiet>
                        </configuration>
                        <executions>
                            <execution>
                                <id>attach-javadocs</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>3.2.8</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.sonatype.central</groupId>
                        <artifactId>central-publishing-maven-plugin</artifactId>
                        <extensions>true</extensions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <!-- Activate to publish develop's snapshot: `mvn -Psnapshot deploy`, run by hand from a
             checkout of develop, as a release is from its tag; CI publishes nothing. The snapshot
             repository keeps one coordinate per version and every publication overwrites it, so
             what the coordinate holds is whatever was published last; this profile is what makes
             that the tip of develop. It refuses a version that is not a snapshot, a change HEAD
             does not record, an ignored file where the build reads, and a HEAD that is not the
             commit develop points at on origin, and it cleans every module before building it. A
             snapshot may depend on snapshots: it is overwritten by the next publication anyway. Sources, javadoc and signatures are a
             release's and are not made. -->
        <profile>
            <id>snapshot</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-enforcer-plugin</artifactId>
                        <version>${enforcer.version}</version>
                        <executions>
                            <execution>
                                <id>a-snapshot-version-built-from-releases</id>
                                <phase>initialize</phase>
                                <goals>
                                    <goal>enforce</goal>
                                </goals>
                                <configuration>
                                    <rules>
                                        <requireSnapshotVersion>
                                            <message>The snapshot profile publishes develop's snapshot, and ${project.version} is not one. develop never carries a release version.</message>
                                        </requireSnapshotVersion>
                                    </rules>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <version>3.5.1</version>
                        <executions>
                            <execution>
                                <id>require-clean-checkout</id>
                                <phase>initialize</phase>
                                <inherited>false</inherited>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <configuration>
                                    <executable>${project.basedir}/bin/require-clean-checkout.sh</executable>
                                    <commandlineArgs>${souther.build.reads}</commandlineArgs>
                                </configuration>
                            </execution>
                            <execution>
                                <id>require-recorded-sources</id>
                                <phase>initialize</phase>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <configuration>
                                    <executable>${maven.multiModuleProjectDirectory}/bin/require-clean-checkout.sh</executable>
                                    <arguments>
                                        <argument>${project.basedir}/src</argument>
                                    </arguments>
                                </configuration>
                            </execution>
                            <execution>
                                <id>require-develop-tip</id>
                                <phase>initialize</phase>
                                <inherited>false</inherited>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <configuration>
                                    <executable>${project.basedir}/bin/require-develop-tip.sh</executable>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-clean-plugin</artifactId>
                        <version>3.5.0</version>
                        <executions>
                            <execution>
                                <id>clean-before-building</id>
                                <phase>initialize</phase>
                                <goals>
                                    <goal>clean</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.sonatype.central</groupId>
                        <artifactId>central-publishing-maven-plugin</artifactId>
                        <extensions>true</extensions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
