diff --git a/.github/workflows/loxone-java-check.yml b/.github/workflows/loxone-java-check.yml index af81b69..9cd986a 100644 --- a/.github/workflows/loxone-java-check.yml +++ b/.github/workflows/loxone-java-check.yml @@ -13,11 +13,11 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Set up JDK 11 + - name: Set up JDK 17 uses: actions/setup-java@v3 with: - java-version: '11' - distribution: 'adopt' + java-version: '17' + distribution: 'temurin' - name: Check with Gradle uses: gradle/gradle-build-action@v2 with: diff --git a/.github/workflows/loxone-java-release.yml b/.github/workflows/loxone-java-release.yml index a3168bf..08a8fb5 100644 --- a/.github/workflows/loxone-java-release.yml +++ b/.github/workflows/loxone-java-release.yml @@ -25,11 +25,11 @@ jobs: ref: master token: ${{ secrets.SMARTEON_GIT_TOKEN }} - - name: Setup JDK 11 + - name: Setup JDK 17 uses: actions/setup-java@v3 with: - java-version: '11' - distribution: 'adopt' + java-version: '17' + distribution: 'temurin' - name: Set up git configuration run: | @@ -50,9 +50,9 @@ jobs: - name: Publish to OSS Sonatype shell: bash env: - OSS_USER: ${{ secrets.OSS_USER }} - OSS_PASS: ${{ secrets.OSS_PASS }} - SIGNING_KEY: ${{ secrets.SIGNING_KEY }} - SIGNING_PASS: ${{ secrets.SIGNING_PASS }} + ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.OSS_USER }} + ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.OSS_PASS }} + ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_KEY }} + ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASS }} run: | - ./gradlew publishLibraryPublicationToProjectLocalRepository zipMavenCentralPortalPublication releaseMavenCentralPortalPublication + ./gradlew publishToMavenCentral diff --git a/build.gradle.kts b/build.gradle.kts index b29b26d..e371bc0 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,3 +1,7 @@ +import com.vanniktech.maven.publish.JavaLibrary +import com.vanniktech.maven.publish.JavadocJar +import org.jetbrains.kotlin.gradle.dsl.JvmTarget + group = "cz.smarteon" scmVersion { @@ -11,20 +15,20 @@ project.version = scmVersion.version plugins { `java-library` - signing - `maven-publish` jacoco id("pl.allegro.tech.build.axion-release") version "1.18.18" - id("org.danilopianini.publish-on-central") version "8.0.7" + id("com.vanniktech.maven.publish") version "0.34.0" id("ru.vyarus.quality") version "6.0.1" - kotlin("jvm") version "1.7.10" + kotlin("jvm") version "2.2.20" } java { + toolchain { + languageVersion.set(JavaLanguageVersion.of(17)) + } sourceCompatibility = JavaVersion.VERSION_11 targetCompatibility = JavaVersion.VERSION_11 - withJavadocJar() - withSourcesJar() + // javadoc and sources configured in publishing plugin } repositories { @@ -58,6 +62,7 @@ dependencies { testImplementation("org.junit.jupiter:junit-jupiter-api:$junitVersion") testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:$junitVersion") testImplementation("org.junit.jupiter:junit-jupiter-params:$junitVersion") + testRuntimeOnly("org.junit.platform:junit-platform-launcher") val striktVersion = "0.34.1" testImplementation("io.strikt:strikt-core:$striktVersion") @@ -88,88 +93,59 @@ dependencies { testImplementation("org.awaitility:awaitility-kotlin:4.1.1") } -val ossUser: String? = System.getenv("OSS_USER") -val ossPass: String? = System.getenv("OSS_PASS") - -publishing { - publications { - create("library") { - from(components["java"]) - - pom { - name.set(project.name) - url.set("https://github.com/Smarteon/loxone-java") - description.set("Java implementation of the Loxone™ communication protocol (Web Socket)") - organization { - name.set("Smarteon Systems s.r.o") - url.set("https://smarteon.cz") - } - licenses { - license { - name.set("3-Clause BSD License") - url.set("https://opensource.org/licenses/BSD-3-Clause") - distribution.set("repo") - } - } - developers { - developer { - name.set("Jiří Mikulášek") - email.set("jiri.mikulasek@smarteon.cz") - } - developer { - name.set("Vojtěch Zavřel") - email.set("vojtech.zavrel@smarteon.cz") - } - developer { - name.set("Tomáš Knotek") - email.set("tomas.knotek@smarteon.cz") - } - } - contributors { - contributor { - name.set("Petr Žufan") - } - } - scm { - url.set("git@github.com:Smarteon/loxone-java.git") - connection.set("scm:git:git@github.com:Smarteon/loxone-java.git") - tag.set(project.version.toString()) - } - } - } - } -} +// see https://vanniktech.github.io/gradle-maven-publish-plugin/central/#secrets for how to set up credentials and signing +mavenPublishing { + publishToMavenCentral(automaticRelease = true) + signAllPublications() -if (ossUser != null && ossPass != null) { - publishOnCentral { - repoOwner.set("Smarteon") - projectDescription.set("Java implementation of the Loxone™ communication protocol (Web Socket)") - licenseName.set("3-Clause BSD License") - licenseUrl.set("https://opensource.org/licenses/BSD-3-Clause") + configure( + JavaLibrary( + javadocJar = JavadocJar.Javadoc(), + sourcesJar = true, + ) + ) - repositories { - mavenCentral.user.set(ossUser) - mavenCentral.password.set(ossPass) - } - } -} + coordinates(project.group.toString(), project.name, project.version.toString()) -val signingKey: String? = System.getenv("SIGNING_KEY") -val signingPassword: String? = System.getenv("SIGNING_PASS") -if (signingKey != null && signingPassword != null) { - signing { - setRequired({ - !project.version.toString().endsWith("-SNAPSHOT") - }) - useInMemoryPgpKeys(signingKey, signingPassword) - sign(publishing.publications["library"]) - } -} else if (hasProperty("signing.keyId")) { - signing { - setRequired({ - !project.version.toString().endsWith("-SNAPSHOT") - }) - sign(publishing.publications["library"]) + pom { + name = project.name + url = "https://github.com/Smarteon/loxone-java" + description = "Java implementation of the Loxone™ communication protocol (Web Socket)" + organization { + name = "Smarteon Systems s.r.o" + url = "https://smarteon.cz" + } + licenses { + license { + name = "3-Clause BSD License" + url = "https://opensource.org/licenses/BSD-3-Clause" + distribution = "repo" + } + } + developers { + developer { + name = "Jiří Mikulášek" + email = "jiri.mikulasek@smarteon.cz" + } + developer { + name = "Vojtěch Zavřel" + email = "vojtech.zavrel@smarteon.cz" + } + developer { + name = "Tomáš Knotek" + email = "tomas.knotek@smarteon.cz" + } + } + contributors { + contributor { + name = "Petr Žufan" + } + } + scm { + url = "git@github.com:Smarteon/loxone-java.git" + connection = "scm:git:git@github.com:Smarteon/loxone-java.git" + tag = project.version.toString() + } } } @@ -195,8 +171,8 @@ tasks { } withType { - kotlinOptions { - jvmTarget = "11" + compilerOptions { + jvmTarget.set(JvmTarget.JVM_11) } } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 249e583..1b33c55 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 260504c..2e11132 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index a69d9cb..23d15a9 100755 --- a/gradlew +++ b/gradlew @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -80,13 +82,11 @@ do esac done -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" +# This is normally unused +# shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -114,7 +114,7 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar +CLASSPATH="\\\"\\\"" # Determine the Java command to use to start the JVM. @@ -133,22 +133,29 @@ location of your Java installation." fi else JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -193,16 +200,20 @@ if "$cygwin" || "$msys" ; then done fi -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/gradlew.bat b/gradlew.bat index 53a6b23..5eed7ee 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -26,6 +28,7 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @@ -42,11 +45,11 @@ set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 if %ERRORLEVEL% equ 0 goto execute -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -56,22 +59,22 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar +set CLASSPATH= @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* :end @rem End local scope for the variables with windows NT shell