Skip to content

Commit

Permalink
Bump spotless to v7 (#697)
Browse files Browse the repository at this point in the history
* Prepare version bump of spotless

spotless v7 fails on Gradle with some `SerializationException`, moving the `callable` works around this issue (as [mentioned here](diffplug/spotless#2387)).

Also removing the unnecessary `buildscript.dependencies` and the implied 2nd spotless version definition.

* main: Update dependency com.diffplug.spotless:spotless-plugin-gradle to v7

* spotlessApply

---------

Co-authored-by: Mend Renovate <[email protected]>
  • Loading branch information
snazy and renovate-bot authored Jan 11, 2025
1 parent 9db2892 commit 7d53b73
Show file tree
Hide file tree
Showing 15 changed files with 44 additions and 43 deletions.
2 changes: 1 addition & 1 deletion api/iceberg-service/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ openApiGenerate {
"CommitTableRequest" to "org.apache.polaris.service.types.CommitTableRequest",
"NotificationRequest" to "org.apache.polaris.service.types.NotificationRequest",
"TableUpdateNotification" to "org.apache.polaris.service.types.TableUpdateNotification",
"NotificationType" to "org.apache.polaris.service.types.NotificationType"
"NotificationType" to "org.apache.polaris.service.types.NotificationType",
)
}

Expand Down
24 changes: 15 additions & 9 deletions build-logic/src/main/kotlin/polaris-java.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
* under the License.
*/

import com.diffplug.spotless.FormatterFunc
import java.io.Serializable
import net.ltgt.gradle.errorprone.errorprone
import org.gradle.api.tasks.compile.JavaCompile
import org.gradle.api.tasks.testing.Test
Expand Down Expand Up @@ -74,25 +76,29 @@ tasks.withType(Jar::class).configureEach {
// manifests for release(-like) builds.
"Implementation-Title" to "Apache Polaris(TM) (incubating)",
"Implementation-Vendor" to "Apache Software Foundation",
"Implementation-URL" to "https://polaris.apache.org/"
"Implementation-URL" to "https://polaris.apache.org/",
)
}
}

