<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>

    <parent>
        <groupId>com.logonbox</groupId>
        <artifactId>vmsee-agent</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>
    <artifactId>vmsee-agent-tools</artifactId>
    <name>VMSee agent - Tools</name>
    <packaging>jar</packaging>
    <dependencies>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>vmsee-agent-lib</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>info.picocli</groupId>
            <artifactId>picocli</artifactId>
        </dependency>
       <dependency>
            <groupId>com.sshtools</groupId>
            <artifactId>slf4j-tty</artifactId>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jul-to-slf4j</artifactId>
        </dependency>
        <dependency>
            <groupId>com.sshtools</groupId>
            <artifactId>liftlib</artifactId>
            <version>0.9.13-SNAPSHOT</version>
        </dependency>
		<dependency>
			<groupId>org.jline</groupId>
			<artifactId>jline-terminal-ffm</artifactId>
			<version>${jline.version}</version> 
		</dependency>
		<dependency>
			<groupId>org.jline</groupId>
			<artifactId>jline-console</artifactId>
			<version>${jline.version}</version>
		</dependency>
		<dependency>
			<groupId>org.jline</groupId>
			<artifactId>jline-style</artifactId>
			<version>${jline.version}</version>
		</dependency>
		<dependency>
			<groupId>com.github.hypfvieh</groupId>
			<artifactId>dbus-java-core</artifactId>
		</dependency>
		<dependency>
			<groupId>com.github.hypfvieh</groupId>
			<artifactId>dbus-java-transport-native-unixsocket</artifactId>
		</dependency>
    </dependencies>
    <description>
        Various tools for using the VMSee Agent.
    </description>

    <profiles>
        <!-- Native Activation -->
        <profile>
            <id>windows</id>
            <activation>
                <os>
                    <family>windows</family>
                </os>
            </activation>
            <properties>
				<graalvm.firstArgs>-H:+UnlockExperimentalVMOptions -H:+AddAllCharsets</graalvm.firstArgs>
			</properties>
        </profile>
        <profile>
            <id>linux</id>
            <activation>
                <os>
                    <family>linux</family>
                </os>
            </activation>
        </profile>
        <profile>
            <id>macos</id>
            <activation>
                <os>
                    <family>mac</family>
                </os>
            </activation>
        </profile>
        <!-- Graal Native Image -->
        <profile>
            <id>native-image</id>

            <build>
                <plugins>
                    <plugin>
                        <groupId>org.graalvm.buildtools</groupId>
                        <artifactId>native-maven-plugin</artifactId>
                        <version>${graalvm.version}</version>
                        <executions>
                            <execution>
                                <id>vmsee-do</id>
                                <goals>
                                    <goal>compile-no-fork</goal>
                                </goals>
                                <phase>package</phase>
                                <configuration>
                                    <mainClass>com.logonbox.vmsee.agent.tools.AgentDo</mainClass>
                                    <imageName>vmsee-do</imageName>
                                    <buildArgs>
	                                    <buildArg>-march=compatibility</buildArg>
										<buildArg>-H:Log=registerResource:verbose</buildArg>
                                        <buildArg>--report-unsupported-elements-at-runtime</buildArg>
                                        <buildArg>-R:MaxHeapSize=64m</buildArg>
										<buildArg>--install-exit-handlers</buildArg>
                                        <buildArg>--enable-http</buildArg>
                                        <buildArg>--enable-https</buildArg>
                                        <buildArg>--enable-url-protocols=http,https,file</buildArg>
                                        
                                        <buildArg>--initialize-at-build-time=com.sshtools.common.files.nio.AbstractFileNIOProvider</buildArg>
                                        <!--TODO This should not be necessary! For some reason native-image-annotations is not working for these -->
                                        <buildArg>-H:IncludeResources=win32.*</buildArg>
                                    </buildArgs>
                                     <metadataRepository>
                                        <enabled>true</enabled>
                                     </metadataRepository>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>shaded</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-shade-plugin</artifactId>
                        <version>2.4.3</version>
                        <configuration>
                            <transformers>
                                <transformer
                                    implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass>com.logonbox.vmsee.agent.tools.AgentDo</mainClass>
                                </transformer>
                            </transformers>
                            <filters>
                                <filter>
                                    <artifact>*:*</artifact>
                                    <excludes>
                                        <exclude>module-info.class</exclude>
                                        <exclude>META-INF/*.SF</exclude>
                                        <exclude>META-INF/*.DSA</exclude>
                                        <exclude>META-INF/*.RSA</exclude>
                                    </excludes>
                                </filter>
                            </filters>
                            <shadedArtifactAttached>true</shadedArtifactAttached>
                            <shadedClassifierName>launcher</shadedClassifierName>
                        </configuration>
                        <executions>
                            <execution>
                                <phase>package</phase>
                                <goals>
                                    <goal>shade</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
