<?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>io.github.captainssingapura-hue.homing.js</groupId>
        <artifactId>homing.js</artifactId>
        <version>0.4.0</version>
    </parent>

    <artifactId>homing-workspace-codecs</artifactId>
    <name>homing.js :: workspace-codecs</name>

    <description>
        Generated JS codecs for the workspace's typed records. Doctrine —
        "Generated and Hand-Written Live Apart": this module's
        src/main/resources is empty; all served JS is produced by
        WorkspaceCodecGen.main() into target/classes during the
        generate-resources phase via the Maven exec plugin.

        The manifest of records-to-be-codeced is declared in
        WorkspaceStateCodecsManifest as a typed List of
        ObjectDefinition&lt;?&gt; instances. The Java DomModule
        (WorkspaceStateCodecsModule) declares the matching Exportable._Class
        records so the framework's EsModuleWriter can wire imports across
        the JS module boundary.

        Cycle A — foundation slice. Manifest contains PaneId only; subsequent
        cycles expand to all 18 workspace records and add specialised
        codegens for sealed sums, enums, collections, Optionals, and Instant.
    </description>

    <properties>
        <maven.compiler.source>21</maven.compiler.source>
        <maven.compiler.target>21</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <!-- Path under target/classes where generated JS lands. Matches the
             classpath layout EsModuleWriter / ModuleNameResolver use to
             serve module bodies. -->
        <codecs.output.dir>${project.build.outputDirectory}/homing/js/hue/captains/singapura/js/homing/workspace/codecs</codecs.output.dir>
    </properties>

    <dependencies>
        <dependency>
            <groupId>io.github.captainssingapura-hue.homing.js</groupId>
            <artifactId>homing-core</artifactId>
            <version>${project.parent.version}</version>
        </dependency>
        <dependency>
            <groupId>io.github.captainssingapura-hue.homing.js</groupId>
            <artifactId>homing-codec</artifactId>
            <version>${project.parent.version}</version>
        </dependency>
        <dependency>
            <groupId>io.github.captainssingapura-hue.homing.js</groupId>
            <artifactId>homing-codec-ecma</artifactId>
            <version>${project.parent.version}</version>
        </dependency>
        <dependency>
            <groupId>io.github.captainssingapura-hue.homing.js</groupId>
            <artifactId>homing-workspace</artifactId>
            <version>${project.parent.version}</version>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <!-- Run WorkspaceCodecGen.main() during generate-resources so the
                 produced .js files are in target/classes by the time the jar
                 is packaged. The doctrine: generated code never lives in
                 src/main/resources; only in target/. -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>3.5.0</version>
                <executions>
                    <execution>
                        <id>generate-workspace-codecs</id>
                        <!-- process-classes runs immediately after compile.
                             The generator class itself must be compiled first
                             before we can invoke its main(), so generate-resources
                             (which runs BEFORE compile) wouldn't work. -->
                        <phase>process-classes</phase>
                        <goals><goal>java</goal></goals>
                        <configuration>
                            <mainClass>hue.captains.singapura.js.homing.workspace.codecs.WorkspaceCodecGen</mainClass>
                            <arguments>
                                <argument>${codecs.output.dir}</argument>
                            </arguments>
                            <!-- The generator must run in a classloader that already
                                 has homing-codec-ecma + homing-workspace on it. Maven
                                 exec uses the project's compile classpath by default,
                                 which is what we want — every dep above is reachable. -->
                            <classpathScope>compile</classpathScope>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>
