<?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.lwjgl.osgi</groupId>
    <artifactId>org.lwjgl.parent</artifactId>
    <version>3.3.0</version>
  </parent>

  <packaging>bundle</packaging>
  <artifactId>org.lwjgl.opencl</artifactId>
  <name>org.lwjgl.opencl</name>
  <description>LWJGL OSGi bundle (OpenCL bindings)</description>
  <url>https://github.com/LWJGL/lwjgl3-osgi</url>

  <dependencies>
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>org.lwjgl.lwjgl</artifactId>
      <version>${project.version}</version>
    </dependency>

    <dependency>
      <groupId>org.lwjgl</groupId>
      <artifactId>lwjgl-opencl</artifactId>
      <scope>provided</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>

      <!-- Unpack LWJGL dependencies/sources/natives -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <id>unpack-sources</id>
            <phase>generate-resources</phase>
            <goals>
              <goal>unpack-dependencies</goal>
            </goals>
            <configuration>
              <overWriteReleases>true</overWriteReleases>
              <includeGroupIds>org.lwjgl</includeGroupIds>
              <includeArtifactIds>lwjgl-opencl</includeArtifactIds>
              <includeClassifiers>sources</includeClassifiers>
              <includeTypes>jar</includeTypes>
              <includes>**\/*</includes>
              <outputDirectory>${project.build.directory}/unpacked-sources</outputDirectory>
              <markersDirectory>${project.build.directory}/unpack-source-markers</markersDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <!-- Produce source jar -->
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>add-generated-sources</id>
            <phase>prepare-package</phase>
            <goals>
              <goal>add-source</goal>
            </goals>
            <configuration>
              <sources>${project.build.directory}/unpacked-sources</sources>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-source-plugin</artifactId>
        <executions>
          <execution>
            <id>sources-jar</id>
            <goals>
              <goal>jar-no-fork</goal>
            </goals>
            <phase>package</phase>
            <configuration>
              <attach>true</attach>
              <classifier>sources</classifier>
              <archive>
                <addMavenDescriptor>false</addMavenDescriptor>
              </archive>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <!-- Produce OSGi bundle -->
      <plugin>
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-bundle-plugin</artifactId>
        <extensions>true</extensions>
        <executions>
          <execution>
            <id>default-bundle</id>
            <configuration>
              <instructions>
                <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>

                <Require-Capability>
                  osgi.ee;filter:="(&amp;(osgi.ee=JavaSE)(version>=1.8))"
                </Require-Capability>

                <Import-Package>
                  <!-- Add explicit imports for LWJGL -->
                  org.lwjgl,
                  org.lwjgl.system,
                  org.lwjgl.system.*,
                  sun.misc,
                </Import-Package>

                <Embed-Dependency>
                  artifactId=lwjgl-opencl;classifier=!sources;inline=!*.jar
                </Embed-Dependency>

                <Export-Package>
                  org.lwjgl.opencl
                </Export-Package>

                <Specification-Title>Lightweight Java Game Library</Specification-Title>
                <Specification-Version>${project.version}</Specification-Version>
                <Specification-Vendor>lwjgl.org</Specification-Vendor>
                <Implementation-Title>lwjgl</Implementation-Title>
                <Implementation-Version>${project.version}</Implementation-Version>
                <Implementation-Vendor>lwjgl.org</Implementation-Vendor>
                <Implementation-Vendor-Id>${project.groupId}</Implementation-Vendor-Id>

                <Multi-Release>true</Multi-Release>
                <Sealed>true</Sealed>
              </instructions>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>io.github.zlika</groupId>
        <artifactId>reproducible-build-maven-plugin</artifactId>
      </plugin>
    </plugins>
  </build>

</project>
