For the latest stable version, please use Spring Data Neo4j 7.3.4!

Building Spring Data Neo4j

Requirements

  • JDK 17+ (Can be OpenJDK or Oracle JDK)

  • Maven 3.8.5 (We provide the Maven wrapper, see mvnw respectively mvnw.cmd in the project root; the wrapper downloads the appropriate Maven version automatically)

  • A Neo4j 5.+ database, either

About the JDK version

Choosing JDK 17 is a decision influenced by various aspects

  • SDN is a Spring Data project. Spring Data commons baseline is JDK 17 and so is Spring Framework’s baseline. Thus, it is only natural to keep the JDK 17 baseline.

Running the build

The following sections are alternatives and roughly sorted by increased effort.

All builds require a local copy of the project:

Clone SDN
$ git clone [email protected]:spring-projects/spring-data-neo4j.git

Before you proceed, verify your locally installed JDK version. The output should be similar:

Verify your JDK
$ java -version
java version "18.0.1" 2022-04-19
Java(TM) SE Runtime Environment (build 18.0.1+10-24)
Java HotSpot(TM) 64-Bit Server VM (build 18.0.1+10-24, mixed mode, sharing)

With Docker installed

Using the default image

If you don’t have Docker installed, head over to Docker Desktop. In short, Docker is a tool that helps you running lightweight software images using OS-level virtualization in so-called containers.

Our build uses Testcontainers Neo4j to bring up a database instance.

Build with default settings on Linux / macOS
$ ./mvnw clean verify

On a Windows machine, use

Build with default settings on Windows
$ mvnw.cmd clean verify

The output should be similar.

Using another image

The image version to use can be configured through an environmental variable like this:

Build using a different Neo4j Docker image
$ SDN_NEO4J_VERSION=5.3.0-enterprise SDN_NEO4J_ACCEPT_COMMERCIAL_EDITION=yes ./mvnw clean verify

Here we are using 5.3.0 enterprise and also accept the license agreement.

Consult your operating system or shell manual on how to define environment variables if specifying them inline does not work for you.

Against a locally running database

Running against a locally running database will erase its complete content.

Building against a locally running database is faster, as it does not restart a container each time. We do this a lot during our development.

You can get a copy of Neo4j at our download center free of charge.

Please download the version applicable to your operating system and follow the instructions to start it. A required step is to open a browser and go to localhost:7474 after you started the database and change the default password from neo4j to something of your liking.

After that, you can run a complete build by specifying the local bolt URL:

Build using a locally running database
$ SDN_NEO4J_URL=bolt://localhost:7687 SDN_NEO4J_PASSWORD=verysecret ./mvnw clean verify

Summary of environment variables controlling the build

Name Default value Meaning

SDN_NEO4J_VERSION

5.3.0

Version of the Neo4j docker image to use, see Neo4j Docker Official Images

SDN_NEO4J_ACCEPT_COMMERCIAL_EDITION

no

Some tests may require the enterprise edition of Neo4j. We build and test against the enterprise edition internally, but we won’t force you to accept the license if you don’t want to.

SDN_NEO4J_URL

not set

Setting this environment allows connecting to a locally running Neo4j instance. We use this a lot during development.

SDN_NEO4J_PASSWORD

not set

Password for the neo4j user of the instance configured with SDN_NEO4J_URL.

You need to set both SDN_NEO4J_URL and SDN_NEO4J_PASSWORD to use a local instance.

Checkstyle and friends

There is no quality gate in place at the moment to ensure that the code/test ratio stays as is, but please consider adding tests to your contributions.

We have some rather mild checkstyle rules in place, enforcing more or less default Java formatting rules. Your build will break on formatting errors or something like unused imports.