spotless {
val disallowWildcardImports = { text: String ->
val regex = "~/import .*\\.\\*;/".toRegex()
if (regex.matches(text)) {
throw GradleException("Wildcard imports disallowed - ${regex.findAll(text)}")
}
text
}
java {
target("src/main/java/**/*.java", "src/testFixtures/java/**/*.java", "src/test/java/**/*.java")
googleJavaFormat()
licenseHeaderFile(rootProject.file("codestyle/copyright-header-java.txt"))
endWithNewline()
custom("disallowWildcardImports", disallowWildcardImports)
custom(
"disallowWildcardImports",
object : Serializable, FormatterFunc {
override fun apply(text: String): String {
val regex = "~/import .*\\.\\*;/".toRegex()
if (regex.matches(text)) {
throw GradleException("Wildcard imports disallowed - ${regex.findAll(text)}")
}
return text
}
},
)
toggleOffOn()
}
kotlinGradle {
Expand Down
6 changes: 3 additions & 3 deletions build-logic/src/main/kotlin/polaris-license-report.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ afterEvaluate {
arrayOf(
LicenseBundleNormalizer(
"${rootProject.projectDir}/gradle/license/normalizer-bundle.json",
false
false,
),
LicenseFileValidation()
LicenseFileValidation(),
)
allowedLicensesFile = rootProject.projectDir.resolve("gradle/license/allowed-licenses.json")
renderers =
Expand All @@ -48,7 +48,7 @@ val generateLicenseReport =
inputs
.files(
rootProject.projectDir.resolve("gradle/license/normalizer-bundle.json"),
rootProject.projectDir.resolve("gradle/license/allowed-licenses.json")
rootProject.projectDir.resolve("gradle/license/allowed-licenses.json"),
)
.withPathSensitivity(PathSensitivity.RELATIVE)
inputs.property("renderersHash", Arrays.hashCode(licenseReport.renderers))
Expand Down
2 changes: 1 addition & 1 deletion build-logic/src/main/kotlin/publishing/MemoizedGitInfo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ internal class MemoizedGitInfo {
"Apache-Polaris-Build-Git-Describe" to gitDescribe,
"Apache-Polaris-Build-Timestamp" to timestamp,
"Apache-Polaris-Build-System" to system,
"Apache-Polaris-Build-Java-Version" to javaVersion
"Apache-Polaris-Build-Java-Version" to javaVersion,
)
rootProject.extra["gitReleaseInfo"] = info
return info
Expand Down
2 changes: 1 addition & 1 deletion build-logic/src/main/kotlin/publishing/configurePom.kt
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ fun addMissingMandatoryDependencyVersions(project: Project, projectNode: Node) {
findDependency(
project.configurations.findByName("testRuntimeClasspath"),
depGroup,
depName
depName,
)
}

Expand Down
2 changes: 1 addition & 1 deletion build-logic/src/main/kotlin/publishing/rootProject.kt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ internal fun configureOnRootProject(project: Project) =
"--prefix=${e.baseName.get()}/",
"--format=tar.gz",
"--output=${e.sourceTarball.get().asFile.relativeTo(projectDir)}",
"HEAD"
"HEAD",
)
workingDir(project.projectDir)
}
Expand Down
8 changes: 4 additions & 4 deletions build-logic/src/main/kotlin/publishing/shadowPub.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import org.gradle.api.publish.maven.MavenPublication
internal fun configureShadowPublishing(
project: Project,
mavenPublication: MavenPublication,
softwareComponentFactory: SoftwareComponentFactory
softwareComponentFactory: SoftwareComponentFactory,
) =
project.run {
fun isPublishable(element: ConfigurationVariant): Boolean {
Expand All @@ -64,15 +64,15 @@ internal fun configureShadowPublishing(
attribute(Usage.USAGE_ATTRIBUTE, project.objects.named(Usage::class.java, Usage.JAVA_API))
attribute(
Category.CATEGORY_ATTRIBUTE,
project.objects.named(Category::class.java, Category.LIBRARY)
project.objects.named(Category::class.java, Category.LIBRARY),
)
attribute(
LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE,
project.objects.named(LibraryElements::class.java, LibraryElements.JAR)
project.objects.named(LibraryElements::class.java, LibraryElements.JAR),
)
attribute(
Bundling.BUNDLING_ATTRIBUTE,
project.objects.named(Bundling::class.java, Bundling.SHADOWED)
project.objects.named(Bundling::class.java, Bundling.SHADOWED),
)
}
outgoing.artifact(shadowJar)
Expand Down
9 changes: 5 additions & 4 deletions build-logic/src/main/kotlin/publishing/util.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import org.gradle.api.artifacts.result.DependencyResult
internal fun findDependency(
config: Configuration?,
depGroup: String,
depName: String
depName: String,
): DependencyResult? {
if (config != null) {
val depResult =
Expand Down Expand Up @@ -78,7 +78,8 @@ internal fun generateDigest(input: File, output: File, algorithm: String) {
}

internal fun <T : Any> unsafeCast(o: Any?): T {
@Suppress("UNCHECKED_CAST") return o as T
@Suppress("UNCHECKED_CAST")
return o as T
}

internal fun <T : Any> parseJson(url: String): T {
Expand Down Expand Up @@ -206,7 +207,7 @@ internal fun fetchProjectPeople(apacheId: String): ProjectPeople {
licenseUrl,
bugDatabase,
inceptionYear,
peopleList
peopleList,
)
}

Expand All @@ -219,7 +220,7 @@ internal class ProjectPeople(
val licenseUrl: String,
val bugDatabase: String,
val inceptionYear: Int,
val people: List<ProjectMember>
val people: List<ProjectMember>,
)

internal class ProjectMember(val apacheId: String, val name: String, val roles: List<String>)
7 changes: 1 addition & 6 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,7 @@
import java.net.URI
import org.nosphere.apache.rat.RatTask

buildscript {
repositories { maven { url = java.net.URI("https://plugins.gradle.org/m2/") } }
dependencies {
classpath("com.diffplug.spotless:spotless-plugin-gradle:${libs.plugins.spotless.get().version}")
}
}
buildscript { repositories { maven { url = java.net.URI("https://plugins.gradle.org/m2/") } } }

plugins {
id("idea")
Expand Down
2 changes: 1 addition & 1 deletion gradle/baselibs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ idea-ext = { module = "gradle.plugin.org.jetbrains.gradle.plugin.idea-ext:gradle
license-report = { module = "com.github.jk1:gradle-license-report", version = "2.9" }
nexus-publish = { module = "io.github.gradle-nexus:publish-plugin", version = "2.0.0" }
shadow = { module = "com.gradleup.shadow:shadow-gradle-plugin", version = "8.3.5" }
spotless = { module = "com.diffplug.spotless:spotless-plugin-gradle", version = "6.25.0" }
spotless = { module = "com.diffplug.spotless:spotless-plugin-gradle", version = "7.0.1" }
1 change: 0 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,3 @@ threeten-extra = { module = "org.threeten:threeten-extra", version = "1.8.0" }
[plugins]
openapi-generator = { id = "org.openapi.generator", version = "7.10.0" }
rat = { id = "org.nosphere.apache.rat", version = "0.8.1" }
spotless = { id = "com.diffplug.spotless", version = "6.25.0" }
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
*/
public interface PolarisStorageIntegrationProvider {
@SuppressWarnings("unchecked")
<T extends PolarisStorageConfigurationInfo> @Nullable
PolarisStorageIntegration<T> getStorageIntegrationForConfig(
<T extends PolarisStorageConfigurationInfo>
@Nullable PolarisStorageIntegration<T> getStorageIntegrationForConfig(
PolarisStorageConfigurationInfo polarisStorageConfigurationInfo);
}
Original file line number Diff line number Diff line change
Expand Up @@ -519,8 +519,8 @@ public Response addGrantToCatalogRole(
catalogName);
PolarisAdminService adminService = newAdminService(realmContext, securityContext);
switch (grantRequest.getGrant()) {
// The per-securable-type Privilege enums must be exact String match for a subset of all
// PolarisPrivilege values.
// The per-securable-type Privilege enums must be exact String match for a subset of all
// PolarisPrivilege values.
case ViewGrant viewGrant:
{
PolarisPrivilege privilege =
Expand Down Expand Up @@ -595,8 +595,8 @@ public Response revokeGrantFromCatalogRole(

PolarisAdminService adminService = newAdminService(realmContext, securityContext);
switch (grantRequest.getGrant()) {
// The per-securable-type Privilege enums must be exact String match for a subset of all
// PolarisPrivilege values.
// The per-securable-type Privilege enums must be exact String match for a subset of all
// PolarisPrivilege values.
case ViewGrant viewGrant:
{
PolarisPrivilege privilege =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1735,16 +1735,16 @@ private void renameTableLike(
case BaseResult.ReturnStatus.ENTITY_NOT_FOUND:
throw new NotFoundException("Cannot rename %s to %s. %s does not exist", from, to, from);

// this is temporary. Should throw a special error that will be caught and retried
// this is temporary. Should throw a special error that will be caught and retried
case BaseResult.ReturnStatus.TARGET_ENTITY_CONCURRENTLY_MODIFIED:
case BaseResult.ReturnStatus.ENTITY_CANNOT_BE_RESOLVED:
throw new RuntimeException("concurrent update detected, please retry");

// some entities cannot be renamed
// some entities cannot be renamed
case BaseResult.ReturnStatus.ENTITY_CANNOT_BE_RENAMED:
throw new BadRequestException("Cannot rename built-in object %s", leafEntity.getName());

// some entities cannot be renamed
// some entities cannot be renamed
default:
throw new IllegalStateException(
"Unknown error status " + returnedEntityResult.getReturnStatus());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ public PolarisStorageIntegrationProviderImpl(

@Override
@SuppressWarnings("unchecked")
public <T extends PolarisStorageConfigurationInfo> @Nullable
PolarisStorageIntegration<T> getStorageIntegrationForConfig(
public <T extends PolarisStorageConfigurationInfo>
@Nullable PolarisStorageIntegration<T> getStorageIntegrationForConfig(
PolarisStorageConfigurationInfo polarisStorageConfigurationInfo) {
if (polarisStorageConfigurationInfo == null) {
return null;
Expand Down

0 comments on commit 7d53b73

Please sign in to comment.