Skip to content

Commit

Permalink
Bump com.diffplug.spotless from 6.19.0 to 6.22.0 (#159)
Browse files Browse the repository at this point in the history
Bumps com.diffplug.spotless from 6.19.0 to 6.22.0.


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=com.diffplug.spotless&package-manager=gradle&previous-version=6.19.0&new-version=6.22.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Philip K. Warren <pwarren@buf.build>
  • Loading branch information
dependabot[bot] and pkwarren authored Nov 1, 2023
1 parent d6b9c15 commit ee3e80d
Show file tree
Hide file tree
Showing 28 changed files with 174 additions and 183 deletions.
10 changes: 5 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,16 @@ gradlePlugin {
create("buf") {
id = "build.buf"
implementationClass = "build.buf.gradle.BufPlugin"
displayName = ProjectInfo.name
description = ProjectInfo.description
displayName = ProjectInfo.NAME
description = ProjectInfo.DESCRIPTION
}
}
}

pluginBundle {
website = ProjectInfo.url
vcsUrl = ProjectInfo.url
description = ProjectInfo.description
website = ProjectInfo.URL
vcsUrl = ProjectInfo.URL
description = ProjectInfo.DESCRIPTION
tags = listOf("protobuf", "kotlin", "buf")
}

Expand Down
18 changes: 9 additions & 9 deletions buildSrc/src/main/kotlin/ConfigurePublishing.kt
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ private object Remote {
}

object ProjectInfo {
const val name = "Buf Gradle Plugin"
const val url = "https://github.com/bufbuild/buf-gradle-plugin"
const val description = "Buf plugin for Gradle"
const val NAME = "Buf Gradle Plugin"
const val URL = "https://github.com/bufbuild/buf-gradle-plugin"
const val DESCRIPTION = "Buf plugin for Gradle"
}

