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

	<parent>
		<groupId>org.scijava</groupId>
		<artifactId>pom-scijava</artifactId>
		<version>44.0.0</version>
		<relativePath />
	</parent>

	<artifactId>scripting-kotlin</artifactId>
	<version>1.0.0</version>

	<name>SciJava Scripting: Kotlin</name>
	<description>JSR-223-compliant Kotlin scripting language plugin.</description>
	<url>https://github.com/scijava/scripting-kotlin</url>
	<inceptionYear>2016</inceptionYear>
	<organization>
		<name>SciJava</name>
		<url>https://scijava.org/</url>
	</organization>
	<licenses>
		<license>
			<name>Simplified BSD License</name>
			<distribution>repo</distribution>
		</license>
	</licenses>

	<developers>
		<developer>
			<id>ctrueden</id>
			<name>Curtis Rueden</name>
			<url>https://imagej.net/people/ctrueden</url>
			<roles>
				<role>founder</role>
				<role>lead</role>
				<role>developer</role>
				<role>debugger</role>
				<role>reviewer</role>
				<role>support</role>
				<role>maintainer</role>
			</roles>
		</developer>
	</developers>
	<contributors>
		<contributor>
			<name>Philipp Hanslovsky</name>
			<url>https://imagej.net/people/hanslovsky</url>
			<properties><id>hanslovsky</id></properties>
		</contributor>
	</contributors>

	<mailingLists>
		<mailingList>
			<name>SciJava</name>
			<subscribe>https://groups.google.com/group/scijava</subscribe>
			<unsubscribe>https://groups.google.com/group/scijava</unsubscribe>
			<post>scijava.com</post>
			<archive>https://groups.google.com/group/scijava</archive>
		</mailingList>
	</mailingLists>

	<scm>
		<connection>scm:git:https://github.com/scijava/scripting-kotlin</connection>
		<developerConnection>scm:git:git@github.com:scijava/scripting-kotlin</developerConnection>
		<tag>scripting-kotlin-1.0.0</tag>
		<url>https://github.com/scijava/scripting-kotlin</url>
	</scm>
	<issueManagement>
		<system>GitHub Issues</system>
		<url>https://github.com/scijava/scripting-kotlin/issues</url>
	</issueManagement>
	<ciManagement>
		<system>GitHub Actions</system>
		<url>https://github.com/scijava/scripting-kotlin/actions</url>
	</ciManagement>

	<properties>
		<scijava.jvm.version>1.8</scijava.jvm.version>

		<package-name>org.scijava.plugins.scripting.kotlin</package-name>
		<license.licenseName>bsd_2</license.licenseName>
		<license.copyrightOwners>SciJava developers.</license.copyrightOwners>

		<!-- NB: Work around duplicate classes issue in Kotlin dependencies. -->
		<allowedDuplicateClasses>org/jetbrains/kotlin/daemon/common/*,kotlinx/coroutines/**</allowedDuplicateClasses>

		<!-- NB: We have to disable manifest-only jar to be able to run tests on command line. -->
		<!-- NB: Tests work in IntelliJ but manifest-only jar seems to mess with it on command line. -->
		<!-- NB: cf: mvn surefire:help -Ddetail=true -->
		<surefire.useManifestOnlyJar>false</surefire.useManifestOnlyJar>

		<kotlin-compiler-embeddable.optional>false</kotlin-compiler-embeddable.optional>
	</properties>

	<dependencies>
		<!-- SciJava dependencies -->
		<dependency>
			<groupId>org.scijava</groupId>
			<artifactId>scijava-common</artifactId>
		</dependency>

		<!-- Kotlin dependencies -->
		<dependency>
			<groupId>org.jetbrains.kotlin</groupId>
			<artifactId>kotlin-compiler-embeddable</artifactId>
			<optional>${kotlin-compiler-embeddable.optional}</optional>
		</dependency>
		<dependency>
			<groupId>org.jetbrains.kotlin</groupId>
			<artifactId>kotlin-stdlib</artifactId>
		</dependency>
		<dependency>
			<groupId>org.jetbrains.kotlin</groupId>
			<artifactId>kotlin-scripting-jsr223</artifactId>
		</dependency>

		<!-- Test dependencies -->
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.scijava</groupId>
			<artifactId>scijava-common</artifactId>
			<classifier>tests</classifier>
			<scope>test</scope>
		</dependency>
	</dependencies>

	<profiles>
		<profile>
			<!--
			This is a pure-Kotlin project with no Java sources, so the
			maven-javadoc-plugin produces nothing ("No Javadoc in project").
			Use Dokka (managed by the pom-scijava parent hierarchy) to generate
			the javadoc JAR that Maven Central requires at release time.

			Reuse the sonatype-oss-release profile id so this Dokka execution is
			added to that profile when it activates, which the
			maven-release-plugin does during release:perform via the parent's
			releaseProfiles setting. This mirrors when the maven-javadoc-plugin
			runs for non-Kotlin projects, so a plain "mvn package" does not pay
			this Dokka cost.

			NB: Remove this profile once the project's parent includes the Dokka
			javadoc-jar wiring in pom-scijava-base's kotlin profile.
			-->
			<id>sonatype-oss-release</id>
			<build>
				<plugins>
					<plugin>
						<groupId>org.jetbrains.dokka</groupId>
						<artifactId>dokka-maven-plugin</artifactId>
						<version>${dokka-maven-plugin.version}</version>
						<executions>
							<execution>
								<id>attach-javadoc-jar</id>
								<phase>package</phase>
								<goals>
									<goal>javadocJar</goal>
								</goals>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>

		<profile>
			<!--
			The JetBrains trove4j fork clashes with the gnu trove4j jar in Fiji.
			We need to shade and relocate in this case.
			-->
			<id>shade-trove4j-fork</id>
			<activation>
				<property>
					<name>scijava.app.directory</name>
				</property>
			</activation>
			<properties>
				<kotlin-compiler-embeddable.optional>true</kotlin-compiler-embeddable.optional>
				<scijava.ignoreOptionalDependencies>true</scijava.ignoreOptionalDependencies>
			</properties>
			<build>
				<plugins>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-shade-plugin</artifactId>
						<version>${maven-shade-plugin.version}</version>
						<executions>
							<execution>
								<phase>package</phase>
								<goals>
									<goal>shade</goal>
								</goals>
								<configuration>
									<artifactSet>
										<includes>
											<include>org.jetbrains.intellij.deps:trove4j</include>
											<include>org.jetbrains.kotlin:kotlin-compiler-embeddable</include>
											<include>org.jetbrains.kotlin:kotlin-script-runtime</include>
											<include>org.jetbrains.kotlin:kotlin-reflect</include>
											<include>org.jetbrains.kotlin:kotlin-daemon-embeddable</include>
										</includes>
									</artifactSet>
									<relocations>
										<relocation>
											<pattern>gnu.trove</pattern>
											<shadedPattern>gnu.trove.shaded</shadedPattern>
										</relocation>
									</relocations>
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>
	</profiles>
</project>
