Skip to content

kit-data-manager/ro-crate-java

Repository files navigation

ro-crate-java

Java CI with Gradle Coverage Status CodeQL Publish to Maven Central / OSSRH

A Java library to create and modify RO-Crates. The aim of this implementation is to not require too deep knowledge of the specification, and avoiding crates which do not fully comply to the specification, at the same time.

Use it in your application

Build the library / documentation

  • Building (with tests): ./gradlew clean build
  • Building (without tests): ./gradlew clean build -x test
  • Building with release profile: ./gradlew -Dprofile=release clean build
  • Doing a release: ./gradlew -Dprofile=release clean build release
    • Will prompt you about version number to use and next version number
    • Will make a git tag which can later be used in a GitHub release
      • A GitHub release will trigger the CI for publication. See also .github/workflows/publishRelease.yml.
  • Build documentation: ./gradlew javadoc

On Windows, replace ./gradlew with gradlew.bat.

RO-Crate Specification Compatibility

Quick-start

ro-crate-java makes use of the builder pattern to guide the user to create a valid RO-Crate, similar to:

RoCrate myFirstCrate = STARTER_CRATE
    .addDataEntity(
        new FileEntity.FileEntityBuilder()
            .setId("path/within/crate/survey-responses-2019.csv")
            .setLocation(Paths.get("path/to/current/location/experiment.csv"))
            .addProperty("name", "Survey responses")
            .addProperty("contentSize", "26452")
            .addProperty("encodingFormat", "text/csv")
            .build()
    )
    .addDataEntity(/*...*/)
    .addContextualEntity(/*...*/)
    .build();

A built or imported crate can of course also be modified afterwards. Take a look at our further documentation: