-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Uses an xjc gradle plugin that has been updated recently (previous is basically dead) - Does as much as possible in groovy, rather than via the plugin, which hopefully means we can drop-in replacement since no special functionality is required - jakarta is now used --------- Co-authored-by: Lars-Olav Vågene <42863501+LarsV123@users.noreply.github.com>
- Loading branch information
Showing
11 changed files
with
120 additions
and
83 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: Build | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
types: [opened, reopened, synchronize] | ||
|
||
jobs: | ||
build: | ||
uses: BIBSYSDEV/nva-github-workflows/.github/workflows/java.yml@v1 | ||
with: | ||
lint_openapi: false | ||
lint_cloudformation: false | ||
secrets: | ||
codacy_token: ${{ secrets.CODACY_PROJECT_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,80 @@ | ||
import java.nio.file.Files | ||
import java.nio.file.Paths | ||
|
||
plugins { | ||
id 'java' | ||
id "org.unbroken-dome.xjc" version "2.0.0" | ||
id("com.github.bjornvester.xjc") version "1.8.1" | ||
id "de.undercouch.download" version "5.6.0" | ||
} | ||
|
||
group 'no.unit.nva' | ||
|
||
dependencies { | ||
implementation group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.1' | ||
implementation group: 'jakarta.xml.bind', name: 'jakarta.xml.bind-api', version: '2.3.2' | ||
runtimeOnly group: 'org.glassfish.jaxb', name: 'jaxb-runtime', version: '2.3.1' | ||
implementation group: 'jakarta.xml.bind', name: 'jakarta.xml.bind-api', version: '4.0.2' | ||
runtimeOnly group: 'org.glassfish.jaxb', name: 'jaxb-runtime', version: '4.0.5' | ||
} | ||
|
||
def schemaDir = "${buildDir}/tmp/schema/" | ||
ext.SCHEMA_VERSION = '4.5' | ||
ext.SCHEMA_DIR = file(layout.buildDirectory.asFile.get().toURI().toString() + '/tmp/schema') | ||
ext.METADATA_XSD = 'metadata.xsd' | ||
ext.DID_DOWNLOAD = new HashMap<String, Boolean>() | ||
|
||
tasks.register('fetchSchema') { | ||
doLast { | ||
getUris().forEach { | ||
downloadFile(it.toString()) | ||
} | ||
if (DID_DOWNLOAD.any { it.value == false }) { | ||
System.out.println("WARN: Some XSD files were cached from a previous run, to avoid this, run ./gradlew clean") | ||
} | ||
} | ||
} | ||
|
||
task fetchSchema() { | ||
def schemaVersion = '4.4' | ||
private List<String> getUris() { | ||
|
||
mkdir(schemaDir) | ||
def source = downloadFile(METADATA_XSD) | ||
|
||
def urlFile = "datacite.url" | ||
def xml = new groovy.xml.XmlSlurper().parseText(source.getText()) | ||
|
||
if (!file(schemaDir + urlFile).exists()) { | ||
Files.createFile(Paths.get(schemaDir + urlFile)) | ||
.text = "https://schema.datacite.org/meta/kernel-${schemaVersion}/metadata.xsd" | ||
return xml.'**'.findAll { | ||
it.name() == 'include' || it.name() == 'import' | ||
}.collect { | ||
it.@'schemaLocation' | ||
} | ||
} | ||
|
||
private File downloadFile(String path) { | ||
def uri = "https://schema.datacite.org/meta/kernel-${SCHEMA_VERSION}/${path}" | ||
def file = file(SCHEMA_DIR.toURI().toString() + '/' + path) | ||
|
||
if (!file.exists()) { | ||
def destination = path.contains("/") ? file.parentFile : SCHEMA_DIR | ||
destination.mkdirs() | ||
download.run { | ||
src uri | ||
dest destination | ||
} | ||
DID_DOWNLOAD.put(path, true) | ||
} else { | ||
DID_DOWNLOAD.put(path, false) | ||
} | ||
return file; | ||
} | ||
|
||
jar { | ||
from "$buildDir/classes/java/main" | ||
from "${layout.buildDirectory}/classes/java/main" | ||
} | ||
|
||
tasks.named('sourcesJar') { | ||
dependsOn('xjc') | ||
} | ||
|
||
System.setProperty('javax.xml.accessExternalSchema', 'all') | ||
|
||
xjc { | ||
srcDirName = schemaDir | ||
xsdDir.set(layout.projectDirectory.dir(SCHEMA_DIR.toURI().toString())) | ||
} | ||
|
||
tasks.named('xjc') { | ||
dependsOn('fetchSchema') | ||
} | ||
|
||
build.dependsOn("fetchSchema") | ||
tasks.named('compileJava') { | ||
dependsOn('xjc') | ||
} |
6 changes: 3 additions & 3 deletions
6
datacite-transform/src/main/java/no/unit/nva/transformer/Transformer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
datacite-transform/src/main/java/no/unit/nva/transformer/dto/DataCiteMetadataDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.2-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
jdk: | ||
- openjdk11 | ||
- openjdk21 | ||
install: | ||
- ./gradlew build | ||
- ./gradlew -Pgroup=com.github.BIBSYSDEV -Pversion=v0.5.8 -xtest assemble publishToMavenLocal | ||
- ./gradlew -Pgroup=com.github.BIBSYSDEV -Pversion=v0.5.9 -xtest assemble publishToMavenLocal |