Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
3598384
chore(deps): update dependency gradle to v8.14.1
renovate[bot] May 22, 2025
a5896f5
chore(deps): update dependency com.networknt:json-schema-validator to…
renovate[bot] May 23, 2025
355b856
refactor: rename ContextTest to RoCrateMetadataContextTest for clarity
Pfeil May 28, 2025
9d639bd
test: add Context tests for new context implementation
Pfeil May 28, 2025
8803c60
feat: add support for context prefixes in entity checks
Pfeil Jun 2, 2025
4afd85e
feat: add entity checks in RoCrateBuilder for data and contextual ent…
Pfeil Jun 2, 2025
78b1957
chore: fix typo in test and add entity check
Pfeil Jun 2, 2025
f809820
chore(deps): update dependency org.junit:junit-bom to v5.13.0
renovate[bot] May 30, 2025
39518cc
doc: improve javadoc for context class
Pfeil Jun 2, 2025
bd8aba4
Merge pull request #267 from kit-data-manager/add-context-prefix-support
Pfeil Jun 2, 2025
11fc59c
test: add rough tests for future RO-Crate metadata generation
Pfeil Jun 3, 2025
b594997
test: refine first tests for future RO-Crate metadata generation
Pfeil Jun 3, 2025
5e5a37c
test: add bidirectional relation test for implicit crate metadata
Pfeil Jun 3, 2025
bb170bb
test: add test for accumulating actions during multiple writes to RO-…
Pfeil Jun 3, 2025
16002a6
test: add debugging output for metadata in RO-Crate tests
Pfeil Jun 3, 2025
a08c314
test: add validation tests for RO-Crate version format and completeness
Pfeil Jun 3, 2025
4e817e9
test: add provenance tests for modifying RO-Crate metadata
Pfeil Jun 3, 2025
b855b80
test: add validation for RO-Crate metadata after writing and modifyin…
Pfeil Jun 3, 2025
b90d3c8
feat: add support for automatic provenance management in CrateWriter
Pfeil Jun 3, 2025
cc97444
chore: add TODO for reading software version from Gradle in Provenanc…
Pfeil Jun 3, 2025
2221627
fix: standardize property name to 'Action' in ProvenanceManager and r…
Pfeil Jun 4, 2025
b36e64b
feat: add imported state management to Crate interface and implementa…
Pfeil Jun 4, 2025
fe63d12
feat: refactor buildRoCrateJavaEntity to streamline entity creation a…
Pfeil Jun 4, 2025
f2086f3
fix: wrong assumptions / typos in RoCrateMetadataGenerationTest
Pfeil Jun 4, 2025
7d3020c
fix(test): disable automatic provenance in tests unrelated to metadat…
Pfeil Jun 4, 2025
7257354
feat: add version properties generation and load version from propert…
Pfeil Jun 4, 2025
e60ae89
chore: update version to 2.1.0-rc3 in CITATION.cff
Pfeil Jun 4, 2025
db56685
fix: improve error handling in loadVersionFromProperties method
Pfeil Jun 5, 2025
501060d
chore: implement ClasspathPropertiesVersionProvider for version retri…
Pfeil Jun 5, 2025
55648fd
feat: create provenance entity per library version and keep old ones
Pfeil Jun 5, 2025
0fba28d
feat: action entities in provenance now actually call the crate their…
Pfeil Jun 5, 2025
fe179bf
feat: add utility class for handling RO-Crate graph operations
Pfeil Jun 5, 2025
f4046ea
test: add unit tests for ProvenanceManager library ID retrieval
Pfeil Jun 5, 2025
9656ea7
feat: add getIdProperty method to retrieve a nested id property value…
Pfeil Jun 5, 2025
6cbbbc8
test: add unit tests for ProvenanceManager
Pfeil Jun 5, 2025
77c4279
refactor: update withAutomaticProvenance method to accept ProvenanceM…
Pfeil Jun 5, 2025
3b47ecc
doc: complete javadocs for CrateWriter
Pfeil Jun 5, 2025
c42b185
test: add delay in RoCrateMetadataGenerationTest to ensure crate stab…
Pfeil Jun 5, 2025
210d6ac
refactor: reduce possibly missing code coverage
Pfeil Jun 5, 2025
eb89c94
chore: fix small linter complaints in AbstractEntity and ClasspathPro…
Pfeil Jun 5, 2025
9cbe059
test: add sleep delays in RoCrateMetadataGenerationTest to ensure sta…
Pfeil Jun 5, 2025
ec9e9da
doc: enhance documentation in ProvenanceManager for clarity and consi…
Pfeil Jun 5, 2025
7905f12
Merge pull request #268 from kit-data-manager/265-store-provenance-in…
Pfeil Jun 5, 2025
f2f70ac
refactor: update ClasspathPropertiesVersionProvider to use lazy initi…
Pfeil Jun 5, 2025
57bf583
fix: use existing provenanceManager instance in CrateWriter for prove…
Pfeil Jun 5, 2025
5f172da
chore(deps): update dependency gradle to v8.14.2
renovate[bot] Jun 5, 2025
fa6dd22
feat: add updateCff task to update version and date-released in CITAT…
Pfeil Jun 6, 2025
2507724
fix: updateCff gradle task does not require release definitions and c…
Pfeil Jun 6, 2025
88fc710
chore: remove unnecessary whitespace in build.gradle and profile-rele…
Pfeil Jun 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ authors:
given-names: "Sabrine"
orcid: "https://orcid.org/0000-0002-4480-6116"
title: "ro-crate-java"
version: 1.0.3
version: 2.1.0-rc3
date-released: 2022-07-19
url: "https://github.com/kit-data-manager/ro-crate-java"
27 changes: 25 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ ext {

dependencies {
// JUnit setup for testing
testImplementation(platform("org.junit:junit-bom:5.12.2"))
testImplementation(platform("org.junit:junit-bom:5.13.0"))
Comment thread
Pfeil marked this conversation as resolved.
testImplementation('org.junit.jupiter:junit-jupiter')
testRuntimeOnly('org.junit.platform:junit-platform-launcher')
// JSON object mapping / (de-)serialization
Expand All @@ -64,7 +64,7 @@ dependencies {
// JSON-LD, Zenodo mapping
implementation group: 'com.apicatalog', name: 'titanium-json-ld', version: '1.6.0'
// metadata validation, profiles based on JSON schema
implementation group: "com.networknt", name: "json-schema-validator", version: "1.5.6"
implementation group: "com.networknt", name: "json-schema-validator", version: "1.5.7"
implementation 'org.glassfish:jakarta.json:2.0.1'
//JTE for template processing
implementation('gg.jte:jte:3.2.1')
Expand Down Expand Up @@ -111,6 +111,22 @@ configurations {
performanceTestImplementation.extendsFrom implementation
}

// Task for creating a resource file with the version info
tasks.register("generateVersionProps", WriteProperties) { t ->
def generatedResourcesDir = project.layout.buildDirectory.dir(["resources", "main"].join(File.separator))
def outputFile = generatedResourcesDir.map { it.file("version.properties") }

t.destinationFile = outputFile.get().asFile
t.property("version", version)
}

tasks.register("generateVersionPropsTest", WriteProperties) { t ->
def generatedResourcesDir = project.layout.buildDirectory.dir(["resources", "test"].join(File.separator))
def outputFile = generatedResourcesDir.map { it.file("version.properties") }

t.destinationFile = outputFile.get().asFile
t.property("version", version)
}

tasks.register('performanceContextEntitiesBenchmark', JavaExec) {
description = "Run the context entities benchmarks."
Expand Down Expand Up @@ -154,8 +170,13 @@ tasks.register('performanceReadWriteMultipleCratesBenchmark', JavaExec) {
mainClass = 'edu.kit.datamanager.ro_crate.multiplecrates.MultipleCratesWriteAndRead'
}

compileJava {
dependsOn generateVersionProps
}

test {
useJUnitPlatform()
dependsOn generateVersionPropsTest
finalizedBy jacocoTestReport
}

Expand All @@ -178,3 +199,5 @@ if (System.getProperty('profile') == "release") {
println 'Using release profile for building ' + project.getName()
apply from: 'gradle/profile-release.gradle'
}

apply from: 'gradle/updateCff.gradle'
2 changes: 1 addition & 1 deletion gradle/profile-release.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
apply plugin: 'net.researchgate.release'
apply plugin: 'maven-publish'
apply plugin: 'signing'

//for plugin net.researchgate.release
//see https://github.com/researchgate/gradle-release
release {
Expand Down
70 changes: 70 additions & 0 deletions gradle/updateCff.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import java.time.LocalDate
import java.time.format.DateTimeFormatter

/**
* This file defines the updateCff task.
*
* This task hooks into the workflow of the release task,
* which, according to the source code of the release plugin,
* seems to be defined like this:
*
* tasks = [
* "${p}createScmAdapter" as String,
* "${p}initScmAdapter" as String,
* "${p}checkCommitNeeded" as String,
* "${p}checkUpdateNeeded" as String,
* "${p}checkoutMergeToReleaseBranch" as String,
* "${p}unSnapshotVersion" as String,
* "${p}confirmReleaseVersion" as String,
* -> we insert our task here <-
* "${p}checkSnapshotDependencies" as String,
* "${p}runBuildTasks" as String,
* "${p}preTagCommit" as String,
* "${p}createReleaseTag" as String,
* "${p}checkoutMergeFromReleaseBranch" as String,
* "${p}updateVersion" as String,
* "${p}commitNewVersion" as String
* ]
*/

tasks.register('updateCff') {
group = 'release'
description = 'Updates the version in CITATION.cff file'

outputs.file("CITATION.cff")

Comment on lines +30 to +35
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Declare task inputs for up-to-date checks.
Gradle tasks should declare both inputs and outputs to support incremental builds. Add inputs.file("CITATION.cff") alongside the existing output.

 tasks.register('updateCff') {
     group = 'release'
     description = 'Updates the version in CITATION.cff file'
-    outputs.file("CITATION.cff")
+    inputs.file("CITATION.cff")
+    outputs.file("CITATION.cff")
     ...
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
tasks.register('updateCff') {
group = 'release'
description = 'Updates the version in CITATION.cff file'
outputs.file("CITATION.cff")
tasks.register('updateCff') {
group = 'release'
description = 'Updates the version in CITATION.cff file'
inputs.file("CITATION.cff")
outputs.file("CITATION.cff")
...
}
🤖 Prompt for AI Agents
In gradle/updateCff.gradle around lines 30 to 35, the 'updateCff' task declares
outputs but lacks declared inputs, which is necessary for Gradle's incremental
build checks. Add an inputs declaration by including inputs.file("CITATION.cff")
within the task configuration to properly specify the input file for up-to-date
checks.

doLast {
def version = project.version.toString()
def today = LocalDate.now().format(DateTimeFormatter.ISO_DATE)

def cffFile = file('CITATION.cff')
def content = cffFile.text

// Update or insert version
if (content.contains('version:')) {
content = content.replaceAll(/(?m)^version:\s*.+$/, "version: ${version}")
} else {
content = content + "\nversion: ${version}"
}

// Update or insert date-released
if (content.contains('date-released:')) {
content = content.replaceAll(/(?m)^date-released:\s*.+$/, "date-released: ${today}")
} else {
content = content + "\ndate-released: ${today}"
}

cffFile.text = content
println "Updated CITATION.cff to version ${version} and date-released ${today}"
}
}

// Make sure your custom task runs after a specific task in the release sequence
tasks.named('updateCff') {
mustRunAfter(tasks.named('confirmReleaseVersion'))
}

// Ensure subsequent tasks in the release sequence run after your custom task
tasks.named('checkSnapshotDependencies') {
dependsOn('updateCff')
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
22 changes: 22 additions & 0 deletions src/main/java/edu/kit/datamanager/ro_crate/Crate.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,28 @@
*/
public interface Crate {

/**
* Mark the crate as imported, i.e. it has been read from a file
* or is for other reasons not considered a new crate.
* <p>
* This is useful mostly for readers to indicate this in case
* the crate may not have any provenance information yet and
* should still be recognized as an imported crate.
*
* @return this crate, for convenience.
*/
Crate markAsImported();

/**
* Check if the crate is marked as imported.
* <p>
* If true, it indicates that the crate has been read from a file
* or is for other reasons not considered a new crate.
*
* @return true if the crate is marked as imported, false otherwise.
*/
boolean isImported();

/**
* Read version from the crate descriptor and return it as a class
* representation.
Expand Down
20 changes: 20 additions & 0 deletions src/main/java/edu/kit/datamanager/ro_crate/RoCrate.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,24 @@ public class RoCrate implements Crate {

protected Collection<File> untrackedFiles;

/**
* Indicates whether this crate has been imported from an external source.
* This is used to determine if ro-crate-java should add a CreateAction
* or an UpdateAction in the provenance on export.
*/
protected boolean isImported = false;

@Override
public RoCrate markAsImported() {
this.isImported = true;
return this;
}

@Override
public boolean isImported() {
return this.isImported;
}

@Override
public CratePreview getPreview() {
return this.roCratePreview;
Expand Down Expand Up @@ -375,12 +393,14 @@ public RoCrateBuilder addDescription(String description) {
* @return returns the builder for further usage.
*/
public RoCrateBuilder addDataEntity(DataEntity dataEntity) {
this.metadataContext.checkEntity(dataEntity);
Comment thread
Pfeil marked this conversation as resolved.
this.payload.addDataEntity(dataEntity);
this.rootDataEntity.addToHasPart(dataEntity.getId());
return this;
}

public RoCrateBuilder addContextualEntity(ContextualEntity contextualEntity) {
this.metadataContext.checkEntity(contextualEntity);
this.payload.addContextualEntity(contextualEntity);
return this;
}
Expand Down
Loading
Loading