forked from smithy-lang/smithy-kotlin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
162 lines (138 loc) · 5.08 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
import java.util.Properties
buildscript {
repositories {
mavenCentral()
google()
}
val kotlinVersion: String by project
dependencies {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
}
}
plugins {
kotlin("jvm") apply false
id("org.jetbrains.dokka")
id("io.github.gradle-nexus.publish-plugin") version "1.1.0"
}
allprojects {
repositories {
mavenLocal()
mavenCentral()
google()
}
tasks.withType<org.jetbrains.dokka.gradle.AbstractDokkaTask>().configureEach {
val sdkVersion: String by project
moduleVersion.set(sdkVersion)
val year = java.time.LocalDate.now().year
val pluginConfigMap = mapOf(
"org.jetbrains.dokka.base.DokkaBase" to """
{
"customStyleSheets": [
"${rootProject.file("docs/dokka-presets/css/logo-styles.css")}",
"${rootProject.file("docs/dokka-presets/css/aws-styles.css")}"
],
"customAssets": [
"${rootProject.file("docs/dokka-presets/assets/logo-icon.svg")}",
"${rootProject.file("docs/dokka-presets/assets/aws_logo_white_59x35.png")}"
],
"footerMessage": "© $year, Amazon Web Services, Inc. or its affiliates. All rights reserved.",
"separateInheritedMembers" : true
}
"""
)
pluginsMapConfiguration.set(pluginConfigMap)
}
}
val localProperties: Map<String, Any> by lazy {
val props = Properties()
listOf(
File(rootProject.projectDir, "local.properties"), // Project-specific local properties
File(rootProject.projectDir.parent, "local.properties"), // Workspace-specific local properties
File(System.getProperty("user.home"), ".sdkdev/local.properties"), // User-specific local properties
)
.filter(File::exists)
.map(File::inputStream)
.forEach(props::load)
props.mapKeys { (k, _) -> k.toString() }
}
fun Project.prop(name: String): Any? =
this.properties[name] ?: localProperties[name]
if (project.prop("kotlinWarningsAsErrors")?.toString()?.toBoolean() == true) {
subprojects {
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions.allWarningsAsErrors = true
}
}
}
// configure the root multimodule docs
tasks.dokkaHtmlMultiModule.configure {
moduleName.set("Smithy Kotlin")
// Output subprojects' docs to <docs-base>/project-name/* instead of <docs-base>/path/to/project-name/*
// This is especially important for inter-repo linking (e.g., via externalDocumentationLink) because the
// package-list doesn't contain enough project path information to indicate where modules' documentation are
// located.
fileLayout.set { parent, child -> parent.outputDirectory.get().resolve(child.project.name) }
includes.from(
// NOTE: these get concatenated
rootProject.file("docs/dokka-presets/README.md"),
)
val excludeFromDocumentation = listOf(
project(":runtime:testing"),
project(":runtime:smithy-test"),
)
removeChildTasks(excludeFromDocumentation)
}
apply(from = rootProject.file("gradle/codecoverage.gradle"))
if (
project.hasProperty("sonatypeUsername") &&
project.hasProperty("sonatypePassword") &&
project.hasProperty("publishGroupName")
) {
apply(plugin = "io.github.gradle-nexus.publish-plugin")
val publishGroupName = project.property("publishGroupName") as String
group = publishGroupName
nexusPublishing {
packageGroup.set(publishGroupName)
repositories {
create("awsNexus") {
nexusUrl.set(uri("https://aws.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://aws.oss.sonatype.org/content/repositories/snapshots/"))
username.set(project.property("sonatypeUsername") as String)
password.set(project.property("sonatypePassword") as String)
}
}
}
}
val ktlint by configurations.creating {
attributes {
attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling.EXTERNAL))
}
}
val ktlintVersion: String by project
dependencies {
ktlint("com.pinterest:ktlint:$ktlintVersion")
ktlint(project(":ktlint-rules"))
}
val lintPaths = listOf(
"smithy-kotlin-codegen/src/**/*.kt",
"runtime/**/*.kt",
"tests/**/jvm/**/*.kt",
)
tasks.register<JavaExec>("ktlint") {
description = "Check Kotlin code style."
group = "Verification"
classpath = configurations.getByName("ktlint")
main = "com.pinterest.ktlint.Main"
args = lintPaths
}
tasks.register<JavaExec>("ktlintFormat") {
description = "Auto fix Kotlin code style violations"
group = "formatting"
classpath = configurations.getByName("ktlint")
main = "com.pinterest.ktlint.Main"
args = listOf("-F") + lintPaths
}