<?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">
    <!--
    Artifacts:

    1. codenameone-windows-8.0-SNAPSHOT.jar
        The src directory compiled (the Win32 platform implementation). No native
        compilation happens here; the C in nativeSources is compiled by ParparVM's
        "windows" clean-target build (clang-cl) on Windows.
    2. codenameone-windows-8.0-SNAPSHOT-bundle.jar
        Zip with WindowsPort.jar and nativewindows.jar in the root, mirroring the
        iOS port bundle. Consumed by the build pipeline to supply the port classes
        and the native sources to the translator.
    -->
    <parent>
        <groupId>com.codenameone</groupId>
        <artifactId>codenameone</artifactId>
        <version>7.0.267</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.codenameone</groupId>
    <artifactId>codenameone-windows</artifactId>
    <version>7.0.267</version>
    <packaging>jar</packaging>

    <name>Codename One Windows Port</name>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>6</maven.compiler.source>
        <maven.compiler.target>6</maven.compiler.target>
        <src.dir>../../Ports/WindowsPort/src</src.dir>
        <codename1.nativewindows.dir>../../Ports/WindowsPort/nativeSources</codename1.nativewindows.dir>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.codenameone</groupId>
            <artifactId>codenameone-core</artifactId>
        </dependency>
    </dependencies>

    <build>
        <sourceDirectory>${src.dir}</sourceDirectory>
        <resources>
            <resource>
                <directory>${src.dir}</directory>
                <excludes><exclude>**/*.java</exclude></excludes>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>3.3.0</version>
                <executions>
                    <execution>
                        <id>make-assembly</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <configuration>
                            <!-- Built for the -bundle step below / local use, but deliberately NOT
                                 attached: nothing consumes the published
                                 jar-with-dependencies classifier (verified across this repo
                                 plus BuildDaemon, BuildCloud, BuildClient, OfflineBuilder and
                                 Deploy - the builders use the -bundle classifier). It was
                                 ~44MB of shaded third-party bytes per release across the five
                                 ports. -->
                            <attach>false</attach>
                            <descriptorRefs>
                                <descriptorRef>jar-with-dependencies</descriptorRef>
                            </descriptorRefs>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <!-- The port has no built-in native look, so its native theme is
                         the full material theme (the same one Android ships). Stage it
                         as a classpath resource (windowsNativeTheme.res) so the windows
                         translator target embeds it into the exe and the
                         getResourceAsStream call in installNativeTheme() serves it
                         straight from the executable. Mirrors how the iOS port carries
                         iOSModernTheme.res. Staged at prepare-package so it is in
                         target/classes before the jar is built (into WindowsPort.jar for
                         the build target) and visible to the screenshot harness, which
                         reads target/classes directly. -->
                    <execution>
                        <id>stage-native-theme</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <target>
                                <copy file="${project.basedir}/../../Themes/AndroidMaterialTheme.res"
                                      tofile="${project.build.outputDirectory}/windowsNativeTheme.res"
                                      overwrite="true" failonerror="true"/>
                            </target>
                        </configuration>
                    </execution>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <target>
                                <mkdir dir="${project.build.directory}/codenameone/windowsport-bundle"/>
                                <!-- Stage the prebuilt cn1ble.dll libraries
                                     (from cn1-binaries) into the native bundle
                                     under ble/{arch}/, so WindowsNativeBuilder
                                     can ship the arch-correct one next to a
                                     Bluetooth app's exe for the runtime
                                     LoadLibraryA in cn1_windows_ble.c. Tolerant
                                     of an absent ble/ dir. -->
                                <zip destfile="${project.build.directory}/codenameone/windowsport-bundle/nativewindows.jar">
                                    <fileset dir="${codename1.nativewindows.dir}"/>
                                    <zipfileset dir="${cn1.binaries}/ble/windows" prefix="ble" erroronmissingdir="false"/>
                                </zip>
                                <!--
                                  WindowsPort.jar inside the bundle is the
                                  fat jar: port classes plus every
                                  transitive dep including codenameone-core.
                                  The ParparVM translator scans this jar to
                                  find every class it needs to translate;
                                  without core inside, it cannot resolve
                                  symbols like
                                  com.codename1.ui.events.ActionListener
                                  referenced from an app lambda body and
                                  aborts mid-translation with empty output.
                                  Mirrors the iOSPort.jar layout, which has
                                  always shipped jar-with-dependencies.
                                -->
                                <copy file="${project.build.directory}/${project.build.finalName}-jar-with-dependencies.jar" tofile="${project.build.directory}/codenameone/windowsport-bundle/WindowsPort.jar" overwrite="true"/>
                                <zip destfile="${project.build.directory}/${project.build.finalName}-bundle.jar">
                                    <fileset dir="${project.build.directory}/codenameone/windowsport-bundle"/>
                                </zip>
                            </target>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <version>3.2.0</version>
                <executions>
                    <execution>
                        <id>attach-artifacts</id>
                        <phase>package</phase>
                        <goals>
                            <goal>attach-artifact</goal>
                        </goals>
                        <configuration>
                            <artifacts>
                                <artifact>
                                    <file>${project.build.directory}/${project.build.finalName}-bundle.jar</file>
                                    <type>jar</type>
                                    <classifier>bundle</classifier>
                                </artifact>
                            </artifacts>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
