-
Notifications
You must be signed in to change notification settings - Fork 9
/
build.gradle.kts
107 lines (95 loc) · 4.27 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
plugins {
idea
kotlin("jvm")
`maven-publish`
signing
}
BuildTools.mainProject = project
BuildProperties.printProperties()
// apply common configuration for this project and each sub project
allprojects {
group = "de.comahe.i18n4k"
version = "0.9.0"
repositories {
mavenLocal()
mavenCentral()
}
}
// apply common configuration for each sub project
subprojects {
// add signing and Maven publish to each project
apply<MavenPublishPlugin>()
val isSnapshot = version.toString().contains("SNAPSHOT");
if (loadSecretProperties(this)
&& ((isSnapshot && BuildProperties.publishSnapshots) || (!isSnapshot && BuildProperties.publishReleases))
) {
apply<SigningPlugin>()
// configure common things for signing and Maven publish for each project
afterEvaluate {
// need another `afterEvaluate` here, as some publications are added in an `afterEvaluate`
afterEvaluate {
// sign artifacts, see buildSrc/readme.md
signing {
publishing.publications.forEach { publication ->
sign(publication)
}
}
// publishing artifacts, see buildSrc/readme.md
publishing {
// Set Maven-Central repository
repositories {
maven {
url = uri(
if (isSnapshot)
"https://oss.sonatype.org/content/repositories/snapshots/"
else
"https://oss.sonatype.org/service/local/staging/deploy/maven2/"
)
println("###> Publishing to Maven repository: $url")
credentials {
username = project.property("sonatype.username").toString()
password = project.property("sonatype.password").toString()
}
}
}
// Update POM of all MavenPublication
publications {
publications.forEach { publication ->
if (publication !is MavenPublication)
return@forEach
publication.pom {
name.set(project.name)
description.set("i18n4k is a multiplatform (JVM, JS, native) library and code generator for Kotlin to handle internationalisation (i18n) in your program.")
url.set("https://comahe-de.github.io/i18n4k/")
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
developers {
developer {
id.set("comahe.de")
name.set("Marcel Heckel")
email.set("info@comahede")
}
}
scm {
connection.set("scm:[email protected]:comahe-de/i18n4k.git")
developerConnection.set("scm:[email protected]:comahe-de/i18n4k.git")
url.set("https://github.com/comahe-de/i18n4k")
}
}
}
}
}
// Fix Gradle error about signing tasks, using publishing task outputs without explicit dependencies
// https://github.com/gradle/gradle/issues/26091
tasks.withType<AbstractPublishToMaven>().configureEach {
val signingTasks = tasks.withType<Sign>()
mustRunAfter(signingTasks)
}
}
}
}
}