-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
157 lines (133 loc) · 4.71 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
import com.vanniktech.maven.publish.SonatypeHost
import org.jetbrains.kotlin.gradle.plugin.extraProperties
import java.util.*
// Make sure these are always in sync
val javaVersion = JavaVersion.VERSION_17
val javaLanguageVersion: JavaLanguageVersion = JavaLanguageVersion.of(17)
val githubAuthor = "AniFichadia"
val githubRepo = "Figstract"
plugins {
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.kotlin.serialization)
alias(libs.plugins.shadow) apply false
alias(libs.plugins.dokka.core)
alias(libs.plugins.dokka.javadoc)
alias(libs.plugins.maven.publish)
`maven-publish`
signing
}
java {
toolchain {
languageVersion.set(javaLanguageVersion)
}
}
allprojects {
version = resolveVersion()
}
subprojects {
apply(plugin = "maven-publish")
apply(plugin = "signing")
apply(plugin = "org.jetbrains.dokka")
apply(plugin = "org.jetbrains.dokka-javadoc")
apply(plugin = "com.vanniktech.maven.publish")
tasks.withType(Test::class.java) {
useJUnitPlatform()
}
tasks.register("allDeps", DependencyReportTask::class)
//region Publishing
tasks.register<Jar>("sourceJar") {
archiveClassifier.set("sources")
from(sourceSets.main.get().allSource)
}
tasks.register<Jar>("javadocJar") {
archiveClassifier.set("javadoc")
from(tasks.javadoc)
}
dokka {
}
//region Property remappings
remapSystemPropertyProperty("GPG_PRIVATE_KEY", "ORG_GRADLE_PROJECT_signingInMemoryKey")
remapSystemPropertyProperty("GPG_PRIVATE_KEY", "signingInMemoryKey")
remapSystemPropertyProperty("GPG_KEY_PASSWORD", "ORG_GRADLE_PROJECT_signingInMemoryKeyPassword")
remapSystemPropertyProperty("GPG_KEY_PASSWORD", "signingInMemoryKeyPassword")
//endregion
publishing {
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/AniFichadia/Figstract")
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}
}
}
mavenPublishing {
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)
signAllPublications()
pom {
name.set(project.name)
description.set("Figstract bridges the process for maintaining design systems (in Figma) between frontend engineers and designers and helps automate mundane upkeep tasks.")
url.set("https://github.com/$githubAuthor/$githubRepo")
developers {
developer {
id = "AniFichadia"
name = "Aniruddh Fichadia"
email = "[email protected]"
}
}
licenses {
license {
name = "$githubRepo license"
url = "https://github.com/$githubAuthor/$githubRepo/blob/main/LICENSE"
}
}
scm {
connection.set("scm:git:git://github.com/$githubAuthor/$githubRepo.git")
developerConnection.set("scm:git:ssh://github.com/$githubAuthor/$githubRepo.git")
url.set("https://github.com/$githubAuthor/$githubRepo")
}
}
}
// Note: this should be after publishing to override any previously applied signing configs from publishing plugins
signing {
val encodedKey = System.getenv("GPG_PRIVATE_KEY")
val signingKey: String? = encodedKey?.let { String(Base64.getDecoder().decode(it)) }
val signingPassword: String? = System.getenv("GPG_KEY_PASSWORD")
if (!signingKey.isNullOrBlank() && !signingPassword.isNullOrBlank()) {
useInMemoryPgpKeys(
signingKey,
signingPassword,
)
sign(publishing.publications)
}
}
//endregion
}
fun Project.resolveVersion(): String {
val originalVersionName = property("VERSION").toString()
val isSnapshot = System.getenv("IS_SNAPSHOT")?.toBooleanStrictOrNull()
return if (isSnapshot == true) {
"$originalVersionName-SNAPSHOT"
} else {
originalVersionName
}
}
fun Project.remapSystemPropertyProperty(
originalName: String,
newName: String,
map: (String) -> String = { it },
) {
val project = this
System.getenv(originalName)
?.let(map)
?.let {
System.setProperty(newName, it)
// project.setProperty(newName, it)
project.extraProperties.set(newName, it)
project.extra[newName] = it
// project.extensions.extraProperties.set(newName, it)
// project.extensions.extraProperties[newName] = it
}
}