<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Copyright 2023 The Netty Project
  ~
  ~ The Netty Project licenses this file to you under the Apache License,
  ~ version 2.0 (the "License"); you may not use this file except in compliance
  ~ with the License. You may obtain a copy of the License at:
  ~
  ~   https://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  ~ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  ~ License for the specific language governing permissions and limitations
  ~ under the License.
  -->
<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.netty.incubator</groupId>
    <artifactId>netty-incubator-codec-parent-quic</artifactId>
    <version>0.0.45.Final</version>
  </parent>

  <artifactId>netty-incubator-codec-quic-testsuite-native-image</artifactId>
  <packaging>${packaging.type}</packaging>
  <name>Netty/Testsuite/NativeImage</name>

  <!-- Profiles related to native-image -->
  <profiles>
    <profile>
      <id>native-image-quic-server</id>
      <dependencies>
        <dependency>
          <groupId>${project.groupId}</groupId>
          <artifactId>netty-incubator-codec-native-quic</artifactId>
          <version>${project.version}</version>
          <classifier>${os.detected.classifier}</classifier>
        </dependency>
        <dependency>
          <groupId>org.bouncycastle</groupId>
          <artifactId>bcpkix-jdk15on</artifactId>
          <scope>runtime</scope>
        </dependency>
      </dependencies>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
              <source>17</source>
              <target>17</target>
            </configuration>
          </plugin>
          <!-- Include examples from 'codec-native-quic' module as sources -->
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <executions>
              <execution>
                <phase>generate-sources</phase>
                <goals>
                  <goal>add-source</goal>
                </goals>
                <configuration>
                  <sources>
                    <source>${project.basedir}/../codec-native-quic/src/test/java/io/netty/incubator/codec/quic/example/</source>
                  </sources>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <!-- ./mvnw -Pnative-image-quic-server -pl testsuite-native-image package -->
          <plugin>
            <groupId>org.graalvm.buildtools</groupId>
            <artifactId>native-maven-plugin</artifactId>
            <version>${native.maven.plugin.version}</version>
            <extensions>true</extensions>
            <executions>
              <execution>
                <id>build-native</id>
                <goals>
                  <goal>compile-no-fork</goal>
                </goals>
                <phase>package</phase>
              </execution>
            </executions>
            <configuration>
              <mainClass>io.netty.incubator.codec.quic.example.QuicServerExample</mainClass>
              <imageName>native-image-quic-server</imageName>
              <metadataRepository>
                <enabled>true</enabled>
              </metadataRepository>
            </configuration>
          </plugin>
          <!-- ./mvnw -Pnative-image-quic-server -pl testsuite-native-image exec:exec -->
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>1.6.0</version>
            <executions>
              <execution>
                <id>verify-native-image</id>
                <phase>verify</phase>
                <goals>
                  <goal>exec</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <executable>${project.build.directory}/native-image-quic-server</executable>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>native-image-quic-client</id>
      <dependencies>
        <dependency>
          <groupId>${project.groupId}</groupId>
          <artifactId>netty-incubator-codec-native-quic</artifactId>
          <version>${project.version}</version>
          <classifier>${os.detected.classifier}</classifier>
        </dependency>
        <dependency>
          <groupId>org.bouncycastle</groupId>
          <artifactId>bcpkix-jdk15on</artifactId>
          <scope>runtime</scope>
        </dependency>
      </dependencies>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
              <source>17</source>
              <target>17</target>
            </configuration>
          </plugin>
          <!-- Include examples from 'codec-native-quic' module as sources -->
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <executions>
              <execution>
                <phase>generate-sources</phase>
                <goals>
                  <goal>add-source</goal>
                </goals>
                <configuration>
                  <sources>
                    <source>${project.basedir}/../codec-native-quic/src/test/java/io/netty/incubator/codec/quic/example/</source>
                  </sources>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <!-- ./mvnw -Pnative-image-quic-client -pl testsuite-native-image package -->
          <plugin>
            <groupId>org.graalvm.buildtools</groupId>
            <artifactId>native-maven-plugin</artifactId>
            <version>${native.maven.plugin.version}</version>
            <extensions>true</extensions>
            <executions>
              <execution>
                <id>build-native</id>
                <goals>
                  <goal>compile-no-fork</goal>
                </goals>
                <phase>package</phase>
              </execution>
            </executions>
            <configuration>
              <mainClass>io.netty.incubator.codec.quic.example.QuicClientExample</mainClass>
              <imageName>native-image-quic-client</imageName>
              <metadataRepository>
                <enabled>true</enabled>
              </metadataRepository>
            </configuration>
          </plugin>
          <!-- ./mvnw -Pnative-image-quic-client -pl testsuite-native-image exec:exec -->
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>1.6.0</version>
            <executions>
              <execution>
                <id>verify-native-image</id>
                <phase>verify</phase>
                <goals>
                  <goal>exec</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <executable>${project.build.directory}/native-image-quic-client</executable>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
