From afc80d3567a013125edb5e29e909e83698553c6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20G=C3=BCrtler?= Date: Wed, 22 Feb 2023 18:14:34 +0100 Subject: [PATCH 01/15] switched to Groovy 4.x, Gradle 7.x and Java 17, updated dependencies --- Dockerfile | 6 ++++-- README.md | 4 ++-- Releases.md | 4 ++++ build.gradle | 35 ++++++++++++++++++++++------------- docker/README.md | 4 ++-- docker/image/Dockerfile | 3 ++- 6 files changed, 36 insertions(+), 20 deletions(-) diff --git a/Dockerfile b/Dockerfile index ee4bc57..eea153e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,13 @@ -FROM mcr.microsoft.com/java/jdk:11u3-zulu-alpine as build +# FROM mcr.microsoft.com/java/jdk:11u3-zulu-alpine as build +FROM azul/zulu-openjdk-alpine:17.0.4.1 as build +# "--module-path", "/usr/lib/jvm/zulu-11-azure-jdk_11.31.11-11.0.3-linux_musl_x64/jmods", \ RUN ["jlink", \ "--compress=2", \ "--strip-debug", \ "--no-header-files", \ "--no-man-pages", \ - "--module-path", "/usr/lib/jvm/zulu-11-azure-jdk_11.31.11-11.0.3-linux_musl_x64/jmods", \ + "--module-path", "/usr/lib/jvm/zulu17-ca/jmods", \ "--add-modules", "java.base,java.logging,java.desktop,java.naming,java.prefs,java.xml,java.scripting,java.sql", \ "--output", "/custom_jre"] diff --git a/README.md b/README.md index 8826ec6..709381d 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ A simple Groovy based program to do generation tasks from a JSON schema. ## Requirements -* Java 8 -* Gradle v5.4* +* Java 17 +* Gradle v7.* ## Unsupported JSON schema features * patternProperties - make no sense in model description diff --git a/Releases.md b/Releases.md index 439f9be..5c72def 100644 --- a/Releases.md +++ b/Releases.md @@ -1,3 +1,7 @@ +## 0.14.0 +- switched to Groovy 4.x, Gradle 7.x and Java 17 +- updated dependencies + ## 0.13.1 - handle the right notation of external references: e.g. ./object_base.json#/definitions/ObjectBase diff --git a/build.gradle b/build.gradle index 200f04e..e5899c7 100644 --- a/build.gradle +++ b/build.gradle @@ -1,15 +1,23 @@ +/* apply plugin: 'groovy' apply plugin: 'java' -apply plugin: 'maven' +// apply plugin: 'maven' apply plugin: 'java-library' apply plugin: 'maven-publish' - -sourceCompatibility = 8 + */ +plugins { + id 'groovy' + id 'java' + id 'maven-publish' + id 'java-library' +} +sourceCompatibility = 17 +targetCompatibility = 17 def mainClass='de.lisaplus.atlas.DoCodeGen' project.group = 'de.lisaplus.tools' -project.version = '0.13.2' +project.version = '0.14.0' task sourcesJar(type: Jar) { @@ -31,13 +39,13 @@ artifacts { } dependencies { - compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25' - compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3' - compile group: 'com.beust', name: 'jcommander', version: '1.69' - compile 'org.apache.commons:commons-lang3:3.3' - compile 'org.codehaus.groovy:groovy-all:2.5.7' - compile group: 'org.apache.xmlbeans', name: 'xmlbeans', version: '3.0.0' - testCompile group: 'junit', name: 'junit', version: '4.12' + implementation group: 'org.slf4j', name: 'slf4j-api', version: '1.7.36' + runtimeOnly group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.11' + implementation group: 'com.beust', name: 'jcommander', version: '1.82' + implementation 'org.apache.commons:commons-lang3:3.12.0' + implementation group: 'org.apache.groovy', name: 'groovy-all', version: '4.0.9' + implementation group: 'org.apache.xmlbeans', name: 'xmlbeans', version: '5.1.1' + testImplementation group: 'junit', name: 'junit', version: '4.13.2' } clean { @@ -46,7 +54,8 @@ clean { task dependenciesToLibDir(type: Copy) { into "$buildDir/release/lib" - from configurations.runtime + from sourceSets.main.runtimeClasspath + // from configurations.runtime } task buildRelease (type: Copy) { @@ -132,7 +141,7 @@ task buildDockerImage { def imageName=['bash','docker/bin/image_conf.sh'].execute().text.trim() println "create image: $imageName ..." def cmd = ['docker', 'build', '-t', imageName,'.'] - def sout = new StringBuilder(), serr = new StringBuilder() + def sout = new java.lang.StringBuilder(), serr = new java.lang.StringBuilder() def proc = cmd.execute() proc.consumeProcessOutput(sout, serr) proc.waitForOrKill(20000) diff --git a/docker/README.md b/docker/README.md index 6a84673..7838106 100644 --- a/docker/README.md +++ b/docker/README.md @@ -23,8 +23,8 @@ bin/run_jsonCodeGen.sh -m ../src/test/resources/schemas/vera.json \ ## How to create a docker image Requirements: -- installed Java v8 -- installed Gradle +- installed Java v17 +- installed Gradle v7.x ```bash # show all available Gradle tasks (only for information) gradle tasks --all diff --git a/docker/image/Dockerfile b/docker/image/Dockerfile index 9239302..6aa6e67 100644 --- a/docker/image/Dockerfile +++ b/docker/image/Dockerfile @@ -1,4 +1,5 @@ -FROM openjdk:8-jre-alpine +# FROM openjdk:8-jre-alpine +FROM azul/zulu-openjdk-alpine:17.0.4.1 ADD release /opt/jsonCodeGen From 7ee5642108c7ca336ecbd1fb18ba70d2ba0d1ec1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20G=C3=BCrtler?= Date: Wed, 22 Feb 2023 18:57:29 +0100 Subject: [PATCH 02/15] Fixed error PlantUmlGenerator missing property EMPTY. Make it clear that the lambda in TypeStringManipulation are to use the constant EMPTY of the class, not some property of the class making use of the lambda --- .../codegen/TypeStringManipulation.groovy | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/groovy/de/lisaplus/atlas/codegen/TypeStringManipulation.groovy b/src/main/groovy/de/lisaplus/atlas/codegen/TypeStringManipulation.groovy index 1c95549..9218d5d 100644 --- a/src/main/groovy/de/lisaplus/atlas/codegen/TypeStringManipulation.groovy +++ b/src/main/groovy/de/lisaplus/atlas/codegen/TypeStringManipulation.groovy @@ -116,7 +116,7 @@ class TypeStringManipulation { } def breakTxt = { String txtToBreak,int charPerLine,String breakText='\n' -> - if (!txtToBreak) return EMPTY + if (!txtToBreak) return TypeStringManipulation.EMPTY StringBuilder sb = new StringBuilder() int txtLen = txtToBreak.length() int aktPos = 0 @@ -155,15 +155,15 @@ class TypeStringManipulation { } def toLowerCase = { str -> - return str==null ? EMPTY : str.toLowerCase() + return str==null ? TypeStringManipulation.EMPTY : str.toLowerCase() } def toUpperCase = { str -> - return str==null ? EMPTY : str.toUpperCase() + return str==null ? TypeStringManipulation.EMPTY : str.toUpperCase() } def firstLowerCase = { str -> - if (!str) return EMPTY + if (!str) return TypeStringManipulation.EMPTY def first = str.substring(0,1) first = first.toLowerCase() if (str.length()>1) { @@ -176,7 +176,7 @@ class TypeStringManipulation { } def firstUpperCase = { str -> - if (!str) return EMPTY + if (!str) return TypeStringManipulation.EMPTY def first = str.substring(0,1) first = first.toUpperCase() if (str.length()>1) { @@ -189,19 +189,19 @@ class TypeStringManipulation { } def firstUpperCamelCase = { str -> - if (!str) return EMPTY + if (!str) return TypeStringManipulation.EMPTY def firstUpper = firstUpperCase(str) return convertAllUnderLinesToCamelCase(firstUpper) } def firstLowerCamelCase = { str -> - if (!str) return EMPTY + if (!str) return TypeStringManipulation.EMPTY def firstLower = firstLowerCase(str) return convertAllUnderLinesToCamelCase(firstLower) } def convertAllUnderLinesToCamelCase = { String str -> - if (!str) return EMPTY + if (!str) return TypeStringManipulation.EMPTY def i_ = str.indexOf('_') while (i_!=-1) { def stopLen = str.length()-1 @@ -285,5 +285,5 @@ class TypeStringManipulation { return Type.copyOf(type, [:]) } - private final static String EMPTY='' + private static final String EMPTY='' } From 568eee79b11f9b155b868be32bedb4d3eddeb6e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20G=C3=BCrtler?= Date: Wed, 22 Feb 2023 18:57:41 +0100 Subject: [PATCH 03/15] Remove unused imports --- .../de/lisaplus/atlas/builder/test/xsd/SimpleXsdBuilder.groovy | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/test/groovy/de/lisaplus/atlas/de/lisaplus/atlas/builder/test/xsd/SimpleXsdBuilder.groovy b/src/test/groovy/de/lisaplus/atlas/de/lisaplus/atlas/builder/test/xsd/SimpleXsdBuilder.groovy index 1bd7cdb..8533407 100644 --- a/src/test/groovy/de/lisaplus/atlas/de/lisaplus/atlas/builder/test/xsd/SimpleXsdBuilder.groovy +++ b/src/test/groovy/de/lisaplus/atlas/de/lisaplus/atlas/builder/test/xsd/SimpleXsdBuilder.groovy @@ -3,8 +3,6 @@ package de.lisaplus.atlas.de.lisaplus.atlas.builder.test.xsd import de.lisaplus.atlas.builder.XSDBuilder import org.junit.Test -import static junit.framework.Assert.assertTrue -import static org.junit.Assert.assertEquals import static org.junit.Assert.assertNotNull import static org.junit.Assert.assertTrue From 1a0b53b2c2b555fadf6c65b8c6555b66b4ccd780 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20G=C3=BCrtler?= Date: Wed, 22 Feb 2023 19:26:27 +0100 Subject: [PATCH 04/15] Avoid using deprecated elements --- build.gradle | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index e5899c7..5d445da 100644 --- a/build.gradle +++ b/build.gradle @@ -14,19 +14,19 @@ plugins { sourceCompatibility = 17 targetCompatibility = 17 -def mainClass='de.lisaplus.atlas.DoCodeGen' +def mc='de.lisaplus.atlas.DoCodeGen' project.group = 'de.lisaplus.tools' project.version = '0.14.0' task sourcesJar(type: Jar) { - classifier = 'sources' + archiveClassifier = 'sources' from sourceSets.main.allJava } task javadocJar(type: Jar) { - classifier = 'javadoc' + archiveClassifier = 'javadoc' from javadoc.destinationDir } @@ -97,7 +97,7 @@ task myRun (type: JavaExec, dependsOn: classes){ jvmArgs '-Xdebug', '-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=9009' } - main = mainClass + mainClass = mc classpath = sourceSets.main.runtimeClasspath } From b4e668eb1298ff7d0d622fcc9d94075c56e66099 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20G=C3=BCrtler?= Date: Wed, 22 Feb 2023 19:27:17 +0100 Subject: [PATCH 05/15] Updated name of task used for building docker image --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 709381d..4454b59 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ A simple Groovy based program to do generation tasks from a JSON schema. gradle buildRelease # builds release and copy artifacts to docker image dir as preparation for the image build -gradle copyReleaseToDockerImage +gradle buildDockerImage # run program without any arguments from project gradle myRun From cf08d652526aa230600d0a9ae7e1c06148385e3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20G=C3=BCrtler?= Date: Wed, 22 Feb 2023 20:07:07 +0100 Subject: [PATCH 06/15] Fixed building trimmed down JRE in alpine container image replace '--strip-debug' with '--strip-java-debug-attributes' or install package binutils Avoids error 'Cannot run program "objcopy": error=2, No such file or directory' --- Dockerfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index eea153e..47acba9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,8 @@ -# FROM mcr.microsoft.com/java/jdk:11u3-zulu-alpine as build FROM azul/zulu-openjdk-alpine:17.0.4.1 as build -# "--module-path", "/usr/lib/jvm/zulu-11-azure-jdk_11.31.11-11.0.3-linux_musl_x64/jmods", \ +# replace '--strip-debug' with '--strip-java-debug-attributes' or install package binutils +# Avoid error 'Cannot run program "objcopy": error=2, No such file or directory'! +RUN apk add --no-cache binutils RUN ["jlink", \ "--compress=2", \ "--strip-debug", \ From 0f6cb0a8358079970c094d45c36d16fbf16576f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20G=C3=BCrtler?= Date: Wed, 22 Feb 2023 20:24:30 +0100 Subject: [PATCH 07/15] Made looking up the version independent from the working directory Ensures that docker/bin/build.sh can be called from within folder docker --- docker/bin/image_conf.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docker/bin/image_conf.sh b/docker/bin/image_conf.sh index 2d7c3ba..519001f 100755 --- a/docker/bin/image_conf.sh +++ b/docker/bin/image_conf.sh @@ -1,8 +1,10 @@ +scriptPos=${0%/*} + imageBase=schlothauer/jsoncodegen imageTag=0.11.3 -if [ -f build.gradle ]; then - imageTag=`cat build.gradle | grep project.version | awk '{ print $3 }' | sed -e "s-'--g"` +if [ -f $scriptPos/../../build.gradle ]; then + imageTag=$(cat $scriptPos/../../build.gradle | grep project.version | awk '{ print $3 }' | sed -e "s-'--g") fi imageName="$imageBase:$imageTag" From 4f1c662ffe887eaabb7129b8e977953f62453de9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20G=C3=BCrtler?= Date: Wed, 22 Feb 2023 20:31:41 +0100 Subject: [PATCH 08/15] Updated usage in README Copied in the parameters understood by current DoCodeGen (auto-generated from the attributes with annotation @Parameter) --- README.md | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4454b59..d0c7770 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,9 @@ Usage: de.lisaplus.atlas.DoCodeGen [options] -b, --black-list black listed type, multiple usage possible Default: [] + -cet, --create-enum-types + if set the model is built with enum types + Default: false -g, --generator generator that are used with the model. This parameter can be used multiple times @@ -96,19 +99,22 @@ Usage: de.lisaplus.atlas.DoCodeGen [options] -gp, --generator-parameter special parameter that are passed to template via maps Default: [] + -gs, --generator-scripts + additional script that should be passed to the used templates -h, --help + -mta, --main-types-attrib + specify a needed attribute to be a maintype, used in addition to the + schema location * -m, --model Path to JSON schema to parse + Default: [] -o, --outputBase Base directory for the output -pmt, --print-main-types don't do any code generation, simply loads the model and print the main-types of it Default: false - -pmta, --print-main-types-attrib - don't do any code generation, simply loads the model and print the - main-types of it -pmti, --print-main-types-info print with info header Default: false @@ -120,6 +126,15 @@ Usage: de.lisaplus.atlas.DoCodeGen [options] -rta, --remove-tag-all remove a tag from all model types, f.e. -rta rest Default: [] + -rta2, --remove-tag-all-if-not-main + remove a tag from all model types that are no main types, f.e. -rta rest + Default: [] + -rta2a, --remove-tag-all-if-not-main-attrib + don't do any code generation, simply loads the model and print the + main-types of it + -tmt, --tag-main-types + if this flag is set all maintypes will be extended with a 'mainType' tag + Default: false -w, --white-list white listed type, multiple usage possible Default: [] From f5b39ff895fe3c45a11349bc7c7bdca105d60e31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20G=C3=BCrtler?= Date: Wed, 22 Feb 2023 20:37:12 +0100 Subject: [PATCH 09/15] Fixed example gradle calls for taks myRun --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d0c7770..b390282 100644 --- a/README.md +++ b/README.md @@ -69,12 +69,12 @@ gradle myRun -PmyArgs="-m,src/test/resources/schemas/ProcessDataEvent.json" # complex example for debug mode run gradle myRun -PDEBUG -PmyArgs="-o,/tmp/test_beans,-m,src/test/resources/test_schemas/multiType.json,\ --g,multifiles=src/main/resources/templates/java/java_bean.txt,\ +-g,multifiles=src/main/resources/templates/java/bean.txt,\ -gp,destFileNameExt=java,-gp,packageName=de.sw.atlas.test" # complex example without debug mode run gradle myRun -PmyArgs="-o,/tmp/test_beans,-m,src/test/resources/test_schemas/multiType.json,\ --g,multifiles=src/main/resources/templates/java/java_bean.txt,\ +-g,multifiles=src/main/resources/templates/java/bean.txt,\ -gp,destFileNameExt=java,-gp,packageName=de.sw.atlas.test" ``` ### Usage of the release From b6fdccda16f6835a11300b1129d6da8b8daa82de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20G=C3=BCrtler?= Date: Wed, 22 Feb 2023 21:42:01 +0100 Subject: [PATCH 10/15] Run the swagger example via gradle task myRun, too --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index b390282..351c271 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,10 @@ gradle myRun -PDEBUG -PmyArgs="-o,/tmp/test_beans,-m,src/test/resources/test_sch gradle myRun -PmyArgs="-o,/tmp/test_beans,-m,src/test/resources/test_schemas/multiType.json,\ -g,multifiles=src/main/resources/templates/java/bean.txt,\ -gp,destFileNameExt=java,-gp,packageName=de.sw.atlas.test" + +# swagger example +gradle myRun -PmyArgs="-o,/tmp/swagger,-m,src/test/resources/test_schemas/ds/user.json\ +,-g,swagger,-gp,removeEmptyLines=true,-gp,host=api.lisaplus.de" ``` ### Usage of the release From 773fb925cdd403310b77b146b31e761411dcbb8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20G=C3=BCrtler?= Date: Wed, 22 Feb 2023 21:49:07 +0100 Subject: [PATCH 11/15] Fight script failing silently - Enable log level warn for console - Extra quoting each parameter breaks looking up the model and template files! --- src/main/resources/bin/jsonCodeGen.groovy | 4 ++-- src/main/resources/bin/jsonCodeGen.sh | 2 +- src/main/resources/bin/jsonCodeGenDebug.sh | 2 +- src/main/resources/conf/logback.xml | 4 ++++ 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/resources/bin/jsonCodeGen.groovy b/src/main/resources/bin/jsonCodeGen.groovy index 9aa2ea4..1181e36 100644 --- a/src/main/resources/bin/jsonCodeGen.groovy +++ b/src/main/resources/bin/jsonCodeGen.groovy @@ -1,8 +1,8 @@ /** * This is a platform independent start script for jsonCodeGen * Requirements: - * Java 8 - * Groovy > 2.4.7 + * Java 17 + * Groovy >= 4.0.0 * Created by eiko on 13.07.17. */ diff --git a/src/main/resources/bin/jsonCodeGen.sh b/src/main/resources/bin/jsonCodeGen.sh index 5ae39ad..327390d 100755 --- a/src/main/resources/bin/jsonCodeGen.sh +++ b/src/main/resources/bin/jsonCodeGen.sh @@ -38,7 +38,7 @@ esac args= for arg in "$@"; do - args="$args \"$arg\"" + args="$args $arg" done if [ -d $scriptPos/lib ]; then diff --git a/src/main/resources/bin/jsonCodeGenDebug.sh b/src/main/resources/bin/jsonCodeGenDebug.sh index d2af8f0..24e0ba6 100755 --- a/src/main/resources/bin/jsonCodeGenDebug.sh +++ b/src/main/resources/bin/jsonCodeGenDebug.sh @@ -38,7 +38,7 @@ esac args= for arg in "$@"; do - args="$args \"$arg\"" + args="$args $arg" done if [ -d $scriptPos/lib ]; then diff --git a/src/main/resources/conf/logback.xml b/src/main/resources/conf/logback.xml index d071390..b4a8797 100644 --- a/src/main/resources/conf/logback.xml +++ b/src/main/resources/conf/logback.xml @@ -23,4 +23,8 @@ + + + + \ No newline at end of file From b8e249a4446625ab2b2d098d8a38c96e6633ad9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20G=C3=BCrtler?= Date: Thu, 23 Feb 2023 10:25:06 +0100 Subject: [PATCH 12/15] task zipRelease --- build.gradle | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/build.gradle b/build.gradle index 5d445da..b224654 100644 --- a/build.gradle +++ b/build.gradle @@ -79,14 +79,12 @@ task buildRelease (type: Copy) { } task zipRelease (type: Zip) { - doLast { - println 'zipRelease' - from "${buildDir}/release" - include '*' - include '*/*' - archiveName "$releaseArchiveName" - destinationDir(file("${buildDir}")) - } + // creates build/jsonCodeGen-[version].zip + println 'zipRelease' + from layout.buildDirectory.dir("release") + include '*' + include '*/*' + destinationDirectory = layout.buildDirectory.dir("${buildDir}") } task myRun (type: JavaExec, dependsOn: classes){ From 6da6095e55e34f47aebf8a1ca22632f43b0c5829 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20G=C3=BCrtler?= Date: Thu, 23 Feb 2023 11:57:58 +0100 Subject: [PATCH 13/15] Updated bin/uploadReleaseToNexus.sh, mention release process in the README.md --- README.md | 10 ++++++++++ bin/uploadReleaseToNexus.sh | 33 +++++++++++++++++++++++++-------- 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 351c271..f6864aa 100644 --- a/README.md +++ b/README.md @@ -214,3 +214,13 @@ def generatorScriptDefinedFunction(def someString) { 7. Break-Point should be triggered in IDE This approach can also be used for other projects. + +## Do NEXUS release +For uploading a binary release / release archive of jsonCodeGen to a NEXUS instance use corresponding release script [uploadReleaseToNexus.sh](bin/uploadReleaseToNexus.sh). +It needs some environment variables to work properly: + +* nexus_raw_archive: URL to the directory, where the binary release is to be POSTed +* nexus_user: Username use to authenticate at the NEXUS instance +* nexus_password: Password used to authenticate at the NEXUS instance (optional) + +If no password is available, then curl will prompt for one! diff --git a/bin/uploadReleaseToNexus.sh b/bin/uploadReleaseToNexus.sh index f94f979..932466e 100755 --- a/bin/uploadReleaseToNexus.sh +++ b/bin/uploadReleaseToNexus.sh @@ -2,6 +2,13 @@ scriptPos=${0%/*} +# Uploads a binary release / release archive of jsonCodeGen to a NEXUS instance +# This script relies on these environment variabels: +# * nexus_user: Username use to authenticate at the NEXUS instance +# * nexus_password: Password used to authenticate at the NEXUS instance (optional) +# * nexus_raw_archive: URL to the directory, where the binary release is to be POSTed +# If no password is available, then curl will prompt for one! + # retrieve the version from project file version=`cat "$scriptPos/../build.gradle" | grep project.version | grep = | sed -e "s-.* '--" -e "s-'--"` echo "version: $version" @@ -13,13 +20,13 @@ if ! gradle publish; then fi popd > /dev/null -if [ -z "$NEXUS_USER" ]; then - echo "NEXUS_USER not defined" +if [ -z "$nexus_user" ]; then + echo "nexus_user not defined" exit 1 fi -if [ -z "$NEXUS_RAW_ARCHIVE" ]; then - echo "NEXUS_RAW_ARCHIVE not defined" +if [ -z "$nexus_raw_archive" ]; then + echo "nexus_raw_archive not defined" exit 1 fi @@ -34,8 +41,7 @@ if ! gradle buildRelease; then exit 1 fi -cd build/release - +pushd "build/release" > /dev/null releaseFile="jsonCodeGen_$version.tgz" @@ -45,13 +51,24 @@ fi tar -czf "$releaseFile" * -if ! curl -v --user "$NEXUS_USER" --upload-file "$releaseFile" \ - "$NEXUS_RAW_ARCHIVE/$releaseFile" +# use password if availagle +if [ -z "$nexus_password" ]; then + user="$nexus_user" +else + echo "Making us of env. variable nexus_password!" + user="$nexus_user:$nexus_password" +fi + +if ! curl -v --user $user --upload-file "$releaseFile" \ + "$nexus_raw_archive/$releaseFile" then echo "error while upload release to nexus raw repo" fi git tag "$version" +echo "tagged version $version, please push it using command git push origin refs/tags/$version" + popd > /dev/null +popd > /dev/null From beb9a1f915c0fea2e0c7e6c09fbfe2afbb31571b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20G=C3=BCrtler?= Date: Thu, 23 Feb 2023 12:00:48 +0100 Subject: [PATCH 14/15] Log problem with start parameters! --- src/main/groovy/de/lisaplus/atlas/DoCodeGen.groovy | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/groovy/de/lisaplus/atlas/DoCodeGen.groovy b/src/main/groovy/de/lisaplus/atlas/DoCodeGen.groovy index d03fabe..5ed92ee 100644 --- a/src/main/groovy/de/lisaplus/atlas/DoCodeGen.groovy +++ b/src/main/groovy/de/lisaplus/atlas/DoCodeGen.groovy @@ -163,6 +163,7 @@ class DoCodeGen { doCodeGen.run() } catch(ParameterException e) { + log.error("Encountered a problem while parsing the start parameters: {}", e) e.usage() } } From 0e2f1286e21961fcac09440a29762330a6c90a31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20G=C3=BCrtler?= Date: Thu, 23 Feb 2023 12:08:38 +0100 Subject: [PATCH 15/15] Back to commonly used environment variables. --- README.md | 6 +++--- bin/uploadReleaseToNexus.sh | 24 ++++++++++++------------ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index f6864aa..f037fc2 100644 --- a/README.md +++ b/README.md @@ -219,8 +219,8 @@ This approach can also be used for other projects. For uploading a binary release / release archive of jsonCodeGen to a NEXUS instance use corresponding release script [uploadReleaseToNexus.sh](bin/uploadReleaseToNexus.sh). It needs some environment variables to work properly: -* nexus_raw_archive: URL to the directory, where the binary release is to be POSTed -* nexus_user: Username use to authenticate at the NEXUS instance -* nexus_password: Password used to authenticate at the NEXUS instance (optional) +* NEXUS_RAW_ARCHIVE: URL to the directory, where the binary release is to be POSTed +* NEXUS_USER: Username use to authenticate at the NEXUS instance +* NEXUS_PWD: Password used to authenticate at the NEXUS instance (optional) If no password is available, then curl will prompt for one! diff --git a/bin/uploadReleaseToNexus.sh b/bin/uploadReleaseToNexus.sh index 932466e..780ced1 100755 --- a/bin/uploadReleaseToNexus.sh +++ b/bin/uploadReleaseToNexus.sh @@ -4,9 +4,9 @@ scriptPos=${0%/*} # Uploads a binary release / release archive of jsonCodeGen to a NEXUS instance # This script relies on these environment variabels: -# * nexus_user: Username use to authenticate at the NEXUS instance -# * nexus_password: Password used to authenticate at the NEXUS instance (optional) -# * nexus_raw_archive: URL to the directory, where the binary release is to be POSTed +# * NEXUS_USER: Username use to authenticate at the NEXUS instance +# * NEXUS_PWD: Password used to authenticate at the NEXUS instance (optional) +# * NEXUS_RAW_ARCHIVE: URL to the directory, where the binary release is to be POSTed # If no password is available, then curl will prompt for one! # retrieve the version from project file @@ -20,13 +20,13 @@ if ! gradle publish; then fi popd > /dev/null -if [ -z "$nexus_user" ]; then - echo "nexus_user not defined" +if [ -z "$NEXUS_USER" ]; then + echo "NEXUS_USER not defined" exit 1 fi -if [ -z "$nexus_raw_archive" ]; then - echo "nexus_raw_archive not defined" +if [ -z "$NEXUS_RAW_ARCHIVE" ]; then + echo "NEXUS_RAW_ARCHIVE not defined" exit 1 fi @@ -52,15 +52,15 @@ fi tar -czf "$releaseFile" * # use password if availagle -if [ -z "$nexus_password" ]; then - user="$nexus_user" +if [ -z "$NEXUS_PWD" ]; then + user="$NEXUS_USER" else - echo "Making us of env. variable nexus_password!" - user="$nexus_user:$nexus_password" + echo "Making us of env. variable NEXUS_PWD!" + user="$NEXUS_USER:$NEXUS_PWD" fi if ! curl -v --user $user --upload-file "$releaseFile" \ - "$nexus_raw_archive/$releaseFile" + "$NEXUS_RAW_ARCHIVE/$releaseFile" then echo "error while upload release to nexus raw repo" fi