Skip to content
This repository has been archived by the owner on Jan 17, 2024. It is now read-only.

Latest commit

 

History

History
144 lines (108 loc) · 4.1 KB

CONTRIBUTING.adoc

File metadata and controls

144 lines (108 loc) · 4.1 KB

Contributing

Building and compiling sql2cypher

JDK 17 and Maven is required. Please run to test and package the project:

Warning
For the time being, you need to install a snapshot version of both jOOQ and cypher-dsl.
git clone --depth 1 --branch stable-sql2cypher git@github.com:jOOQ/jOOQ.git
cd jOOQ
mvn -DskipTests -pl jOOQ -pl jOOQ-meta -am install
cd -
./mvnw verify

There’s a fast profile that will skip all the tests and validations:

./mvnw -Dfast package

The build will create an assembly inside the target directory, with two executable scripts inside the bin sub-directory:

sql2cypher git:(main) ✗ tree target/assembly
target/assembly
├── bin
│   ├── sql2cypher
│   └── sql2cypher.bat
└── lib
    ├── apiguardian-api-1.1.2.jar
    ├── jooq-3.18.0-SNAPSHOT.jar
    ├── neo4j-cypher-dsl-2023.0.1.jar
    ├── picocli-4.7.0.jar
    ├── r2dbc-spi-1.0.0.RELEASE.jar
    ├── reactive-streams-1.0.3.jar
    └── sql2cypher-1.0-SNAPSHOT.jar

2 directories, 9 files

Native image (GraalVM) support

There’s somewhat support to run this application as native image, but jOOQ itself is not yet fully GraalVM compatible (see jOOQ 8779).

Please install GraalVM 22.3 for Java 17 and native image. One way is SDKMAN!:

sdk install java 22.3.r17-grl
gu install native-image

Afterwards you can run our build for native image like this:

sdk use java 22.3.r17-grl
./mvnw -Dnative package
file target/sql2cypher

Test the generated image like this:

Testing native image
time ./target/sql2cypher 'SELECT p.name, cast(p.age as STRING)
FROM "Person" AS p
WHERE p.age = 18 + rand()' 2>/dev/null
Output and runtime native image
MATCH (p:Person)
WHERE p.age = (18 + rand())
RETURN p.name, toString(p.age)

0,01s user 0,01s system 73% cpu 0,025 total

The necessary reflection-config.json has been created partially via the GraalVM agent run like this

./mvnw -Dfast package
JAVA_OPTS=-agentlib:native-image-agent=config-output-dir=target/generated-native-image-config target/assembly/bin/sql2cypher "SELECT 1"

And a printing breakpoint in the constructor of org.jooq.impl.ArrayDataType.ArrayDataType with the following content:

"{\"name\": \"" + elementType.getType().getName() + "[]\", \"allPublicConstructors\": true},"

Tasks

Formatting sources / adding headers

When you add new files, you can run

./mvnw license:format

to add required headers automatically.

We use spring-javaformat to format the source files.

./mvnw spring-javaformat:apply
Tip
The Spring Developers write: "The source formatter does not fundamentally change your code. For example, it will not change the order of import statements. It is effectively limited to adding or removing whitespace and line feeds." This means the following checkstyle check might still fail. Some common errors:
Static imports, import javax. and java. before others
Static imports are helpful, yes, but when working with 2 builders in the same project (here jOOQ and Cypher-DSL), they can be quite confusing.

There are plugins for Eclipse and IntelliJ IDEA and the Checkstyle settings can be imported as well. We took those "as is" and just disabled the lambda check (requiring even single parameters to have parenthesis).

Sorting the build file

To keep the dependencies in a predictable order, we enforce sorting of the build file. You can trigger this manually via

./mvnw  sortpom:verify@sort