<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <name>Narcissus</name>
    <groupId>io.github.toolfactory</groupId>
    <artifactId>narcissus</artifactId>
    <version>1.0.11</version>

    <description>Reflection API for circumventing Java security, visibility, and encapsulation mechanisms</description>

    <url>https://github.com/toolfactory/narcissus</url>

    <properties>
        <maven.compiler.encoding>UTF-8</maven.compiler.encoding>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.build.locales>en_US</project.build.locales>
        <link.opt.1 />
        <link.opt.2 />

        <assertj-core.version>3.27.2</assertj-core.version>
        <junit.version>5.13.3</junit.version>

        <!-- Default architecture type (will be overridden by profiles) --> 
        <arch.type>x64</arch.type>

        <linkerFinalName>libnarcissus-${os.type}-${arch.type}</linkerFinalName>

        <maven-antrun-plugin.version>3.1.0</maven-antrun-plugin.version>
        <maven-compiler-plugin.version>3.14.0</maven-compiler-plugin.version>
        <maven-gpg-plugin.version>3.2.8</maven-gpg-plugin.version>
        <maven-jar-plugin.version>3.4.2</maven-jar-plugin.version>
        <!-- maven-javadoc-plugin v3.1+ has a bug which prevents it from working with multi-release
        jars: -->
        <!-- https://issues.apache.org/jira/projects/MJAVADOC/issues/MJAVADOC-673 -->
        <maven-javadoc-plugin.version>3.0.1</maven-javadoc-plugin.version>
        <maven-jxr-plugin.version>2.5</maven-jxr-plugin.version>
        <maven-source-plugin.version>3.3.1</maven-source-plugin.version>
        <maven-scm-provider-gitexe.version>2.1.0</maven-scm-provider-gitexe.version>
        <maven-surefire-plugin.version>3.5.3</maven-surefire-plugin.version>
        <native-maven-plugin.version>1.0-M1</native-maven-plugin.version>

        <project_jdk_version>7</project_jdk_version>
    </properties>

    <licenses>
        <license>
            <name>MIT License</name>
            <url>https://github.com/toolfactory/narcissus/blob/master/LICENSE</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <organization>
        <name>ToolFactory</name>
        <url>https://github.com/toolfactory</url>
    </organization>

    <developers>
        <developer>
            <name>Luke Hutchison</name>
            <email>tool.factory.heads@gmail.com</email>
            <organization>ToolFactory</organization>
            <organizationUrl>https://github.com/toolfactory</organizationUrl>
            <roles>
                <role>Administrator</role>
                <role>Developer</role>
            </roles>
        </developer>
        <developer>
            <name>Roberto Gentili</name>
            <id>roberto.gentili</id>
            <email>tool.factory.heads@gmail.com</email>
            <organization>ToolFactory</organization>
            <organizationUrl>https://github.com/toolfactory</organizationUrl>
            <roles>
                <role>Administrator</role>
                <role>Developer</role>
            </roles>
        </developer>
    </developers>

    <issueManagement>
        <system>github.com</system>
        <url>https://github.com/toolfactory/narcissus/issues</url>
    </issueManagement>

    <scm>
        <connection>scm:git:https://toolfactory@github.com/toolfactory/narcissus.git</connection>
        <developerConnection>scm:git:https://toolfactory@github.com/toolfactory/narcissus.git</developerConnection>
        <url>https://toolfactory.github.io/narcissus</url>
        <tag>narcissus-1.0.11</tag> 
    </scm>

    <packaging>jar</packaging>

    <dependencies>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <version>${assertj-core.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <profiles>
        <profile>
            <id>mac</id>
            <activation>
                <os>
                    <family>mac</family>
                </os>
            </activation>
            <properties>
                <os.type>macos</os.type>
                <os.dir>darwin</os.dir>
                <lib.extn>dylib</lib.extn>
            </properties>
        </profile>
        <profile>
            <id>mac-arm</id>
            <activation>
                <os>
                    <family>mac</family>
                    <arch>aarch64</arch>
                </os>
            </activation>
            <properties>
                <arch.type>arm64</arch.type>
            </properties>
        </profile>
        <profile>
            <id>linux-arm</id>
            <activation>
                <os>
                    <family>unix</family>
                    <name>Linux</name>
                    <arch>aarch64</arch>
                </os>
            </activation>
            <properties>
                <arch.type>arm64</arch.type>
            </properties>
        </profile>
        <profile>
            <id>windows-arm</id>
            <activation>
                <os>
                    <family>Windows</family>
                    <arch>aarch64</arch>
                </os>
            </activation>
            <properties>
                <arch.type>arm64</arch.type>
            </properties>
        </profile>
        <profile>
            <id>arch-x86</id>
            <activation>
                <property>
                    <name>sun.arch.data.model</name>
                    <value>32</value>
                </property>
            </activation>
            <properties>
                <arch.type>x86</arch.type>
            </properties>
        </profile>
        <profile>
            <id>unix</id>
            <activation>
                <os>
                    <family>unix</family>
                    <name>Linux</name>
                </os>
            </activation>
            <properties>
                <os.type>linux</os.type>
                <os.dir>linux</os.dir>
                <lib.extn>so</lib.extn>
            </properties>
        </profile>
        <profile>
            <id>windows</id>
            <activation>
                <os>
                    <family>Windows</family>
                </os>
            </activation>
            <properties>
                <os.type>win</os.type>
                <os.dir>win32</os.dir>
                <lib.extn>dll</lib.extn>
                <link.opt.1>-Wl,--kill-at</link.opt.1>
            </properties>
        </profile>
        <profile>
            <id>windows-x86</id>
            <activation>
                <os>
                    <family>Windows</family>
                </os>
                <property>
                    <name>sun.arch.data.model</name>
                    <value>32</value>
                </property>
            </activation>
            <properties>
                <link.opt.2>-static</link.opt.2>
            </properties>
        </profile>
        <profile>
            <!-- Disable native-maven-plugin when releasing -->
            <!-- See: https://stackoverflow.com/a/39558669/3950982 -->
            <id>release</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>native-maven-plugin</artifactId>
                        <version>${native-maven-plugin.version}</version>
                        <executions>
                            <execution>
                                <id>compile-native-lib</id>
                                <phase>none</phase>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>massive-test</id>
            <activation>
                <property>
                    <name>massive_test_mode</name>
                    <value>enabled</value>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>native-maven-plugin</artifactId>
                        <version>${native-maven-plugin.version}</version>
                        <executions>
                            <execution>
                                <id>compile-native-lib</id>
                                <phase>none</phase>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <!-- GPG Signature on release -->
        <profile>
            <id>release-sign-artifacts</id>
            <activation>
                <property>
                    <name>performRelease</name>
                    <value>true</value>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>${maven-gpg-plugin.version}</version>
                        <executions>
                            <execution>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                                <configuration>
                                    <excludes>
                                        <exclude>**/*.zip</exclude>
                                    </excludes>
                                    <gpgArguments>
                                        <arg>--pinentry-mode</arg>
                                        <arg>loopback</arg>
                                    </gpgArguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <id>generate-sources</id>
                        <phase>generate-sources</phase>
                        <configuration>
                            <target>
                                <!-- The lib/ dir holds the native library, and is checked back into
                                GitHub -->
                                <mkdir dir="lib" />
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>copy-lib-dir</id>
                        <phase>prepare-package</phase>
                        <configuration>
                            <target>
                                <!-- Copy lib/ dir to build directory so that lib/* is added to jar -->
                                <copy todir="${project.build.directory}/classes/lib">
                                    <fileset dir="lib" />
                                </copy>
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                    <execution>
                        <!-- Put module-info.class in META-INF/versions/9 to maximize backwards
                        compatibility. -->
                        <id>add-module-info-to-jar</id>
                        <phase>package</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <target>
                                <jar update="true" destfile="${project.build.directory}/${project.build.finalName}.jar">
                                    <zipfileset prefix="META-INF/versions/9" dir="${project.basedir}/src/module-info/io.github.toolfactory.narcissus" includes="module-info.class" />
                                </jar>
                            </target>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>native-maven-plugin</artifactId>
                <version>${native-maven-plugin.version}</version>
                <extensions>true</extensions>
                <configuration>
                    <compilerProvider>generic</compilerProvider>
                    <compilerExecutable>gcc</compilerExecutable>
                    <linkerExecutable>gcc</linkerExecutable>
                    <sources>
                        <source>
                            <directory>src/main/c</directory>
                            <fileNames>
                                <fileName>narcissus.c</fileName>
                            </fileNames>
                        </source>
                    </sources>
                    <compilerStartOptions>
                        <compilerStartOption>-I ${JAVA_HOME}/include/</compilerStartOption>
                        <compilerStartOption>-I ${JAVA_HOME}/include/${os.dir}/</compilerStartOption>
                    </compilerStartOptions>
                    <compilerEndOptions>
                        <compilerEndOption>-Wall</compilerEndOption>
                        <compilerEndOption>-fPIC</compilerEndOption>
                        <compilerEndOption>-std=c99</compilerEndOption>
                        <compilerEndOption>-m${sun.arch.data.model}</compilerEndOption>
                    </compilerEndOptions>
                    <linkerStartOptions>
                        <linkerStartOption>-I ${JAVA_HOME}/include/</linkerStartOption>
                        <linkerStartOption>-I ${JAVA_HOME}/include/${os.dir}/</linkerStartOption>
                        <linkerStartOption>-I ${JAVA_HOME}/lib/</linkerStartOption>
                    </linkerStartOptions>
                    <linkerEndOptions>
                        <linkerEndOption>-fPIC</linkerEndOption>
                        <linkerEndOption>-shared</linkerEndOption>
                        <compilerEndOption>-m${sun.arch.data.model}</compilerEndOption>
                        <linkerEndOption>${link.opt.1}</linkerEndOption>
                        <linkerEndOption>${link.opt.2}</linkerEndOption>
                    </linkerEndOptions>
                    <linkerOutputDirectory>${project.basedir}/lib</linkerOutputDirectory>
                    <linkerFinalName>${linkerFinalName}</linkerFinalName>
                    <linkerFinalNameExt>${lib.extn}</linkerFinalNameExt>
                </configuration>
                <executions>
                    <execution>
                        <id>compile-native-lib</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>compile</goal>
                            <goal>link</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven-compiler-plugin.version}</version>
                <configuration>
                    <encoding>UTF-8</encoding>
                    <source>${project_jdk_version}</source>
                    <target>${project_jdk_version}</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${maven-surefire-plugin.version}</version>
                <configuration>
                    <additionalClasspathElements>
                        <!-- Allow test classes to find the native library in
                        ${project.basedir}/lib/ -->
                        <additionalClasspathElement>${project.basedir}</additionalClasspathElement>
                    </additionalClasspathElements>
                    <!-- Show stack traces for test failures -->
                    <trimStackTrace>false</trimStackTrace>
                    <!-- Print summary of test results -->
                    <printSummary>true</printSummary>
                    <redirectTestOutputToFile>false</redirectTestOutputToFile>
                    <useFile>false</useFile>
                    <parallel>none</parallel>
                    <threadCount>1</threadCount>
                    <argLine>-Dsurefire.printTestMethodDetail=true</argLine>
                    <systemPropertyVariables>
                        <junit.jupiter.execution.parallel.enabled>false</junit.jupiter.execution.parallel.enabled>
                        <junit.platform.output.capture.stdout>true</junit.platform.output.capture.stdout>
                        <junit.platform.output.capture.stderr>true</junit.platform.output.capture.stderr>
                    </systemPropertyVariables>
                    <properties>
                        <configurationParameters>
                            junit.jupiter.testinstance.lifecycle.default=per_method
                            junit.platform.reporting.open.xml.enabled=true
                            junit.platform.reporting.output.dir=target/surefire-reports
                        </configurationParameters>
                    </properties>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>${maven-jar-plugin.version}</version>
                <configuration>
                    <forceCreation>true</forceCreation>
                    <archive>
                        <forced>true</forced>
                        <addMavenDescriptor>false</addMavenDescriptor>
                        <manifest>
                            <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                            <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
                        </manifest>
                        <manifestEntries>
                            <built-by>ToolFactory</built-by>
                            <Bundle-Category>Utilities</Bundle-Category>
                            <Bundle-License>http://opensource.org/licenses/MIT</Bundle-License>
                            <Bundle-ManifestVersion>2</Bundle-ManifestVersion>
                            <Bundle-Name>Narcissus</Bundle-Name>
                            <Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
                            <Bundle-Vendor>ToolFactory (Luke Hutchison, Roberto Gentili)</Bundle-Vendor>
                            <Bundle-Description>${project.description}</Bundle-Description>
                            <Bundle-Version>${project.version}</Bundle-Version>
                            <Require-Capability>
                                osgi.ee;filter:="(&amp;(osgi.ee=JavaSE)(version=1.7))"</Require-Capability>
                            <Export-Package>
                                io.github.toolfactory.narcissus;version="${project.version}"</Export-Package>
                            <Multi-Release>true</Multi-Release>
                        </manifestEntries>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>${maven-source-plugin.version}</version>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <phase>package</phase>
                        <goals>
                            <goal>jar-no-fork</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>${maven-javadoc-plugin.version}</version>
                <configuration>
                    <encoding>UTF-8</encoding>
                    <source>${project_jdk_version}</source>
                    <detectJavaApiLink>false</detectJavaApiLink>
                    <doclint>all</doclint>
                    <show>public</show>
                </configuration>
                <executions>
                    <execution>
                        <id>attach-javadoc</id>
                        <phase>package</phase>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.sonatype.central</groupId>
                <artifactId>central-publishing-maven-plugin</artifactId>
                <version>0.8.0</version>
                <extensions>true</extensions>
                <configuration>
                    <publishingServerId>central</publishingServerId>
                    <autoPublish>false</autoPublish>
                    <waitUntil>uploaded</waitUntil>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
