generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 237
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
142 lines (120 loc) · 4.11 KB
/
build.gradle.kts
File metadata and controls
142 lines (120 loc) · 4.11 KB
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
141
142
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
import org.jreleaser.model.Active
buildscript {
repositories {
mavenCentral()
google()
}
dependencies {
classpath(libs.kotlin.gradle.plugin)
}
}
plugins {
alias(libs.plugins.jreleaser)
}
allprojects {
val allowLocalDeps: String by project
repositories {
if (allowLocalDeps.toBoolean()) {
mavenLocal()
}
mavenCentral()
google()
}
group = "software.amazon.smithy.rust"
val codegenVersion: String by project
version = codegenVersion
}
// jreleaser requires a "clean" task to exist
tasks.register("clean")
// Register custom tasks for Maven Central publishing
tasks.register<tasks.VerifyCodegenVersionBump>("verifyCodegenVersionBump")
tasks.register<tasks.CheckMavenCentralPublishingNeeded>("checkMavenCentralPublishingNeeded")
jreleaser {
// Creates a generic release, which won't publish anything (we are only interested in publishing the jar)
// https://jreleaser.org/guide/latest/reference/release/index.html
release {
generic {
enabled = true
skipRelease = true
}
}
// Used to announce a release to configured announcers.
// https://jreleaser.org/guide/latest/reference/announce/index.html
announce {
active = Active.NEVER
}
// Signing configuration.
// https://jreleaser.org/guide/latest/reference/signing.html
signing {
active = Active.ALWAYS
armored = true
}
// Configuration for deploying to Maven Central.
// https://jreleaser.org/guide/latest/examples/maven/maven-central.html#_gradle
deploy {
maven {
mavenCentral {
create("maven-central") {
active = Active.ALWAYS
url = "https://central.sonatype.com/api/v1/publisher"
stagingRepository(stagingDir().get().asFile.path)
maxRetries = 100
retryDelay = 60
}
}
}
}
}
val ktlint by configurations.creating
dependencies {
ktlint(libs.ktlint.cli) {
attributes {
attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling.EXTERNAL))
}
}
}
val lintPaths =
listOf(
"**/*.kt",
// Exclude build output directories
"!**/build/**",
"!**/node_modules/**",
"!**/target/**",
)
tasks.register<JavaExec>("ktlint") {
description = "Check Kotlin code style."
group = LifecycleBasePlugin.VERIFICATION_GROUP
classpath = ktlint
mainClass.set("com.pinterest.ktlint.Main")
args = listOf("--log-level=info", "--relative", "--") + lintPaths
// https://github.com/pinterest/ktlint/issues/1195#issuecomment-1009027802
jvmArgs("--add-opens", "java.base/java.lang=ALL-UNNAMED")
}
tasks.register<JavaExec>("ktlintFormat") {
description = "Auto fix Kotlin code style violations"
group = LifecycleBasePlugin.VERIFICATION_GROUP
classpath = ktlint
mainClass.set("com.pinterest.ktlint.Main")
args = listOf("--log-level=info", "--relative", "--format", "--") + lintPaths
// https://github.com/pinterest/ktlint/issues/1195#issuecomment-1009027802
jvmArgs("--add-opens", "java.base/java.lang=ALL-UNNAMED")
}
if (System.getProperties().containsKey("ktlintPreCommitArgs")) {
tasks.register<JavaExec>("ktlintPreCommit") {
description = "Check Kotlin code style (for the pre-commit hooks)."
group = LifecycleBasePlugin.VERIFICATION_GROUP
classpath = ktlint
mainClass.set("com.pinterest.ktlint.Main")
args = listOf("--log-level=warn", "--color", "--relative", "--format", "--") +
System.getProperty("ktlintPreCommitArgs").let { args ->
check(args.isNotBlank()) { "need to pass in -DktlintPreCommitArgs=<some file paths to check>" }
args.split(" ")
}
// https://github.com/pinterest/ktlint/issues/1195#issuecomment-1009027802
jvmArgs("--add-opens", "java.base/java.lang=ALL-UNNAMED")
}
}