From 7c37e834ce6a6383bf3eb5b701e53c119f60bbba Mon Sep 17 00:00:00 2001 From: Martin Hauner Date: Tue, 12 Apr 2022 23:05:08 +0200 Subject: [PATCH 01/21] update plugin --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index d8ead21..1e661ce 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,7 +3,7 @@ plugins { id("java-library") id("maven-publish") id("signing") - id("com.github.ben-manes.versions") version ("0.41.0") + id("com.github.ben-manes.versions") version ("0.42.0") id("io.github.gradle-nexus.publish-plugin") version ("1.1.0") } From e0fa71cf5ae150e275b587211700a72907903711 Mon Sep 17 00:00:00 2001 From: Martin Hauner Date: Sun, 8 May 2022 15:40:50 +0200 Subject: [PATCH 02/21] update dependencies --- build.gradle.kts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 1e661ce..b3db10d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -70,8 +70,8 @@ repositories { dependencies { compileOnly("io.openapiprocessor:openapi-processor-api:2021.1") - implementation(platform("com.fasterxml.jackson:jackson-bom:2.13.1")) - implementation(platform("org.codehaus.groovy:groovy-bom:3.0.9")) + implementation(platform("com.fasterxml.jackson:jackson-bom:2.13.2.1")) + implementation(platform("org.codehaus.groovy:groovy-bom:3.0.10")) implementation("org.codehaus.groovy:groovy") implementation("org.codehaus.groovy:groovy-nio") From 30ebbf6330b4c3377930f8eca69d7c6d81fbfee4 Mon Sep 17 00:00:00 2001 From: Martin Hauner Date: Sun, 8 May 2022 15:41:18 +0200 Subject: [PATCH 03/21] latest gradle --- gradle/wrapper/gradle-wrapper.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a0f7639..92f06b5 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists From e1e288bfa73122e6dd81ff1082728e9b219ff37c Mon Sep 17 00:00:00 2001 From: Martin Hauner Date: Sun, 8 May 2022 15:41:36 +0200 Subject: [PATCH 04/21] next snapshot --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 3f91cce..21d1378 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -projectVersion=2022.2p-SNAPSHOT +projectVersion=2022.2-SNAPSHOT projectGroupId=io.openapiprocessor projectUrl=https://openapiprocessor.io From 34b2c6b10fcff8fabe7802bc833b619b56be98bf Mon Sep 17 00:00:00 2001 From: Martin Hauner Date: Sun, 8 May 2022 15:50:10 +0200 Subject: [PATCH 05/21] use explicit toolchain --- build.gradle.kts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index b3db10d..8a12dc6 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -14,8 +14,12 @@ group = projectGroupId version = projectVersion java { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 +// sourceCompatibility = JavaVersion.VERSION_1_8 +// targetCompatibility = JavaVersion.VERSION_1_8 + + toolchain { + languageVersion.set(JavaLanguageVersion.of(11)) + } } fun getBuildProperty(property: String): String { From 5d22a5aa8e34a698db7ef2d4a3551fdab7b8db6f Mon Sep 17 00:00:00 2001 From: Martin Hauner Date: Mon, 9 May 2022 08:27:01 +0200 Subject: [PATCH 06/21] clean up --- build.gradle.kts | 3 --- 1 file changed, 3 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 8a12dc6..d071a87 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -14,9 +14,6 @@ group = projectGroupId version = projectVersion java { -// sourceCompatibility = JavaVersion.VERSION_1_8 -// targetCompatibility = JavaVersion.VERSION_1_8 - toolchain { languageVersion.set(JavaLanguageVersion.of(11)) } From a57cbadbbe0a231bfe4771b7b4b1ece7c78e567f Mon Sep 17 00:00:00 2001 From: Martin Hauner Date: Sun, 22 May 2022 09:21:35 +0200 Subject: [PATCH 07/21] update dependency --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index d071a87..2610223 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -71,7 +71,7 @@ repositories { dependencies { compileOnly("io.openapiprocessor:openapi-processor-api:2021.1") - implementation(platform("com.fasterxml.jackson:jackson-bom:2.13.2.1")) + implementation(platform("com.fasterxml.jackson:jackson-bom:2.13.3")) implementation(platform("org.codehaus.groovy:groovy-bom:3.0.10")) implementation("org.codehaus.groovy:groovy") From 2ef25ac9ef6a363372c105be7d5b4fd1c5ffdb45 Mon Sep 17 00:00:00 2001 From: Martin Hauner Date: Thu, 26 May 2022 19:28:25 +0200 Subject: [PATCH 08/21] next snapshot --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 21d1378..e78f4ec 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -projectVersion=2022.2-SNAPSHOT +projectVersion=2022.3-SNAPSHOT projectGroupId=io.openapiprocessor projectUrl=https://openapiprocessor.io From ba926ad49aa91849c969f405d9ead105a332db0a Mon Sep 17 00:00:00 2001 From: Martin Hauner Date: Sat, 3 Sep 2022 18:43:12 +0200 Subject: [PATCH 09/21] ignore generated files --- .../openapiprocessor/test/FileSupport.groovy | 63 +++++++++++++++++-- .../io/openapiprocessor/test/TestItems.groovy | 3 +- .../test/TestSetRunner.groovy | 23 +++++-- 3 files changed, 75 insertions(+), 14 deletions(-) diff --git a/src/main/groovy/io/openapiprocessor/test/FileSupport.groovy b/src/main/groovy/io/openapiprocessor/test/FileSupport.groovy index 414193d..7ad868c 100644 --- a/src/main/groovy/io/openapiprocessor/test/FileSupport.groovy +++ b/src/main/groovy/io/openapiprocessor/test/FileSupport.groovy @@ -110,13 +110,18 @@ class FileSupport { * collect output paths, relative to packageName */ List collectRelativeOutputPaths (String path, String packageName) { - collectRelativeResourcePaths (path, generated).collect { - it.substring (packageName.size () + 1) + def testItems = readTestItems (path, generated) + + def items = [] + testItems.items.forEach { + items.add (it.substring (packageName.size () + 1)) } + + items } /** - * collect absolute paths from output.yaml in resources + * collect absolute paths from items listed in the test items yaml file */ List collectAbsoluteResourcePaths (String path, String itemsYaml) { collectRelativeResourcePaths (path, itemsYaml).collect { @@ -125,17 +130,63 @@ class FileSupport { } /** - * collect paths from output.yaml in resources + * collect paths from test items yaml file (input.yaml/generated.yaml) */ List collectRelativeResourcePaths (String path, String itemsYaml) { + def testItems = readTestItems (path, itemsYaml) + testItems.items + } + + /** + * get the generated files. + * + * @param path path of the generated files + * @return the generated files + */ + static List getGeneratedFiles (Path path) { + collectPaths (path) + .sort () + } + + /** + * read expected files and strip package name. + * + * @param path the resource path of the test + * @param packageName stripped package name + * @return the expected files + */ + TestItems getExpectedFiles (String path, String packageName) { + def items = readTestItems (path, generated) + + def wanted = items.items.collect { + it.substring (packageName.size () + 1) + } + + def ignore = items.ignore.collect { + it.substring (packageName.size () + 1) + } + + def expected = new TestItems () + expected.items = wanted.sort () + expected.ignore = ignore.sort () + expected + } + + /** + * read test items yaml + * + * @param resource path + * @param name of test items yaml file + * @return content of yaml + */ + TestItems readTestItems (String path, String itemsYaml) { def source = getResource ("${path}/${itemsYaml}") if (!source) { println "ERROR: missing '${path}/${itemsYaml}' configuration file!" } def mapper = createYamlParser () - def sourceItems = mapper.readValue (source.text, TestItems) - sourceItems.items + mapper.readValue (source.text, TestItems) } /** diff --git a/src/main/groovy/io/openapiprocessor/test/TestItems.groovy b/src/main/groovy/io/openapiprocessor/test/TestItems.groovy index 2bff262..92f90dd 100644 --- a/src/main/groovy/io/openapiprocessor/test/TestItems.groovy +++ b/src/main/groovy/io/openapiprocessor/test/TestItems.groovy @@ -20,7 +20,6 @@ package io.openapiprocessor.test * input.yaml / generated.yaml mapping. */ class TestItems { - List items - + List ignore } diff --git a/src/main/groovy/io/openapiprocessor/test/TestSetRunner.groovy b/src/main/groovy/io/openapiprocessor/test/TestSetRunner.groovy index a02d374..7cac338 100644 --- a/src/main/groovy/io/openapiprocessor/test/TestSetRunner.groovy +++ b/src/main/groovy/io/openapiprocessor/test/TestSetRunner.groovy @@ -54,13 +54,16 @@ class TestSetRunner { def expectedPath = "${sourcePath}/${packageName}" def generatedPath = Path.of (folder.absolutePath).resolve (packageName) - def expectedFiles = files.collectRelativeOutputPaths (sourcePath, packageName).sort () - def generatedFiles = files.collectPaths (generatedPath).sort () + def expectedFiles = files.getExpectedFiles (sourcePath, packageName) + def generatedFiles = files.getGeneratedFiles (generatedPath) - assert expectedFiles == generatedFiles + // should generate expected files including the ignored files + def allExpectedFiles = (expectedFiles.items + expectedFiles.ignore).sort () + assert allExpectedFiles == generatedFiles + // compare expected files with the generated files, skip the ignored files def success = true - expectedFiles.each { + expectedFiles.items.each { def expected = "${expectedPath}/$it" def generated = generatedPath.resolve (it) @@ -110,9 +113,17 @@ class TestSetRunner { processor.run (options) then: + def expectedFilesYml = files.getExpectedFiles (path, packageName) + def generatedFiles = files.getGeneratedFiles (generatedPath) + + // should generate expected files including the ignored files + def allExpectedFiles = (expectedFilesYml.items + expectedFilesYml.ignore).sort () + assert allExpectedFiles == generatedFiles + + // compare expected files (on the custom files system) with the generated files, skip the + // ignored files def expectedFiles = files.collectPaths (expectedPath) - def generatedFiles = files.collectPaths (generatedPath) - assert expectedFiles == generatedFiles + expectedFiles.removeAll (expectedFilesYml.ignore) def success = true expectedFiles.each { From f4127b69159db689d85576b6e10f7b5ec6a7f762 Mon Sep 17 00:00:00 2001 From: Martin Hauner Date: Sun, 4 Sep 2022 11:27:20 +0200 Subject: [PATCH 10/21] diff only expected files --- .../openapiprocessor/test/FileSupport.groovy | 28 ++++++++++++++++--- .../io/openapiprocessor/test/TestItems.groovy | 16 ++--------- .../test/TestSetRunner.groovy | 23 ++++++--------- 3 files changed, 35 insertions(+), 32 deletions(-) diff --git a/src/main/groovy/io/openapiprocessor/test/FileSupport.groovy b/src/main/groovy/io/openapiprocessor/test/FileSupport.groovy index 7ad868c..ee43786 100644 --- a/src/main/groovy/io/openapiprocessor/test/FileSupport.groovy +++ b/src/main/groovy/io/openapiprocessor/test/FileSupport.groovy @@ -143,18 +143,37 @@ class FileSupport { * @param path path of the generated files * @return the generated files */ - static List getGeneratedFiles (Path path) { - collectPaths (path) - .sort () + static SortedSet getGeneratedFiles (Path path) { + def result = new TreeSet () + result.addAll (collectPaths (path)) + result } /** - * read expected files and strip package name. + *get the expected files (from generated.yaml) and strip package name. * * @param path the resource path of the test * @param packageName stripped package name * @return the expected files */ + SortedSet getExpectedFiles (String path, String packageName) { + def items = readTestItems (path, generated) + + def wanted = items.items.collect { + it.substring (packageName.size () + 1) + } + + def result = new TreeSet () + result.addAll (wanted) + result + } + + /** + * read expected files and strip package name. + * + * @param path the resource path of the test + * @param packageName stripped package name + * @return the expected files TestItems getExpectedFiles (String path, String packageName) { def items = readTestItems (path, generated) @@ -171,6 +190,7 @@ class FileSupport { expected.ignore = ignore.sort () expected } + */ /** * read test items yaml diff --git a/src/main/groovy/io/openapiprocessor/test/TestItems.groovy b/src/main/groovy/io/openapiprocessor/test/TestItems.groovy index 92f90dd..976d82a 100644 --- a/src/main/groovy/io/openapiprocessor/test/TestItems.groovy +++ b/src/main/groovy/io/openapiprocessor/test/TestItems.groovy @@ -1,17 +1,6 @@ /* - * Copyright 2020 the original authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2020 https://github.com/openapi-processor/openapi-processor-test + * PDX-License-Identifier: Apache-2.0 */ package io.openapiprocessor.test @@ -21,5 +10,4 @@ package io.openapiprocessor.test */ class TestItems { List items - List ignore } diff --git a/src/main/groovy/io/openapiprocessor/test/TestSetRunner.groovy b/src/main/groovy/io/openapiprocessor/test/TestSetRunner.groovy index 7cac338..6e0844a 100644 --- a/src/main/groovy/io/openapiprocessor/test/TestSetRunner.groovy +++ b/src/main/groovy/io/openapiprocessor/test/TestSetRunner.groovy @@ -57,13 +57,13 @@ class TestSetRunner { def expectedFiles = files.getExpectedFiles (sourcePath, packageName) def generatedFiles = files.getGeneratedFiles (generatedPath) - // should generate expected files including the ignored files - def allExpectedFiles = (expectedFiles.items + expectedFiles.ignore).sort () - assert allExpectedFiles == generatedFiles + // even if not expected, check that the annotation was generated + def expectedFilesPlus = expectedFiles + ["support/Generated.java"] + assert expectedFilesPlus == generatedFiles - // compare expected files with the generated files, skip the ignored files + // compare expected files with the generated files def success = true - expectedFiles.items.each { + expectedFiles.each { def expected = "${expectedPath}/$it" def generated = generatedPath.resolve (it) @@ -113,17 +113,12 @@ class TestSetRunner { processor.run (options) then: - def expectedFilesYml = files.getExpectedFiles (path, packageName) + def expectedFiles = files.getExpectedFiles (path, packageName) def generatedFiles = files.getGeneratedFiles (generatedPath) - // should generate expected files including the ignored files - def allExpectedFiles = (expectedFilesYml.items + expectedFilesYml.ignore).sort () - assert allExpectedFiles == generatedFiles - - // compare expected files (on the custom files system) with the generated files, skip the - // ignored files - def expectedFiles = files.collectPaths (expectedPath) - expectedFiles.removeAll (expectedFilesYml.ignore) + // even if not expected, check that the annotation was generated + def expectedFilesPlus = expectedFiles + ["support/Generated.java"] + assert expectedFilesPlus == generatedFiles def success = true expectedFiles.each { From f3c933a43c14f2a0e9bfd48db67503a0b7974a8b Mon Sep 17 00:00:00 2001 From: Martin Hauner Date: Sun, 25 Sep 2022 15:24:36 +0200 Subject: [PATCH 11/21] update gradle --- gradle/wrapper/gradle-wrapper.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 92f06b5..8fad3f5 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists From fed81f3fd1a342f8e2aad8224f055d8c6645764c Mon Sep 17 00:00:00 2001 From: Martin Hauner Date: Sun, 25 Sep 2022 15:25:07 +0200 Subject: [PATCH 12/21] add version catalog --- build.gradle.kts | 19 ++++++++++--------- gradle/libs.versions.toml | 18 ++++++++++++++++++ 2 files changed, 28 insertions(+), 9 deletions(-) create mode 100644 gradle/libs.versions.toml diff --git a/build.gradle.kts b/build.gradle.kts index 2610223..8ac700d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,8 +3,8 @@ plugins { id("java-library") id("maven-publish") id("signing") - id("com.github.ben-manes.versions") version ("0.42.0") - id("io.github.gradle-nexus.publish-plugin") version ("1.1.0") + alias(libs.plugins.nexus) + alias(libs.plugins.versions) } val projectGroupId: String by project @@ -69,17 +69,18 @@ repositories { } dependencies { - compileOnly("io.openapiprocessor:openapi-processor-api:2021.1") + compileOnly(libs.openapi.processor.api) - implementation(platform("com.fasterxml.jackson:jackson-bom:2.13.3")) - implementation(platform("org.codehaus.groovy:groovy-bom:3.0.10")) + implementation(platform(libs.jackson.bom)) + implementation("com.fasterxml.jackson.core:jackson-databind") + implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml") + implementation(platform(libs.groovy.bom)) implementation("org.codehaus.groovy:groovy") implementation("org.codehaus.groovy:groovy-nio") - implementation("com.fasterxml.jackson.core:jackson-databind") - implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml") - implementation("io.github.java-diff-utils:java-diff-utils:4.11") - implementation("com.google.jimfs:jimfs:1.2") { + + implementation(libs.diff.utils) + implementation(libs.jimfs) { exclude("com.google.guava") } } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 0000000..02deb4d --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,18 @@ +[versions] + +[libraries] +openapi-processor-api = "io.openapiprocessor:openapi-processor-api:2021.1" + +jackson-bom = "com.fasterxml.jackson:jackson-bom:2.13.4" +jackson-databind = { module = "com.fasterxml.jackson.core:jackson-databind" } +jackson-yaml = { module = "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml" } + +groovy-bom = "org.codehaus.groovy:groovy-bom:3.0.13" + +diff-utils = "io.github.java-diff-utils:java-diff-utils:4.12" +jimfs = "com.google.jimfs:jimfs:1.2" + +[plugins] +versions = { id = "com.github.ben-manes.versions", version = "0.42.0" } +nexus = { id = "io.github.gradle-nexus.publish-plugin", version = "1.1.0" } +jacoco = { id = "org.barfuin.gradle.jacocolog", version = "2.0.0" } From ca2c4420e138240f4907479b7ce3cffe83c95cc9 Mon Sep 17 00:00:00 2001 From: Martin Hauner Date: Sun, 25 Sep 2022 15:59:18 +0200 Subject: [PATCH 13/21] extract publishing --- build.gradle.kts | 141 +---------------------------------- gradle/publishing.gradle | 94 +++++++++++++++++++++++ gradle/publishing.gradle.kts | 84 +++++++++++++++++++++ 3 files changed, 181 insertions(+), 138 deletions(-) create mode 100644 gradle/publishing.gradle create mode 100644 gradle/publishing.gradle.kts diff --git a/build.gradle.kts b/build.gradle.kts index 8ac700d..08cd085 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -17,45 +17,9 @@ java { toolchain { languageVersion.set(JavaLanguageVersion.of(11)) } -} - -fun getBuildProperty(property: String): String { - val prop: String? = project.findProperty(property) as String? - if(prop != null) { - return prop - } - - val env: String? = System.getenv(property) - if (env != null) { - return env - } - - return "n/a" -} - -fun getBuildSignKey(property: String): String { - val prop: String? = project.findProperty(property) as String? - if(prop != null) { - return prop - } - val env: String? = System.getenv(property) - if (env != null) { - return env.replace("\\n", "\n") - } - - return "n/a" -} - -fun isReleaseVersion(): Boolean { - return !(project.version.toString().endsWith("SNAPSHOT")) -} - -ext { - set("publishUser", getBuildProperty("PUBLISH_USER")) - set("publishKey", getBuildProperty("PUBLISH_KEY")) - set("signKey", getBuildSignKey("SIGN_KEY")) - set("signPwd", getBuildProperty("SIGN_PWD")) + withJavadocJar () + withSourcesJar () } repositories { @@ -85,103 +49,4 @@ dependencies { } } -val sourcesJar by tasks.registering(Jar::class) { - archiveClassifier.set("sources") - from(sourceSets.main.get().allSource) -} - -val javadocJar by tasks.registering(Jar::class) { - dependsOn("javadoc") - archiveClassifier.set("javadoc") - from(tasks.javadoc.get().destinationDir) -} - -artifacts { - archives(sourcesJar) - archives(javadocJar) -} - -//apply(from = "${rootProject.rootDir}/gradle/publishing.gradle.kts") - -val projectTitle: String by project -val projectDesc: String by project -val projectUrl: String by project -val projectGithubRepo: String by project - -// does not work on oss.sonatype.org -tasks.withType().configureEach { - enabled = false -} - -publishing { - publications { - create("OpenApiProcessor") { - from(components["java"]) - artifact(sourcesJar.get()) - artifact(javadocJar.get()) - - groupId = project.group.toString() - artifactId = project.name - version = project.version.toString() - - pom { - name.set(projectTitle) - description.set(projectDesc) - url.set(projectUrl) - - licenses { - license { - name.set("The Apache License, Version 2.0") - url.set("http://www.apache.org/licenses/LICENSE-2.0.txt") - distribution.set("repo") - } - } - - developers { - developer { - id.set("hauner") - name.set("Martin Hauner") - } - } - - scm { - url.set("https://github.com/${projectGithubRepo}") - } - } - } - } - - repositories { - maven { - val releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2" - val snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots" - url = uri(if (isReleaseVersion()) releasesRepoUrl else snapshotsRepoUrl) - - credentials { - username = project.extra["publishUser"].toString() - password = project.extra["publishKey"].toString() - } - } - } -} - -//tasks.withType().configureEach { -// onlyIf { isReleaseVersion() } -//} - -signing { - useInMemoryPgpKeys( - project.extra["signKey"].toString(), - project.extra["signPwd"].toString()) - - sign(publishing.publications["OpenApiProcessor"]) -} - -nexusPublishing { - repositories { - sonatype { - username.set(project.extra["publishUser"].toString()) - password.set(project.extra["publishKey"].toString()) - } - } -} +apply(from = "${rootProject.rootDir}/gradle/publishing.gradle") diff --git a/gradle/publishing.gradle b/gradle/publishing.gradle new file mode 100644 index 0000000..6e23e5a --- /dev/null +++ b/gradle/publishing.gradle @@ -0,0 +1,94 @@ +configure(project.rootProject) { + ext { + publishUser = getBuildProperty ('PUBLISH_USER') + publishKey = getBuildProperty ('PUBLISH_KEY') + + signKey = getBuildSignKey ('SIGN_KEY') + signPwd = getBuildProperty ('SIGN_PWD') + + isReleaseVersion = !version.endsWith("SNAPSHOT") + } +} + +publishing { + publications { + processorTest (MavenPublication) { + groupId project.group + artifactId project.name + version project.version + + from components.java + + pom { + name = project.projectTitle + description = project.projectDesc + url = project.projectUrl + + licenses { + license { + name = 'The Apache Software License, Version 2.0' + url = 'https://www.apache.org/licenses/LICENSE-2.0.txt' + distribution = "repo" + } + } + + developers { + developer { + id = 'hauner' + name = 'Martin Hauner' + } + } + + scm { + url = "https://github.com/${project.projectGithubRepo}".toString () + } + } + + } + } + + repositories { + maven { + def releaseRepository = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2") + def snapshotRepository = uri("https://oss.sonatype.org/content/repositories/snapshots") + url = project.isReleaseVersion ? releaseRepository : snapshotRepository + + credentials { + username = publishUser + password = publishKey + } + } + } +} + +//tasks.withType(Sign) { +// onlyIf { project.isReleaseVersion } +//} + +signing { + useInMemoryPgpKeys(signKey, signPwd) + + signing { + sign publishing.publications.processorTest + } +} + +nexusPublishing { + repositories { + sonatype() { + username = publishUser + password = publishKey + } + } +} + +// helper + +String getBuildProperty(String property) { + project.findProperty (property) ?: System.getenv (property) ?: 'n/a' +} + +String getBuildSignKey(String property) { + project.findProperty (property) ?: System.getenv (property) ? + System.getenv (property).replace("\\n", "\n"): 'n/a' +} diff --git a/gradle/publishing.gradle.kts b/gradle/publishing.gradle.kts new file mode 100644 index 0000000..8bcc156 --- /dev/null +++ b/gradle/publishing.gradle.kts @@ -0,0 +1,84 @@ +/* +val projectTitle: String by project +val projectDesc: String by project +val projectUrl: String by project +val projectGithubRepo: String by project + +// does not work on oss.sonatype.org +tasks.withType().configureEach { + enabled = false +} + +publishing { + publications { + create("OpenApiProcessor") { + from(components["java"]) + artifact(sourcesJar.get()) + artifact(javadocJar.get()) + + groupId = project.group.toString() + artifactId = project.name + version = project.version.toString() + + pom { + name.set(projectTitle) + description.set(projectDesc) + url.set(projectUrl) + + licenses { + license { + name.set("The Apache License, Version 2.0") + url.set("http://www.apache.org/licenses/LICENSE-2.0.txt") + distribution.set("repo") + } + } + + developers { + developer { + id.set("hauner") + name.set("Martin Hauner") + } + } + + scm { + url.set("https://github.com/${projectGithubRepo}") + } + } + } + } + + repositories { + maven { + val releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2" + val snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots" + url = uri(if (isReleaseVersion()) releasesRepoUrl else snapshotsRepoUrl) + + credentials { + username = project.extra["publishUser"].toString() + password = project.extra["publishKey"].toString() + } + } + } +} + +//tasks.withType().configureEach { +// onlyIf { isReleaseVersion() } +//} + +signing { + useInMemoryPgpKeys( + project.extra["signKey"].toString(), + project.extra["signPwd"].toString()) + + sign(publishing.publications["OpenApiProcessor"]) +} + +nexusPublishing { + repositories { + sonatype { + username.set(project.extra["publishUser"].toString()) + password.set(project.extra["publishKey"].toString()) + } + } +} +*/ From 788704844fac0be86365873d7435204ca32feff3 Mon Sep 17 00:00:00 2001 From: Martin Hauner Date: Sun, 25 Sep 2022 15:59:55 +0200 Subject: [PATCH 14/21] move to version catalog --- build.gradle.kts | 2 +- gradle/libs.versions.toml | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 08cd085..40f66b0 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -15,7 +15,7 @@ version = projectVersion java { toolchain { - languageVersion.set(JavaLanguageVersion.of(11)) + languageVersion.set(JavaLanguageVersion.of(libs.versions.build.jdk.get())) } withJavadocJar () diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 02deb4d..1bc0e77 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,4 +1,6 @@ [versions] +build-jdk = "11" +target-jvm = "8" [libraries] openapi-processor-api = "io.openapiprocessor:openapi-processor-api:2021.1" From 40fc236f6eea99ef83e67d22c65df71dc493ca41 Mon Sep 17 00:00:00 2001 From: Martin Hauner Date: Sun, 25 Sep 2022 16:01:03 +0200 Subject: [PATCH 15/21] suppress "wrong" error --- build.gradle.kts | 1 + 1 file changed, 1 insertion(+) diff --git a/build.gradle.kts b/build.gradle.kts index 40f66b0..0ccfc76 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,3 +1,4 @@ +@Suppress("DSL_SCOPE_VIOLATION") // TODO: Remove once KTIJ-19369 is fixed plugins { groovy id("java-library") From b0c6437690eec857034375367cd8ab6c1f92bf1d Mon Sep 17 00:00:00 2001 From: Martin Hauner Date: Wed, 28 Sep 2022 09:43:57 +0200 Subject: [PATCH 16/21] log missing files --- build.gradle.kts | 1 + gradle/libs.versions.toml | 1 + .../openapiprocessor/test/FileSupport.groovy | 42 ++++++++++++------- 3 files changed, 29 insertions(+), 15 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 0ccfc76..c62694a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -48,6 +48,7 @@ dependencies { implementation(libs.jimfs) { exclude("com.google.guava") } + implementation(libs.slf4j) } apply(from = "${rootProject.rootDir}/gradle/publishing.gradle") diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 1bc0e77..7212928 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -13,6 +13,7 @@ groovy-bom = "org.codehaus.groovy:groovy-bom:3.0.13" diff-utils = "io.github.java-diff-utils:java-diff-utils:4.12" jimfs = "com.google.jimfs:jimfs:1.2" +slf4j = "org.slf4j:slf4j-api:2.0.0-alpha7" [plugins] versions = { id = "com.github.ben-manes.versions", version = "0.42.0" } diff --git a/src/main/groovy/io/openapiprocessor/test/FileSupport.groovy b/src/main/groovy/io/openapiprocessor/test/FileSupport.groovy index ee43786..041682e 100644 --- a/src/main/groovy/io/openapiprocessor/test/FileSupport.groovy +++ b/src/main/groovy/io/openapiprocessor/test/FileSupport.groovy @@ -10,12 +10,16 @@ import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.dataformat.yaml.YAMLFactory import com.github.difflib.DiffUtils import com.github.difflib.UnifiedDiffUtils +import org.slf4j.Logger +import org.slf4j.LoggerFactory import java.nio.file.Files import java.nio.file.Path import java.util.stream.Stream class FileSupport { + private static final Logger log = LoggerFactory.getLogger (FileSupport) + private Class resourceBase private String inputs private String generated @@ -37,13 +41,17 @@ class FileSupport { .filter ({f -> !Files.isDirectory (f)}) paths.forEach { p -> - Path relativePath = source.relativize (p) - Path targetPath = target.resolve (relativePath.toString ()) - Files.createDirectories (targetPath.getParent ()) - - InputStream src = Files.newInputStream (p) - OutputStream dst = Files.newOutputStream (targetPath) - src.transferTo (dst) + try { + Path relativePath = source.relativize (p) + Path targetPath = target.resolve (relativePath.toString ()) + Files.createDirectories (targetPath.getParent ()) + + InputStream src = Files.newInputStream (p) + OutputStream dst = Files.newOutputStream (targetPath) + src.transferTo (dst) + } catch (Exception ex) { + log.error ("failed to copy {}", p.toString (), ex) + } } paths.close () @@ -58,14 +66,18 @@ class FileSupport { */ void copy (String source, List sources, Path target) { for (String p : sources) { - String relativePath = p.substring (source.size () + 1) - - Path targetPath = target.resolve (relativePath.toString ()) - Files.createDirectories (targetPath.getParent ()) - - InputStream src = getResource (p) - OutputStream dst = Files.newOutputStream (targetPath) - src.transferTo (dst) + try { + String relativePath = p.substring (source.size () + 1) + + Path targetPath = target.resolve (relativePath.toString ()) + Files.createDirectories (targetPath.getParent ()) + + InputStream src = getResource (p) + OutputStream dst = Files.newOutputStream (targetPath) + src.transferTo (dst) + } catch (Exception ex) { + log.error ("failed to copy {}", p, ex) + } } } From 9f76d5f6b10748c92e7d548b14352a48bb76bbf2 Mon Sep 17 00:00:00 2001 From: Martin Hauner Date: Wed, 28 Sep 2022 10:34:15 +0200 Subject: [PATCH 17/21] should report empty diff --- .../io/openapiprocessor/test/FileSupport.groovy | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/main/groovy/io/openapiprocessor/test/FileSupport.groovy b/src/main/groovy/io/openapiprocessor/test/FileSupport.groovy index 041682e..c9e9847 100644 --- a/src/main/groovy/io/openapiprocessor/test/FileSupport.groovy +++ b/src/main/groovy/io/openapiprocessor/test/FileSupport.groovy @@ -222,7 +222,10 @@ class FileSupport { } /** - * unified diff resources <=> file system + * unified diff resources <=> file system. + * + * @param expected resource path + * @param generated file system path * * @return true if there is a difference */ @@ -249,9 +252,14 @@ class FileSupport { } /** - * unified diff file system <=> file system + * unified diff file system <=> file system. + * + * @param expected file system path + * @param generated file system path + * + * @return true if there is a difference */ - static void printUnifiedDiff (Path expected, Path generated) { + boolean printUnifiedDiff (Path expected, Path generated) { def patch = DiffUtils.diff ( expected.readLines (), generated.readLines ()) @@ -267,6 +275,8 @@ class FileSupport { diff.each { println it } + + return !patch.deltas.isEmpty () } InputStream getResource (String path) { From 8016001ac66c1165262292d2e026c4ac136e4a7e Mon Sep 17 00:00:00 2001 From: Martin Hauner Date: Wed, 28 Sep 2022 16:08:39 +0200 Subject: [PATCH 18/21] update dependency --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 7212928..6d5b110 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -13,7 +13,7 @@ groovy-bom = "org.codehaus.groovy:groovy-bom:3.0.13" diff-utils = "io.github.java-diff-utils:java-diff-utils:4.12" jimfs = "com.google.jimfs:jimfs:1.2" -slf4j = "org.slf4j:slf4j-api:2.0.0-alpha7" +slf4j = "org.slf4j:slf4j-api:2.0.3" [plugins] versions = { id = "com.github.ben-manes.versions", version = "0.42.0" } From e42c5256e1287d9882a510ab5b2d13cebf80014e Mon Sep 17 00:00:00 2001 From: Martin Hauner Date: Thu, 29 Sep 2022 12:13:16 +0200 Subject: [PATCH 19/21] next snapshot --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index e78f4ec..abf84db 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -projectVersion=2022.3-SNAPSHOT +projectVersion=2022.4-SNAPSHOT projectGroupId=io.openapiprocessor projectUrl=https://openapiprocessor.io From 8cba1e8ab9199893261c76d0c9106cd52dc6cf59 Mon Sep 17 00:00:00 2001 From: Martin Hauner Date: Fri, 30 Sep 2022 10:01:01 +0200 Subject: [PATCH 20/21] update to groovy 4 --- build.gradle.kts | 4 ++-- gradle/libs.versions.toml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index c62694a..65ac81a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -41,8 +41,8 @@ dependencies { implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml") implementation(platform(libs.groovy.bom)) - implementation("org.codehaus.groovy:groovy") - implementation("org.codehaus.groovy:groovy-nio") + implementation("org.apache.groovy:groovy") + implementation("org.apache.groovy:groovy-nio") implementation(libs.diff.utils) implementation(libs.jimfs) { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 6d5b110..3e1d29c 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,6 +1,6 @@ [versions] build-jdk = "11" -target-jvm = "8" +target-jdk = "8" [libraries] openapi-processor-api = "io.openapiprocessor:openapi-processor-api:2021.1" @@ -9,7 +9,7 @@ jackson-bom = "com.fasterxml.jackson:jackson-bom:2.13.4" jackson-databind = { module = "com.fasterxml.jackson.core:jackson-databind" } jackson-yaml = { module = "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml" } -groovy-bom = "org.codehaus.groovy:groovy-bom:3.0.13" +groovy-bom = "org.apache.groovy:groovy-bom:4.0.5" diff-utils = "io.github.java-diff-utils:java-diff-utils:4.12" jimfs = "com.google.jimfs:jimfs:1.2" From 53d8f695e3a245dfba9cb789dba1b670aa7254a0 Mon Sep 17 00:00:00 2001 From: Martin Hauner Date: Fri, 30 Sep 2022 18:44:14 +0200 Subject: [PATCH 21/21] next snapshot --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index abf84db..a55378d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -projectVersion=2022.4-SNAPSHOT +projectVersion=2022.5-SNAPSHOT projectGroupId=io.openapiprocessor projectUrl=https://openapiprocessor.io