fun Project.configurePublishing() {
Expand Down Expand Up @@ -95,16 +95,16 @@ fun Project.configurePublishing() {

private fun MavenPublication.standardPom() {
pom {
name.set(ProjectInfo.name)
description.set(ProjectInfo.description)
url.set(ProjectInfo.url)
name.set(ProjectInfo.NAME)
description.set(ProjectInfo.DESCRIPTION)
url.set(ProjectInfo.URL)
scm {
url.set(ProjectInfo.url)
url.set(ProjectInfo.URL)
}
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
developers {
Expand All @@ -118,7 +118,7 @@ private fun MavenPublication.standardPom() {
name.set("Buf")
email.set("dev@buf.build")
url.set("https://buf.build")
organization.set("Buf Techonologies, Inc.")
organization.set("Buf Technologies, Inc.")
organizationUrl.set("https://buf.build")
}
}
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ animalsniffer = "1.7.1"
kotlin = "1.6.20"
pluginPublish = "1.2.1"
publishing = "0.22.0"
spotless = "6.19.0"
spotless = "6.22.0"

# signature
java8Signature = "1.0"
Expand Down
10 changes: 5 additions & 5 deletions src/main/kotlin/build/buf/gradle/ArtifactDetailsSupport.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ internal fun Project.getArtifactDetails(): ArtifactDetails? {
return if (publishSchema() || runBreakageCheck()) {
checkNotNull(getExtension().imageArtifactDetails ?: inferredDetails as? ArtifactDetails) {
"""
Unable to determine image artifact details and schema publication or
compatibility check was requested; no image publication details
were provided and there was not exactly one publication from which
to infer them (found ${inferredDetails ?: 0}). Either configure the
plugin with imageArtifact() or configure a publication.
Unable to determine image artifact details and schema publication or
compatibility check was requested; no image publication details
were provided and there was not exactly one publication from which
to infer them (found ${inferredDetails ?: 0}). Either configure the
plugin with imageArtifact() or configure a publication.
""".trimIndent().replace('\n', ' ')
}
} else {
Expand Down
1 change: 0 additions & 1 deletion src/main/kotlin/build/buf/gradle/BufExtension.kt
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ class GenerateOptions(
* dependency resolution to succeed.
*/
var includeImports: Boolean? = null,

/**
* Specify the location of buf.gen.yaml if not using one in the project root.
*/
Expand Down
14 changes: 7 additions & 7 deletions src/main/kotlin/build/buf/gradle/BufPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ class BufPlugin : Plugin<Project> {
private fun Project.failForWorkspaceAndPlugin() {
check(!hasWorkspace()) {
"""
A project cannot use both the protobuf-gradle-plugin and a Buf workspace.
If you have multiple protobuf source directories and you would like to
use the protobuf-gradle-plugin, configure the protobuf-gradle-plugin to use
those directories as source directories in the appropriate source set. If you
would like to use a Buf workspace, you must configure dependency resolution and
code generation using Buf. There is no (easy) way to reconcile the two
configurations for linting, breakage, and code generation steps.
A project cannot use both the protobuf-gradle-plugin and a Buf workspace.
If you have multiple protobuf source directories and you would like to
use the protobuf-gradle-plugin, configure the protobuf-gradle-plugin to use
those directories as source directories in the appropriate source set. If you
would like to use a Buf workspace, you must configure dependency resolution and
code generation using Buf. There is no (easy) way to reconcile the two
configurations for linting, breakage, and code generation steps.
""".trimIndent().replace('\n', ' ')
}
}
Expand Down
10 changes: 8 additions & 2 deletions src/main/kotlin/build/buf/gradle/BufSupport.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,17 @@ internal fun Project.configureBufDependency() {
)
}

internal fun Task.execBuf(vararg args: Any, customErrorMessage: ((String) -> String)? = null) {
internal fun Task.execBuf(
vararg args: Any,
customErrorMessage: ((String) -> String)? = null,
) {
execBuf(args.asList(), customErrorMessage)
}

internal fun Task.execBuf(args: Iterable<Any>, customErrorMessage: ((String) -> String)? = null) {
internal fun Task.execBuf(
args: Iterable<Any>,
customErrorMessage: ((String) -> String)? = null,
) {
with(project) {
val executable = singleFileFromConfiguration(BUF_BINARY_CONFIGURATION_NAME)

Expand Down
3 changes: 1 addition & 2 deletions src/main/kotlin/build/buf/gradle/ConfigSupport.kt
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ internal fun Project.bufConfigFile() =
}
}

internal fun Task.bufConfigFile() =
project.bufConfigFile()
internal fun Task.bufConfigFile() = project.bufConfigFile()

private fun Project.resolveConfig(): File? {
val ext = getExtension()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ private fun Task.execBufInSpecificDirectory(
extraArgs: Iterable<String>,
customErrorMessage: ((String) -> String)? = null,
) {
fun runWithArgs(file: File? = null) =
bufCommand + listOfNotNull(file?.let { project.makeMangledRelativizedPathStr(it) }) + extraArgs
fun runWithArgs(file: File? = null) = bufCommand + listOfNotNull(file?.let { project.makeMangledRelativizedPathStr(it) }) + extraArgs

when {
project.hasProtobufGradlePlugin() ->
Expand Down
6 changes: 2 additions & 4 deletions src/main/kotlin/build/buf/gradle/DslExtensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ import org.gradle.api.artifacts.Dependency
import org.gradle.api.artifacts.dsl.DependencyHandler
import org.gradle.kotlin.dsl.configure

fun Project.buf(cfg: BufExtension.() -> Unit) =
configure(cfg)
fun Project.buf(cfg: BufExtension.() -> Unit) = configure(cfg)

fun DependencyHandler.buf(dependencyNotation: Any): Dependency? =
add(BUF_CONFIGURATION_NAME, dependencyNotation)
fun DependencyHandler.buf(dependencyNotation: Any): Dependency? = add(BUF_CONFIGURATION_NAME, dependencyNotation)
9 changes: 3 additions & 6 deletions src/main/kotlin/build/buf/gradle/ExtensionSupport.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,13 @@ internal fun Project.createExtension() {
extensions.create<BufExtension>(BUF_EXTENSION_NAME)
}

internal fun Project.getExtension() =
extensions.getByName<BufExtension>(BUF_EXTENSION_NAME)
internal fun Project.getExtension() = extensions.getByName<BufExtension>(BUF_EXTENSION_NAME)

internal fun Task.getExtension() =
project.getExtension()
internal fun Task.getExtension() = project.getExtension()

internal fun Project.runBreakageCheck() =
with(getExtension()) {
checkSchemaAgainstLatestRelease || previousVersion != null
}

internal fun Project.publishSchema() =
getExtension().publishSchema
internal fun Project.publishSchema() = getExtension().publishSchema
21 changes: 11 additions & 10 deletions src/main/kotlin/build/buf/gradle/GenerateTask.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,17 @@ abstract class GenerateTask : DefaultTask() {

private fun additionalArgs(): List<String> {
val generateOptions = getExtension().generateOptions
val importOptions = if (generateOptions?.includeImports == true) {
listOf("--include-imports")
} else {
emptyList()
}
val importOptions =
if (generateOptions?.includeImports == true) {
listOf("--include-imports")
} else {
emptyList()
}

val templateFileOption = resolveTemplateFile()?.let {
listOf("--template", it.absolutePath)
} ?: emptyList()
val templateFileOption =
resolveTemplateFile()?.let {
listOf("--template", it.absolutePath)
} ?: emptyList()

return importOptions + templateFileOption
}
Expand All @@ -61,6 +63,5 @@ abstract class GenerateTask : DefaultTask() {
}
}

private fun File?.validOrNull() =
this?.takeIf { it.isFile && it.exists() }
private fun File?.validOrNull() = this?.takeIf { it.isFile && it.exists() }
}
11 changes: 6 additions & 5 deletions src/main/kotlin/build/buf/gradle/GradleSupport.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ internal fun TaskProvider<*>.dependsOn(obj: Any) {
configure { dependsOn(obj) }
}

internal fun Project.createConfigurationWithDependency(configuration: String, notation: Any) {
internal fun Project.createConfigurationWithDependency(
configuration: String,
notation: Any,
) {
configurations.create(configuration)
dependencies { add(configuration, notation) }
}

internal fun Project.singleFileFromConfiguration(configuration: String) =
configurations.getByName(configuration).singleFile
internal fun Project.singleFileFromConfiguration(configuration: String) = configurations.getByName(configuration).singleFile

internal fun Task.singleFileFromConfiguration(configuration: String) =
project.singleFileFromConfiguration(configuration)
internal fun Task.singleFileFromConfiguration(configuration: String) = project.singleFileFromConfiguration(configuration)
3 changes: 1 addition & 2 deletions src/main/kotlin/build/buf/gradle/OutputSupport.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,4 @@ internal fun Task.createsOutput() {
doFirst { project.bufbuildDir.mkdirs() }
}

internal fun ArtifactDetails.groupAndArtifact() =
"$groupId:$artifactId"
internal fun ArtifactDetails.groupAndArtifact() = "$groupId:$artifactId"
10 changes: 8 additions & 2 deletions src/main/kotlin/build/buf/gradle/ProcessRunner.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ internal class ProcessRunner : Closeable {
private val bufStdOut = ByteArrayOutputStream()
private val bufStdErr = ByteArrayOutputStream()

fun shell(workingDir: File, args: List<Any>): Result {
fun shell(
workingDir: File,
args: List<Any>,
): Result {
val processBuilder = ProcessBuilder(args.map(Any::toString))
processBuilder.directory(workingDir)
val process = processBuilder.start()
Expand All @@ -38,7 +41,10 @@ internal class ProcessRunner : Closeable {
return Result(args, exitCode, out.get(), err.get())
}

private fun drain(input: InputStream, output: ByteArrayOutputStream): ByteArray {
private fun drain(
input: InputStream,
output: ByteArrayOutputStream,
): ByteArray {
output.reset()
input.copyTo(output)
return output.toByteArray()
Expand Down
21 changes: 7 additions & 14 deletions src/main/kotlin/build/buf/gradle/ProtobufGradlePluginSupport.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,9 @@ private val BUILD_EXTRACTED_INCLUDE_PROTOS_MAIN =
private val BUILD_EXTRACTED_PROTOS_MAIN =
listOf("build", "extracted-protos", "main").joinToString(File.separator)

internal fun Project.hasProtobufGradlePlugin() =
pluginManager.hasPlugin("com.google.protobuf")
internal fun Project.hasProtobufGradlePlugin() = pluginManager.hasPlugin("com.google.protobuf")

internal fun Project.withProtobufGradlePlugin(action: (AppliedPlugin) -> Unit) =
pluginManager.withPlugin("com.google.protobuf", action)
internal fun Project.withProtobufGradlePlugin(action: (AppliedPlugin) -> Unit) = pluginManager.withPlugin("com.google.protobuf", action)

internal fun Project.configureCreateSymLinksToModules() {
tasks.register<CreateSymLinksToModulesTask>(CREATE_SYM_LINKS_TO_MODULES_TASK_NAME) {
Expand Down Expand Up @@ -128,12 +126,10 @@ private fun Task.allProtoDirs() =
//
// Protobuf-gradle-plugin change that introduced this behavior: https://github.com/google/protobuf-gradle-plugin/pull/637/
// Line: https://github.com/google/protobuf-gradle-plugin/blob/9d2a328a0d577bf4439d3b482a953715b3a03027/src/main/groovy/com/google/protobuf/gradle/ProtobufPlugin.groovy#L425
internal fun Project.projectDefinedProtoDirs() =
allProtoSourceSetDirs() - file(Paths.get(BUILD_EXTRACTED_PROTOS_MAIN))
internal fun Project.projectDefinedProtoDirs() = allProtoSourceSetDirs() - file(Paths.get(BUILD_EXTRACTED_PROTOS_MAIN))

// Returns deduplicated list of all proto source set directories.
private fun Project.allProtoSourceSetDirs() =
projectProtoSourceSetDirs() + androidProtoSourceSetDirs()
private fun Project.allProtoSourceSetDirs() = projectProtoSourceSetDirs() + androidProtoSourceSetDirs()

// Returns android proto source set directories that protobuf-gradle-plugin will codegen.
private fun Project.androidProtoSourceSetDirs() =
Expand All @@ -159,15 +155,12 @@ private fun ExtensionAware.projectProtoSourceSetDirs() =
.filter { anyProtos(it) }
.toSet()

internal fun Project.makeMangledRelativizedPathStr(file: File) =
mangle(projectDir.toPath().relativize(file.toPath()))
internal fun Project.makeMangledRelativizedPathStr(file: File) = mangle(projectDir.toPath().relativize(file.toPath()))

// Indicates if the specified directory contains any proto files.
private fun anyProtos(directory: File) =
directory.walkTopDown().any { it.extension == "proto" }
private fun anyProtos(directory: File) = directory.walkTopDown().any { it.extension == "proto" }

private fun mangle(name: Path) =
name.toString().replace("-", "--").replace(File.separator, "-")
private fun mangle(name: Path) = name.toString().replace("-", "--").replace(File.separator, "-")

internal inline fun <reified T : Task> Project.registerBufTask(
name: String,
Expand Down
3 changes: 1 addition & 2 deletions src/main/kotlin/build/buf/gradle/WorkspaceSupport.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@ package build.buf.gradle

import org.gradle.api.Project

internal fun Project.hasWorkspace() =
file("buf.work.yaml").let { it.exists() && it.isFile }
internal fun Project.hasWorkspace() = file("buf.work.yaml").let { it.exists() && it.isFile }
4 changes: 2 additions & 2 deletions src/test/kotlin/build/buf/gradle/AbstractBreakingTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ abstract class AbstractBreakingTest : AbstractBufIntegrationTest() {
assertThat(result.task(":$BUF_BREAKING_TASK_NAME")?.outcome).isEqualTo(FAILED)
assertThat(result.output).contains(
"""
Execution failed for task ':bufBreaking'.
> Some Protobuf files had breaking changes:
Execution failed for task ':bufBreaking'.
> Some Protobuf files had breaking changes:
""".trimIndent().osIndependent(),
)
assertThat(result.output).contains("Previously present message \"BasicMessage\" was deleted from file.")
Expand Down
Loading

0 comments on commit ee3e80d

Please sign in to comment.