From d45a12132c06d16a5efb8688e94a3b22e4d01052 Mon Sep 17 00:00:00 2001 From: Michael Hoffer Date: Wed, 27 Nov 2024 15:26:21 +0100 Subject: [PATCH] https://github.com/miho/VMF/issues/68 vmf-edit is part of 0.2.9.4 release. --- config/common.properties | 2 +- settings.gradle | 1 + vmfedit/build.gradle | 55 +++++- vmfedit/gradle/project-info.gradle | 23 +++ vmfedit/gradle/publishing.gradle | 173 ++++++++++++++++++ vmfedit/settings.gradle | 2 +- .../vmf/vmfedit/JsonEditorController.java | 20 +- 7 files changed, 260 insertions(+), 16 deletions(-) create mode 100644 vmfedit/gradle/project-info.gradle create mode 100644 vmfedit/gradle/publishing.gradle diff --git a/config/common.properties b/config/common.properties index fa27395..65b31d6 100644 --- a/config/common.properties +++ b/config/common.properties @@ -1,5 +1,5 @@ # version number (is used for core, runtime and default dependencies in plugin and plugin) # publication.version = 0.3-SNAPSHOT -publication.version=0.2.9.5-SNAPSHOT +publication.version=0.2.9.4 #publication.version=0.2.9.3 #publication.version=0.2.8.8 \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index bf801c5..12b29ac 100644 --- a/settings.gradle +++ b/settings.gradle @@ -4,3 +4,4 @@ include ':core', ':runtime', ':gradle-plugin' project(':core').name = 'vmf' project(':runtime').name = 'vmf-runtime' + diff --git a/vmfedit/build.gradle b/vmfedit/build.gradle index 82c40ad..f40acd2 100644 --- a/vmfedit/build.gradle +++ b/vmfedit/build.gradle @@ -1,12 +1,26 @@ +import java.text.SimpleDateFormat + + plugins { id 'application' id 'org.openjfx.javafxplugin' version '0.1.0' id 'org.beryx.jlink' version '2.25.0' id 'com.github.node-gradle.node' version '3.3.0' + + id 'com.github.hierynomus.license' version '0.16.1' + id 'maven-publish' + id 'net.nemerosa.versioning' version '3.0.0' + id 'com.github.ben-manes.versions' version '0.44.0' } -group 'eu.mihosoft.vmf' -version '1.0.0-SNAPSHOT' + +ext.commonProps = new Properties() +file(new File(projectDir.parentFile,"config/common.properties")).withInputStream { commonProps.load(it) } + +apply plugin: 'java-library' +apply from: 'gradle/publishing.gradle' + +version = "${project.commonProps.get('publication.version')}" // installer version (used for jlink/jpackge) // parse version with three '.' separated numbers from full version string @@ -27,8 +41,8 @@ ext { junitVersion = '5.8.2' } -sourceCompatibility = '23' -targetCompatibility = '23' +sourceCompatibility = '17' +targetCompatibility = '17' tasks.withType(JavaCompile) { options.encoding = 'UTF-8' @@ -120,4 +134,35 @@ copyFontAwesomeToResources.dependsOn installFontAwesome processResources.dependsOn copyFontAwesomeToResources copyBootStrapToResources.dependsOn installBootStrap -processResources.dependsOn copyBootStrapToResources \ No newline at end of file +processResources.dependsOn copyBootStrapToResources + +jar { + manifest { + attributes('Automatic-Module-Name': 'eu.mihosoft.vmf.vmfedit') + } + + // // add velocity legacy to jar file + // from { + // configurations.legacyVelocity.collect { it.isDirectory() ? it : zipTree(it) } + // } +} + +license { + header = rootProject.file('core/config/HEADER') + strictCheck = true + ignoreFailures = true + mapping { + java = 'SLASHSTAR_STYLE' + groovy = 'SLASHSTAR_STYLE' + fxml = 'XML_STYLE' + } + + ext.yearCurrent = new SimpleDateFormat("yyyy").format(new Date()) + ext.yearSince1 = '2017' + ext.author1 = 'Michael Hoffer ' + ext.yearSince2 = '2017' + ext.author2 = 'Goethe Center for Scientific Computing, University Frankfurt' + + exclude '**/*.svg' +} + diff --git a/vmfedit/gradle/project-info.gradle b/vmfedit/gradle/project-info.gradle new file mode 100644 index 0000000..b976dcd --- /dev/null +++ b/vmfedit/gradle/project-info.gradle @@ -0,0 +1,23 @@ +// ----------------------------------------------------------------------------- +// publishing information +// ----------------------------------------------------------------------------- +ext.publishingInfo.artifactId = project.name.toLowerCase() +ext.publishingInfo.groupId = 'eu.mihosoft.vmf' +ext.publishingInfo.versionId = ext.commonProps.get("publication.version") + +ext.publishingInfo.developerName = 'Michael Hoffer' +ext.publishingInfo.developerAlias = 'miho' +ext.publishingInfo.developerEmail = 'info@michaelhoffer.de' +ext.publishingInfo.inceptionYear = '2017' + +ext.publishingInfo.desc = 'VMF JSon Schema Editor Support (VRL Modeling Framework) adds editor support via json schema.' +ext.publishingInfo.license = 'Apache-2.0' +ext.publishingInfo.licenseUrl = 'https://github.com/miho/VMF/blob/master/LICENSE' +ext.publishingInfo.labels = ['vmf', 'modeling', 'data model', 'vrl', 'modeling framework'] +ext.publishingInfo.websiteUrl = 'https://github.com/miho/VMF' +ext.publishingInfo.issueTrackerUrl = 'https://github.com/miho/VMF/issues' +ext.publishingInfo.vcsUrl = 'https://github.com/miho/VMF.git' + +ext.publishingInfo.gitHubMavenRepo = "https://maven.pkg.github.com/miho/vmf" + +ext.publishingInfo.pomName = ext.publishingInfo.artifactId diff --git a/vmfedit/gradle/publishing.gradle b/vmfedit/gradle/publishing.gradle new file mode 100644 index 0000000..d7a9717 --- /dev/null +++ b/vmfedit/gradle/publishing.gradle @@ -0,0 +1,173 @@ +// ----------------------------------------------------------------------------- +// Collect publishing information +// ----------------------------------------------------------------------------- +ext.publishingInfo = [:] + +ext.publishingInfo.pomName = ext.publishingInfo.artifactId + +apply from: "gradle/project-info.gradle" +apply plugin: 'signing' + +// ----------------------------------------------------------------------------- +// Performs publishing +// ----------------------------------------------------------------------------- + +task javadocJar(type: Jar, dependsOn: javadoc) { + archiveClassifier = 'javadoc' + from javadoc.destinationDir +} + +// create one jar for the source files +task sourcesJar(type: Jar, dependsOn: classes) { + archiveClassifier = 'sources' + from sourceSets.main.allSource +} + +artifacts { + archives jar + archives javadocJar + archives sourcesJar +} + +Date buildTimeAndDate = new Date() +ext { + buildDate = new java.text.SimpleDateFormat('yyyy-MM-dd').format(buildTimeAndDate) + buildTime = new java.text.SimpleDateFormat('HH:mm:ss.SSSZ').format(buildTimeAndDate) +} + +jar { + manifest { + attributes( + 'Built-By': System.properties['user.name'], + 'Created-By': System.properties['java.version'] + " (" + System.properties['java.vendor'] + " " + System.properties['java.vm.version'] + ")", + 'Build-Date': project.buildDate, + 'Build-Time': project.buildTime, + 'Build-Revision': versioning.info.commit, + 'Specification-Title': project.name, + 'Specification-Version': project.version, + 'Implementation-Title': project.name, + 'Implementation-Version': project.version + ) + } +} + + +def pomConfig = { + name ext.publishingInfo.pomName + description ext.publishingInfo.desc + url ext.publishingInfo.websiteUrl + inceptionYear ext.publishingInfo.inceptionYear + licenses { + license([:]) { + name ext.publishingInfo.license + url ext.publishingInfo.licenseUrl + distribution 'repo' + } + } + scm { + url ext.publishingInfo.vcsUrl + connection ext.publishingInfo.vcsUrl + developerConnection ext.publishingInfo.vcsUrl + } + developers { + developer { + id ext.publishingInfo.developerNameAlias + name ext.publishingInfo.developerName + } + } +} + + + +publishing { + + repositories { + // -------------------------------------------------------------------------------- + // Destination Repository 'GitHubPackages' + // -> call task 'publishMavenJavaPublicationToGitHubPackagesRepository' to publish + // -------------------------------------------------------------------------------- + maven { + name = "GitHubPackages" + // see https://levelup.gitconnected.com/publish-a-maven-package-to-github-with-gradle-fabc6de24d6 + // Replace OWNER and REPOSITORY with your GitHub username/repository + // (must be both lowercase according to the documenations) + // url = uri("https://maven.pkg.github.com/OWNER/REPOSITORY") + url = uri(project.findProperty('publishingInfo').gitHubMavenRepo) + credentials { + // Make sure to generate a token with write-packages and read-packages permission: + // https://github.com/settings/tokens/new + // You can either store the username and token in + // ~/.gradle/gradle.properties (use the gpr.user and gpr.key keys) + // Or you can store them as environment variables e.g. in ~/.bash_profile or ~/.zsh + // depending on your shell (GITHUB_USERNAME and GITHUB_TOKEN keys) + // Or you pass them via CLI: gradle publish -Pgpr.user=username -Pgpr.key=token + // See at EOF for examples on how to store the credentials + username = project.findProperty("gpr.user") ?: System.getenv("GITHUB_USERNAME") + password = project.findProperty("gpr.key") ?: System.getenv("GITHUB_TOKEN") + } + } + + // -------------------------------------------------------------------------------- + // Destination Repository 'OSSRH' + // telling gradle to publish artifact to local directory + // -> call task 'publishMavenJavaPublicationToOSSRHRepository' to publish + // -> go to https://oss.sonatype.org/#stagingRepositories, click 'close', drink coffee and then click 'release' + // if closing was successful + // -------------------------------------------------------------------------------- + maven { + name = "OSSRH" + url "https://oss.sonatype.org/service/local/staging/deploy/maven2" + credentials { + username = project.findProperty("oss.user") ?: System.getenv("OSS_USERNAME") + password = project.findProperty("oss.pwd") ?: System.getenv("OSS_PWD") + } + } + + // -------------------------------------------------------------------------------- + // Destination Repository 'BuildDir' + // telling gradle to publish artifact to local directory + // -> call task 'publishMavenJavaPublicationToBuildDirRepository' to publish + // -------------------------------------------------------------------------------- + maven { + name = "BuildDir" + url "file:/${buildDir}/artifacts" + } + } + + + publications { + mavenJava(MavenPublication) { + groupId publishingInfo.groupId + artifactId publishingInfo.artifactId + version publishingInfo.versionId + from components.java + artifact sourcesJar + artifact javadocJar + + pom.withXml { + def root = asNode() + root.appendNode 'description', publishingInfo.desc + root.children().last() + pomConfig + } + } + } +} + + +if( + project.findProperty("signing.secretKeyRingFile") + && project.findProperty("signing.password") + && project.findProperty("signing.keyId") +) { + + signing { + sign publishing.publications + } + +} else { + println "> skipping signing, provide\n" + + " - 'signing.secretKeyRingFile'\n" + + " - 'signing.password'\n" + + " - 'signing.keyId'\n" + + " to activate it\n" +} diff --git a/vmfedit/settings.gradle b/vmfedit/settings.gradle index 02a28c4..5c5ddde 100644 --- a/vmfedit/settings.gradle +++ b/vmfedit/settings.gradle @@ -1 +1 @@ -rootProject.name = "vmfedit" \ No newline at end of file +rootProject.name = "vmf-edit" \ No newline at end of file diff --git a/vmfedit/src/main/java/eu/mihosoft/vmf/vmfedit/JsonEditorController.java b/vmfedit/src/main/java/eu/mihosoft/vmf/vmfedit/JsonEditorController.java index ede34c6..763c0e7 100644 --- a/vmfedit/src/main/java/eu/mihosoft/vmf/vmfedit/JsonEditorController.java +++ b/vmfedit/src/main/java/eu/mihosoft/vmf/vmfedit/JsonEditorController.java @@ -29,15 +29,14 @@ public class JsonEditorController { private final WebView webView; /** Property holding the current JSON schema */ - private final StringProperty schemaProperty = new SimpleStringProperty(""" - { - "$schema" : "http://json-schema.org/draft-07/schema#", - "title" : "value", - "type" : "string", - "readOnly": true, - "default": "set a schema" - } - """); + private final StringProperty schemaProperty = new SimpleStringProperty( + "{\n" + + " \"$schema\" : \"http://json-schema.org/draft-07/schema#\",\n" + + " \"title\" : \"value\",\n" + + " \"type\" : \"string\",\n" + + " \"readOnly\": true,\n" + + " \"default\": \"set a schema\"\n" + + "}"); /** Property holding the current JSON value */ private final StringProperty valueProperty = new SimpleStringProperty(""); @@ -341,6 +340,9 @@ private String escapeJavaScript(String str) { .replace("\t", "\\t"); } + /** + * Default error handler for the editor. + */ private BiConsumer onErrorConsumer = (title, message) -> { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("Error");