From a62d4c8ce5196caf697d1c79cce70f1cec1de39c Mon Sep 17 00:00:00 2001 From: Emil Lundberg Date: Mon, 3 Jun 2024 14:58:03 +0200 Subject: [PATCH 1/5] Bump org.scalatestplus:junit dependency version Fixes this build failure that suddenly occurred with no code changes: ``` $ ./gradlew :webauthn-server-core:compileTestScala Execution failed for task ':webauthn-server-core:compileTestScala'. > bad constant pool index: 0 at pos: 89856 while compiling: ./webauthn-server-core/src/test/scala/com/yubico/scalacheck/gen/JacksonGenerators.scala during phase: globalPhase=typer, enteringPhase=namer library version: version 2.13.8 compiler version: version 2.13.8 reconstructed args: [9876 characters redacted for brevity] last tree to typer: Ident(com) tree position: line 35 of ./webauthn-server-core/src/test/scala/com/yubico/scalacheck/gen/JacksonGenerators.scala tree tpe: com.type symbol: final package com symbol definition: final package com (a ModuleSymbol) symbol package: symbol owners: package com call site: package gen in package scalacheck in package scalacheck == Source file context for tree position == 32 import com.fasterxml.jackson.databind.node.NumericNode 33 import com.fasterxml.jackson.databind.node.ObjectNode 34 import com.fasterxml.jackson.databind.node.TextNode 35 import com.upokecenter.cbor.CBORObject 36 import com.yubico.internal.util.JacksonCodecs 37 import org.scalacheck.Arbitrary 38 import org.scalacheck.Arbitrary.arbitrary ``` --- test-platform/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test-platform/build.gradle.kts b/test-platform/build.gradle.kts index c3ee96679..e6224e144 100644 --- a/test-platform/build.gradle.kts +++ b/test-platform/build.gradle.kts @@ -12,7 +12,7 @@ dependencies { api("org.mockito:mockito-core:4.7.0") api("org.scalacheck:scalacheck_2.13:1.16.0") api("org.scalatest:scalatest_2.13:3.2.13") - api("org.scalatestplus:junit-4-13_2.13:3.2.13.0") + api("org.scalatestplus:junit-4-13_2.13:3.2.17.0") api("org.scalatestplus:scalacheck-1-16_2.13:3.2.13.0") api("org.slf4j:slf4j-nop:2.0.3") api("uk.org.lidalia:slf4j-test:1.2.0") From f242370b8c1ab1c430847a72ca0a486d005adb45 Mon Sep 17 00:00:00 2001 From: Emil Lundberg Date: Mon, 3 Jun 2024 15:19:39 +0200 Subject: [PATCH 2/5] Bump test dependency versions --- test-platform/build.gradle.kts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test-platform/build.gradle.kts b/test-platform/build.gradle.kts index e6224e144..763737ab2 100644 --- a/test-platform/build.gradle.kts +++ b/test-platform/build.gradle.kts @@ -9,12 +9,12 @@ dependencies { api("junit:junit:4.13.2") api("org.bouncycastle:bcpkix-jdk18on:[1.62,2)") api("org.bouncycastle:bcprov-jdk18on:[1.62,2)") - api("org.mockito:mockito-core:4.7.0") - api("org.scalacheck:scalacheck_2.13:1.16.0") - api("org.scalatest:scalatest_2.13:3.2.13") - api("org.scalatestplus:junit-4-13_2.13:3.2.17.0") - api("org.scalatestplus:scalacheck-1-16_2.13:3.2.13.0") - api("org.slf4j:slf4j-nop:2.0.3") + api("org.mockito:mockito-core:4.11.0") + api("org.scalacheck:scalacheck_2.13:1.18.0") + api("org.scalatest:scalatest_2.13:3.2.18") + api("org.scalatestplus:junit-4-13_2.13:3.2.18.0") + api("org.scalatestplus:scalacheck-1-16_2.13:3.2.14.0") + api("org.slf4j:slf4j-nop:2.0.13") api("uk.org.lidalia:slf4j-test:1.2.0") } } From 3a67ec4a1b2d6588e5161fc24de6ae28544ddd88 Mon Sep 17 00:00:00 2001 From: Emil Lundberg Date: Mon, 3 Jun 2024 15:42:40 +0200 Subject: [PATCH 3/5] Fix scalafix errors The `ignoreSourceSets` config is needed to fix errors like this: ``` Execution failed for task ':yubico-util:configSemanticDBMain'. > Failed to calculate the value of task ':yubico-util:configSemanticDBMain' property 'scalaVersion'. > Unable to detect the Scala version for the 'main' source set. Please ensure it declares dependency to scala-library or consider adding it to 'ignoreSourceSets' ``` The change to `project-convention-code-formatting-internal.gradle` is needed to fix this error: ``` Execution failed for task ':yubico-util-scala:compileScala'. > Could not resolve all files for configuration ':yubico-util-scala:detachedConfiguration1'. > Could not find org.scalameta:semanticdb-scalac_2.13.13:4.5.5. Searched in the following locations: - https://repo.maven.apache.org/maven2/org/scalameta/semanticdb-scalac_2.13.13/4.5.5/semanticdb-scalac_2.13.13-4.5.5.pom If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the re pository declaration. Required by: project :yubico-util-scala ``` --- buildSrc/build.gradle.kts | 2 +- .../groovy/project-convention-code-formatting-internal.gradle | 4 ---- webauthn-server-attestation/build.gradle.kts | 4 ++++ webauthn-server-core/build.gradle.kts | 4 ++++ webauthn-server-demo/build.gradle.kts | 4 ++++ yubico-util/build.gradle.kts | 4 ++++ 6 files changed, 17 insertions(+), 5 deletions(-) diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index ac67ae261..2efaa001c 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -16,6 +16,6 @@ dependencies { // Spotless dropped Java 8 support in version 2.33.0 if (JavaVersion.current().isJava11Compatible) { implementation("com.diffplug.spotless:spotless-plugin-gradle:6.25.0") - implementation("io.github.cosmicsilence:gradle-scalafix:0.1.15") + implementation("io.github.cosmicsilence:gradle-scalafix:0.2.2") } } diff --git a/buildSrc/src/main/groovy/project-convention-code-formatting-internal.gradle b/buildSrc/src/main/groovy/project-convention-code-formatting-internal.gradle index 29e7800f9..5da3528c4 100644 --- a/buildSrc/src/main/groovy/project-convention-code-formatting-internal.gradle +++ b/buildSrc/src/main/groovy/project-convention-code-formatting-internal.gradle @@ -12,10 +12,6 @@ spotless { scalafix { configFile.set(project.rootProject.file("scalafix.conf")) - - // Work around dependency resolution issues in April 2022 - semanticdb.autoConfigure.set(true) - semanticdb.version.set("4.5.5") } project.dependencies.scalafix("com.github.liancheng:organize-imports_2.13:0.6.0") diff --git a/webauthn-server-attestation/build.gradle.kts b/webauthn-server-attestation/build.gradle.kts index 1748835d2..1b331539e 100644 --- a/webauthn-server-attestation/build.gradle.kts +++ b/webauthn-server-attestation/build.gradle.kts @@ -86,3 +86,7 @@ tasks.javadoc.configure { // Use this instead for local testing //(options as StandardJavadocDocletOptions).linksOffline("file://${coreJavadoc.destinationDir}", "${coreJavadoc.destinationDir}") } + +scalafix { + ignoreSourceSets.add("main") +} diff --git a/webauthn-server-core/build.gradle.kts b/webauthn-server-core/build.gradle.kts index 9bbd2bda8..cc1d311e3 100644 --- a/webauthn-server-core/build.gradle.kts +++ b/webauthn-server-core/build.gradle.kts @@ -68,3 +68,7 @@ tasks.withType(Jar::class) { )) } } + +scalafix { + ignoreSourceSets.add("main") +} diff --git a/webauthn-server-demo/build.gradle.kts b/webauthn-server-demo/build.gradle.kts index 82830c46e..c0fb5f773 100644 --- a/webauthn-server-demo/build.gradle.kts +++ b/webauthn-server-demo/build.gradle.kts @@ -71,3 +71,7 @@ for (task in listOf(tasks.installDist, tasks.distZip, tasks.distTar)) { } } } + +scalafix { + ignoreSourceSets.add("main") +} diff --git a/yubico-util/build.gradle.kts b/yubico-util/build.gradle.kts index e8319c120..4d503d950 100644 --- a/yubico-util/build.gradle.kts +++ b/yubico-util/build.gradle.kts @@ -49,3 +49,7 @@ tasks.jar { )) } } + +scalafix { + ignoreSourceSets.add("main") +} From 48d9688f7a85d10da927effb8e36c296ecec8feb Mon Sep 17 00:00:00 2001 From: Emil Lundberg Date: Mon, 3 Jun 2024 15:56:16 +0200 Subject: [PATCH 4/5] Apply scalafix settings conditionally The scalafix plugin is not applied when running in Java 8, so its settings must also be applied conditionally in order to not break the JDK 8 build. --- .../groovy/project-convention-code-formatting-internal.gradle | 4 ++++ webauthn-server-attestation/build.gradle.kts | 4 ---- webauthn-server-core/build.gradle.kts | 4 ---- webauthn-server-demo/build.gradle.kts | 4 ---- yubico-util/build.gradle.kts | 4 ---- 5 files changed, 4 insertions(+), 16 deletions(-) diff --git a/buildSrc/src/main/groovy/project-convention-code-formatting-internal.gradle b/buildSrc/src/main/groovy/project-convention-code-formatting-internal.gradle index 5da3528c4..c875ed7c2 100644 --- a/buildSrc/src/main/groovy/project-convention-code-formatting-internal.gradle +++ b/buildSrc/src/main/groovy/project-convention-code-formatting-internal.gradle @@ -12,6 +12,10 @@ spotless { scalafix { configFile.set(project.rootProject.file("scalafix.conf")) + + if (project.name != "yubico-util-scala") { + ignoreSourceSets.add("main") + } } project.dependencies.scalafix("com.github.liancheng:organize-imports_2.13:0.6.0") diff --git a/webauthn-server-attestation/build.gradle.kts b/webauthn-server-attestation/build.gradle.kts index 1b331539e..1748835d2 100644 --- a/webauthn-server-attestation/build.gradle.kts +++ b/webauthn-server-attestation/build.gradle.kts @@ -86,7 +86,3 @@ tasks.javadoc.configure { // Use this instead for local testing //(options as StandardJavadocDocletOptions).linksOffline("file://${coreJavadoc.destinationDir}", "${coreJavadoc.destinationDir}") } - -scalafix { - ignoreSourceSets.add("main") -} diff --git a/webauthn-server-core/build.gradle.kts b/webauthn-server-core/build.gradle.kts index cc1d311e3..9bbd2bda8 100644 --- a/webauthn-server-core/build.gradle.kts +++ b/webauthn-server-core/build.gradle.kts @@ -68,7 +68,3 @@ tasks.withType(Jar::class) { )) } } - -scalafix { - ignoreSourceSets.add("main") -} diff --git a/webauthn-server-demo/build.gradle.kts b/webauthn-server-demo/build.gradle.kts index c0fb5f773..82830c46e 100644 --- a/webauthn-server-demo/build.gradle.kts +++ b/webauthn-server-demo/build.gradle.kts @@ -71,7 +71,3 @@ for (task in listOf(tasks.installDist, tasks.distZip, tasks.distTar)) { } } } - -scalafix { - ignoreSourceSets.add("main") -} diff --git a/yubico-util/build.gradle.kts b/yubico-util/build.gradle.kts index 4d503d950..e8319c120 100644 --- a/yubico-util/build.gradle.kts +++ b/yubico-util/build.gradle.kts @@ -49,7 +49,3 @@ tasks.jar { )) } } - -scalafix { - ignoreSourceSets.add("main") -} From 0d5b5ef4fd07ff057f84d75088a32576b1197646 Mon Sep 17 00:00:00 2001 From: Emil Lundberg Date: Mon, 3 Jun 2024 17:42:58 +0200 Subject: [PATCH 5/5] Add comment why yubico-util-scala is the exception to scalafix.ignoreSourceSets --- .../groovy/project-convention-code-formatting-internal.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/buildSrc/src/main/groovy/project-convention-code-formatting-internal.gradle b/buildSrc/src/main/groovy/project-convention-code-formatting-internal.gradle index c875ed7c2..d468bf0c7 100644 --- a/buildSrc/src/main/groovy/project-convention-code-formatting-internal.gradle +++ b/buildSrc/src/main/groovy/project-convention-code-formatting-internal.gradle @@ -14,6 +14,7 @@ scalafix { configFile.set(project.rootProject.file("scalafix.conf")) if (project.name != "yubico-util-scala") { + // yubico-util-scala is the only subproject with Scala sources in the "main" source set ignoreSourceSets.add("main") } }