<?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>
	<groupId>org.cryptomator</groupId>
	<artifactId>integrations-win</artifactId>
	<version>1.5.0</version>

	<name>Cryptomator Integrations for Windows</name>
	<description>Provides optional Windows services used by Cryptomator</description>
	<url>https://github.com/cryptomator/integrations-win</url>
	<scm>
		<connection>scm:git:git@github.com:cryptomator/integrations-win.git</connection>
		<developerConnection>scm:git:git@github.com:cryptomator/integrations-win.git</developerConnection>
		<url>git@github.com:cryptomator/integrations-win.git</url>
	</scm>
	<developers>
		<developer>
			<name>Sebastian Stenzel</name>
			<email>sebastian.stenzel@skymatic.de</email>
			<timezone>+1</timezone>
			<organization>Skymatic GmbH</organization>
			<organizationUrl>http://skymatic.de</organizationUrl>
		</developer>
		<developer>
			<name>Armin Schrenk</name>
			<email>armin.schrenk@skymatic.de</email>
			<timezone>+1</timezone>
			<organization>Skymatic GmbH</organization>
			<organizationUrl>http://skymatic.de</organizationUrl>
		</developer>
	</developers>

	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<project.jdk.version>24</project.jdk.version>

		<!-- runtime dependencies -->
		<api.version>1.6.0</api.version>
		<slf4j.version>2.0.17</slf4j.version>
		<jackson.version>2.19.0</jackson.version>

		<!-- test dependencies -->
		<junit.jupiter.version>5.12.2</junit.jupiter.version>
		<mockito.version>5.17.0</mockito.version>

		<!-- build plugin dependencies -->
		<mvn-surefire.version>3.5.3</mvn-surefire.version>
		<mvn-failsafe.version>3.5.3</mvn-failsafe.version>
		<dependency-check.version>12.1.1</dependency-check.version>
		<central-publishing.version>0.7.0</central-publishing.version>
		<jextract-maven.version>0.4.3</jextract-maven.version>

		<!-- jextract props -->
		<win.umHeaderPath>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um</win.umHeaderPath>
		<jextract.executable>C:\Users\Arbeit\Programs\jextract-22\bin\jextract.bat</jextract.executable>
	</properties>

	<licenses>
		<license>
			<name>GNU Affero General Public License (AGPL) version 3.0</name>
			<url>https://www.gnu.org/licenses/agpl.txt</url>
			<distribution>repo</distribution>
		</license>
	</licenses>

	<dependencies>
		<dependency>
			<groupId>org.cryptomator</groupId>
			<artifactId>integrations-api</artifactId>
			<version>${api.version}</version>
		</dependency>
		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-api</artifactId>
			<version>${slf4j.version}</version>
		</dependency>
		<dependency>
			<groupId>com.fasterxml.jackson.core</groupId>
			<artifactId>jackson-databind</artifactId>
			<version>${jackson.version}</version>
		</dependency>
		<dependency>
			<groupId>com.fasterxml.jackson.core</groupId>
			<artifactId>jackson-annotations</artifactId>
			<version>${jackson.version}</version>
		</dependency>

		<!-- JUnit / Mockito / Hamcrest -->
		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-simple</artifactId>
			<version>${slf4j.version}</version>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.junit.jupiter</groupId>
			<artifactId>junit-jupiter</artifactId>
			<version>${junit.jupiter.version}</version>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.mockito</groupId>
			<artifactId>mockito-core</artifactId>
			<version>${mockito.version}</version>
			<scope>test</scope>
		</dependency>
	</dependencies>

	<build>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-clean-plugin</artifactId>
				<version>3.4.1</version>
				<configuration>
					<filesets>
						<fileset>
							<directory>${project.basedir}/src/main/headers</directory>
							<followSymlinks>false</followSymlinks>
							<includes>
								<include>*.h</include>
							</includes>
						</fileset>
						<fileset>
							<directory>${project.basedir}/src/main/resources</directory>
							<followSymlinks>false</followSymlinks>
							<includes>
								<include>*.dll</include>
							</includes>
						</fileset>
					</filesets>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>3.14.0</version>
				<configuration>
					<compilerArgs>
						<arg>-h</arg>
						<arg>${project.basedir}/src/main/headers</arg>
					</compilerArgs>
					<release>${project.jdk.version}</release>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-enforcer-plugin</artifactId>
				<version>3.5.0</version>
				<executions>
					<execution>
						<id>check-preconditions</id>
						<goals>
							<goal>enforce</goal>
						</goals>
						<configuration>
							<rules>
								<requireOS>
									<family>windows</family>
									<message>This build configuration requires Windows.</message>
								</requireOS>
							</rules>
						</configuration>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-dependency-plugin</artifactId>
				<version>3.8.1</version>
				<executions>
					<execution>
						<id>jar-paths-to-properties</id>
						<goals>
							<goal>properties</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<artifactId>maven-resources-plugin</artifactId>
				<version>3.3.1</version>
				<executions>
					<execution>
						<id>copy-dlls</id>
						<phase>process-classes</phase>
						<goals>
							<goal>copy-resources</goal>
						</goals>
						<configuration>
							<outputDirectory>${project.build.outputDirectory}</outputDirectory>
							<resources>
								<resource>
									<directory>${project.basedir}/src/main/resources</directory>
									<filtering>false</filtering>
									<includes>
										<include>*.dll</include>
									</includes>
								</resource>
							</resources>
						</configuration>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-surefire-plugin</artifactId>
				<version>${mvn-surefire.version}</version>
				<dependencies>
					<dependency>
						<groupId>me.fabriciorby</groupId>
						<artifactId>maven-surefire-junit5-tree-reporter</artifactId>
						<version>1.4.0</version>
					</dependency>
				</dependencies>
				<configuration>
					<systemPropertyVariables>
						<org.slf4j.simpleLogger.defaultLogLevel>ERROR</org.slf4j.simpleLogger.defaultLogLevel>
					</systemPropertyVariables>
					<consoleOutputReporter>
						<disable>true</disable>
					</consoleOutputReporter>
					<statelessTestsetInfoReporter
							implementation="org.apache.maven.plugin.surefire.extensions.junit5.JUnit5StatelessTestsetInfoTreeReporter">
					</statelessTestsetInfoReporter>
					<argLine>-javaagent:"${net.bytebuddy:byte-buddy-agent:jar}"</argLine>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-failsafe-plugin</artifactId>
				<version>${mvn-failsafe.version}</version>
				<executions>
					<execution>
						<goals>
							<goal>integration-test</goal>
							<goal>verify</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<artifactId>maven-source-plugin</artifactId>
				<version>3.3.1</version>
				<executions>
					<execution>
						<id>attach-sources</id>
						<goals>
							<goal>jar-no-fork</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<artifactId>maven-javadoc-plugin</artifactId>
				<version>3.11.2</version>
				<executions>
					<execution>
						<id>attach-javadocs</id>
						<goals>
							<goal>jar</goal>
						</goals>
					</execution>
				</executions>
				<configuration>
					<quiet>true</quiet>
					<release>${project.jdk.version}</release>
					<tags>
						<!-- workaround for "unknown tag: implNote", see https://blog.codefx.org/java/new-javadoc-tags/#Maven  -->
						<tag>
							<name>apiNote</name>
							<placement>a</placement>
							<head>API Note:</head>
						</tag>
						<tag>
							<name>implSpec</name>
							<placement>a</placement>
							<head>Implementation Requirements:</head>
						</tag>
						<tag>
							<name>implNote</name>
							<placement>a</placement>
							<head>Implementation Note:</head>
						</tag>
						<tag>
							<name>param</name>
						</tag>
						<tag>
							<name>return</name>
						</tag>
						<tag>
							<name>throws</name>
						</tag>
						<tag>
							<name>since</name>
						</tag>
						<tag>
							<name>version</name>
						</tag>
						<tag>
							<name>serialData</name>
						</tag>
						<tag>
							<name>see</name>
						</tag>
					</tags>
				</configuration>
			</plugin>
		</plugins>
	</build>

	<profiles>
		<profile>
			<id>dependency-check</id>
			<build>
				<plugins>
					<plugin>
						<groupId>org.owasp</groupId>
						<artifactId>dependency-check-maven</artifactId>
						<version>${dependency-check.version}</version>
						<configuration>
							<nvdValidForHours>24</nvdValidForHours>
							<failBuildOnCVSS>0</failBuildOnCVSS>
							<skipTestScope>true</skipTestScope>
							<detail>true</detail>
							<suppressionFile>suppression.xml</suppressionFile>
							<assemblyAnalyzerEnabled>false</assemblyAnalyzerEnabled>
							<nvdApiKeyEnvironmentVariable>NVD_API_KEY</nvdApiKeyEnvironmentVariable>
						</configuration>
						<executions>
							<execution>
								<goals>
									<goal>check</goal>
								</goals>
								<phase>validate</phase>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>

		<profile>
			<id>compile-native</id>
			<activation>
				<property>
					<name>!skipNativeCompile</name>
				</property>
			</activation>
			<properties>
				<devCommandFileDir>C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\</devCommandFileDir>
			</properties>
			<build>
				<plugins>
					<plugin>
						<groupId>org.codehaus.mojo</groupId>
						<artifactId>exec-maven-plugin</artifactId>
						<version>3.5.0</version>
						<configuration>
							<executable>cmd</executable>
							<workingDirectory>${project.basedir}</workingDirectory>
							<environmentVariables>
								<JAVA_HOME>${java.home}</JAVA_HOME>
							</environmentVariables>
						</configuration>
						<executions>
							<execution>
								<id>compile-x64</id>
								<goals>
									<goal>exec</goal>
								</goals>
								<phase>compile</phase>
								<configuration>
									<arguments>
										<argument>/c</argument>
										<argument>"${devCommandFileDir}\vcvars64.bat" &amp;&amp; make install</argument>
									</arguments>
								</configuration>
							</execution>
							<execution>
								<id>compile-arm64</id>
								<goals>
									<goal>exec</goal>
								</goals>
								<phase>compile</phase>
								<configuration>
									<arguments>
										<argument>/c</argument>
										<argument>"${devCommandFileDir}\vcvarsamd64_arm64.bat" &amp;&amp; make install ARCH=arm64</argument>
									</arguments>
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>

		<profile>
			<id>sign</id>
			<build>
				<plugins>
					<plugin>
						<artifactId>maven-gpg-plugin</artifactId>
						<version>3.2.7</version>
						<executions>
							<execution>
								<id>sign-artifacts</id>
								<phase>verify</phase>
								<goals>
									<goal>sign</goal>
								</goals>
								<configuration>
									<signer>bc</signer>
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>

		<profile>
			<id>deploy-central</id>
			<build>
				<plugins>
					<plugin>
						<groupId>org.sonatype.central</groupId>
						<artifactId>central-publishing-maven-plugin</artifactId>
						<version>${central-publishing.version}</version>
						<extensions>true</extensions>
						<configuration>
							<publishingServerId>central</publishingServerId>
 							<autoPublish>true</autoPublish>
						</configuration>
					</plugin>
				</plugins>
			</build>
		</profile>

		<profile>
			<id>deploy-github</id>
			<distributionManagement>
				<repository>
					<id>github</id>
					<name>GitHub Packages</name>
					<url>https://maven.pkg.github.com/cryptomator/integrations-win</url>
				</repository>
			</distributionManagement>
			<build>
				<plugins>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-deploy-plugin</artifactId>
						<version>3.1.4</version>
					</plugin>
				</plugins>
			</build>
		</profile>

		<profile>
			<id>jextract</id>
			<build>
				<plugins>
					<plugin>
						<groupId>io.github.coffeelibs</groupId>
						<artifactId>jextract-maven-plugin</artifactId>
						<version>${jextract-maven.version}</version>
						<configuration>
							<executable>${jextract.executable}</executable>
							<headerSearchPaths>${win.umHeaderPath}</headerSearchPaths>
							<outputDirectory>${project.build.sourceDirectory}</outputDirectory>
							<cPreprocessorMacros>
								<cPreprocessorMacro>_AMD64_</cPreprocessorMacro>
								<cPreprocessorMacro>UNICODE</cPreprocessorMacro>
								<cPreprocessorMacro>_WIN32_WINNT=0x0A00</cPreprocessorMacro>
							</cPreprocessorMacros>
						</configuration>
						<executions>
							<execution>
								<id>jextract-winreg</id>
								<goals>
									<goal>sources</goal>
								</goals>
								<configuration>
									<targetPackage>org.cryptomator.windows.capi.winreg</targetPackage>
									<headerFile>${win.umHeaderPath}/winreg.h</headerFile>
									<headerClassName>Winreg_h</headerClassName>
									<libraries>
										<library>Advapi32</library>
									</libraries>
									<includeFunctions>
										<includeFunction>RegCreateKeyTransactedW</includeFunction>
										<includeFunction>RegOpenKeyTransactedW</includeFunction>
										<includeFunction>RegDeleteKeyTransactedW</includeFunction>
										<includeFunction>RegCloseKey</includeFunction>
										<includeFunction>RegGetValueW</includeFunction>
										<includeFunction>RegSetKeyValueW</includeFunction>
										<includeFunction>RegDeleteKeyValueW</includeFunction>
										<includeFunction>RegDeleteTreeW</includeFunction>
									</includeFunctions>
									<includeConstants>
										<includeConstant>HKEY_CLASSES_ROOT</includeConstant>
										<includeConstant>HKEY_LOCAL_MACHINE</includeConstant>
										<includeConstant>HKEY_USERS</includeConstant>
										<includeConstant>HKEY_CURRENT_USER</includeConstant>
										<includeConstant>REG_OPTION_VOLATILE</includeConstant>
										<includeConstant>REG_OPTION_NON_VOLATILE</includeConstant>
										<includeConstant>KEY_READ</includeConstant>
										<includeConstant>KEY_WRITE</includeConstant>
										<includeConstant>REG_BINARY</includeConstant>
										<includeConstant>REG_DWORD</includeConstant>
										<includeConstant>REG_QWORD</includeConstant>
										<includeConstant>REG_SZ</includeConstant>
										<includeConstant>REG_EXPAND_SZ</includeConstant>
										<includeConstant>REG_MULTI_SZ</includeConstant>
										<includeConstant>RRF_RT_ANY</includeConstant>
										<includeConstant>RRF_RT_REG_BINARY</includeConstant>
										<includeConstant>RRF_RT_REG_DWORD</includeConstant>
										<includeConstant>RRF_RT_REG_QWORD</includeConstant>
										<includeConstant>RRF_RT_REG_SZ</includeConstant>
										<includeConstant>RRF_RT_REG_EXPAND_SZ</includeConstant>
										<includeConstant>RRF_RT_REG_MULTI_SZ</includeConstant>
										<includeConstant>RRF_NOEXPAND</includeConstant>
									</includeConstants>
								</configuration>
							</execution>
							<execution>
								<id>jextract-ktmw32</id>
								<goals>
									<goal>sources</goal>
								</goals>
								<configuration>
									<targetPackage>org.cryptomator.windows.capi.ktmw32</targetPackage>
									<headerFile>${project.basedir}/src/main/resources/ktmw32_helper.h</headerFile>
									<headerClassName>Ktmw32_h</headerClassName>
									<libraries>
										<library>KtmW32</library>
									</libraries>
									<includeFunctions>
										<includeFunction>CreateTransaction</includeFunction>
										<includeFunction>CommitTransaction</includeFunction>
										<includeFunction>RollbackTransaction</includeFunction>
									</includeFunctions>
									<includeConstants>
										<includeConstant>INVALID_HANDLE_VALUE</includeConstant>
									</includeConstants>
								</configuration>
							</execution>
							<execution>
								<id>jextract-common</id>
								<goals>
									<goal>sources</goal>
								</goals>
								<configuration>
									<targetPackage>org.cryptomator.windows.capi.common</targetPackage>
									<headerFile>${win.umHeaderPath}/Windows.h</headerFile>
									<headerClassName>Windows_h</headerClassName>
									<libraries>
										<library>Kernel32</library>
									</libraries>
									<includeFunctions>
										<includeFunction>GetLastError</includeFunction>
										<includeFunction>CloseHandle</includeFunction>
									</includeFunctions>
									<includeConstants>
										<includeConstant>ERROR_SUCCESS</includeConstant>
										<includeConstant>INVALID_HANDLE_VALUE</includeConstant>
										<includeConstant>ERROR_SUCCESS</includeConstant>
										<includeConstant>ERROR_FILE_NOT_FOUND</includeConstant>
										<includeConstant>ERROR_MORE_DATA</includeConstant>
									</includeConstants>
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>
	</profiles>
</project>
