-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathbuild.gradle.kts
140 lines (120 loc) · 3.6 KB
/
build.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
import com.gradle.publish.PublishTask.GRADLE_PUBLISH_KEY
import com.gradle.publish.PublishTask.GRADLE_PUBLISH_SECRET
import com.vanniktech.maven.publish.SonatypeHost
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
repositories {
gradlePluginPortal()
mavenCentral()
}
plugins {
`kotlin-dsl`
alias(libs.plugins.buildConfig)
alias(libs.plugins.kotlin)
alias(libs.plugins.mavenPublish)
alias(libs.plugins.osDetector)
alias(libs.plugins.pluginPublish)
alias(libs.plugins.spotless)
}
group = "build.buf"
allprojects {
spotless {
kotlin {
ktlint()
target("**/*.kt")
}
kotlinGradle {
ktlint()
}
}
}
val bufCliDependabotConfig = configurations.create("bufCliDependabotConfig")
val protoc: Configuration by configurations.creating
dependencies {
// Trigger dependabot on a new Buf CLI release.
bufCliDependabotConfig(libs.bufbuild)
implementation(libs.jacksonDataformatYaml)
implementation(libs.jacksonModuleKotlin)
implementation(libs.versioncompare)
testImplementation(libs.junit)
testImplementation(libs.truth)
protoc("com.google.protobuf:protoc:${libs.versions.protoc.get()}:${osdetector.classifier}@exe")
}
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"
}
fun isRelease() = !version.toString().endsWith("-SNAPSHOT")
gradlePlugin {
website.set(ProjectInfo.URL)
vcsUrl.set(ProjectInfo.URL)
plugins {
create("buf") {
id = "build.buf"
implementationClass = "build.buf.gradle.BufPlugin"
displayName = ProjectInfo.NAME
description = ProjectInfo.DESCRIPTION
tags.set(listOf("protobuf", "kotlin", "buf"))
}
}
}
ext[GRADLE_PUBLISH_KEY] = System.getenv("GRADLE_PORTAL_PUBLISH_KEY")
ext[GRADLE_PUBLISH_SECRET] = System.getenv("GRADLE_PORTAL_PUBLISH_SECRET")
kotlin {
jvmToolchain {
languageVersion.set(JavaLanguageVersion.of(11))
}
}
mavenPublishing {
publishToMavenCentral(SonatypeHost.S01)
signAllPublications()
pom {
name.set(ProjectInfo.NAME)
description.set(ProjectInfo.DESCRIPTION)
url.set(ProjectInfo.URL)
scm {
url.set(ProjectInfo.URL)
}
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
developers {
developer {
id.set("Andrew Parmet")
name.set("Andrew Parmet")
email.set("[email protected]")
}
developer {
id.set("bufbuild")
name.set("Buf")
email.set("[email protected]")
url.set("https://buf.build")
organization.set("Buf Technologies, Inc.")
organizationUrl.set("https://buf.build")
}
}
}
}
tasks {
// Only enable publishing to the Gradle Portal for release builds.
named("publishPlugins") {
enabled = isRelease()
}
withType<Test> {
useJUnitPlatform()
systemProperty("protoc.path", protoc.asPath)
}
withType<KotlinCompile> {
kotlinOptions {
allWarningsAsErrors = true
}
}
}
buildConfig {
useKotlinOutput { topLevelConstants = true }
packageName.set("build.buf.gradle")
buildConfigField("String", "DEFAULT_BUF_VERSION", "\"${libs.bufbuild.get().version}\"")
}