Neo4j Plugin built using both Java and Kotlin

Posting this because it was something I was interested in and could not find a definitive answer whether this was possible.

The answer is YES, you can create a working NEO4J Plugin which has both Java source files and Kotlin source files. The key was in Eman Padah's article about building a NEO4J Plugin using Kotlin ("in 20 minutes"). The pom.xml from that project supports Java source files in the source directory folder.

I have tried it, installed the plugin which had methods created from Java soruce files and from Kotlin source files. All of the methods were available and worked as expected.

Reference:

A simple example of a Kotlin source file in a NEO4J plugin (creates plugin function "date_support.current_date_string", which could be used in a CYPHER statement like 'return date_support.current_date_string()'.

package datesupport

import org.neo4j.procedure.UserFunction
import org.neo4j.procedure.Description
import org.neo4j.procedure.Name

import java.time.Duration;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;

class DateSupport{

    @UserFunction(name = "date_support.current_date_string")
    fun current_date_string() : String
    {
        return LocalDateTime.now().format(DateTimeFormatter.BASIC_ISO_DATE);
    }

}

Here is the GITHUB repository related to the Kotlin article:

https://github.com/doriumlab/dor-trinity-graph

The key element is the pom.xml which allows the Kotlin and Java source files in a NEO4J plugin. It looks like this presently:

<?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>Dor.Neo4j.Crypt.Sha256</groupId>
    <artifactId>CryptSha256</artifactId>
    <version>1.0-SNAPSHOT</version>
    <properties>
        <neo4j.version>3.3.3</neo4j.version>
        <kotlin.version>1.2.30</kotlin.version>
    </properties>
    <dependencies>
        <dependency>
            <!-- This gives us the Procedure API our runtime code uses.
                 We have a `provided` scope on it, because when this is
                 deployed in a Neo4j Instance, the API will be provided
                 by Neo4j. If you add non-Neo4j dependencies to this
                 project, their scope should normally be `compile` -->
            <groupId>org.neo4j</groupId>
            <artifactId>neo4j</artifactId>
            <version>${neo4j.version}</version>
            <scope>provided</scope>
        </dependency>

        <!-- Test Dependencies -->
        <dependency>
            <!-- This is used for a utility that lets us start Neo4j with
                 a specific Procedure, which is nice for writing tests. -->
            <groupId>org.neo4j.test</groupId>
            <artifactId>neo4j-harness</artifactId>
            <version>${neo4j.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <!-- Used to send cypher statements to our procedure. -->
            <groupId>org.neo4j.driver</groupId>
            <artifactId>neo4j-java-driver</artifactId>
            <version>1.4.2</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>


        <dependency>
            <groupId>net.biville.florent</groupId>
            <artifactId>neo4j-sproc-compiler</artifactId>
            <version>1.2</version>
            <scope>provided</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-stdlib-jdk8</artifactId>
            <version>${kotlin.version}</version>
        </dependency>
        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-test-junit</artifactId>
            <version>${kotlin.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <sourceDirectory>src/main/java</sourceDirectory>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <!-- Neo4j Procedures require Java 8 -->
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <!-- This generates a jar-file with our procedure code,
                 plus any dependencies marked as `compile` scope.
                 This should then be deployed in the `plugins` directory
                 of each Neo4j instance in your deployment.
                 After a restart, the procedure is available for calling. -->
                <artifactId>maven-shade-plugin</artifactId>
                <version>2.4.3</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.jetbrains.kotlin</groupId>
                <artifactId>kotlin-maven-plugin</artifactId>
                <version>${kotlin.version}</version>
                <executions>
                    <execution>
                        <id>compile</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>test-compile</id>
                        <phase>test-compile</phase>
                        <goals>
                            <goal>test-compile</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <jvmTarget>1.8</jvmTarget>
                </configuration>
            </plugin>
        </plugins>
    </build>


</project>