forked from streem/pbandk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
109 lines (96 loc) · 3.8 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
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
// Top-level build configuration
plugins {
kotlin("multiplatform") version Versions.kotlin apply false
id("com.android.library") version Versions.androidGradlePlugin apply false
id("org.springframework.boot") version Versions.springBootGradlePlugin apply false
id("binary-compatibility-validator") version Versions.binaryCompatibilityValidatorGradlePlugin apply false
id("com.google.osdetector") version Versions.osDetectorGradlePlugin
}
val sonatypeApiUser = providers.gradlePropertyOrEnvironmentVariable("sonatypeApiUser")
val sonatypeApiKey = providers.gradlePropertyOrEnvironmentVariable("sonatypeApiKey")
val sonatypeRepositoryId = providers.gradlePropertyOrEnvironmentVariable("sonatypeRepositoryId")
val publishToSonatype = sonatypeApiUser.isPresent && sonatypeApiKey.isPresent
if (!publishToSonatype) {
logger.info("Sonatype API key not defined, skipping configuration of Maven Central publishing repository")
}
val signingKeyAsciiArmored = providers.gradlePropertyOrEnvironmentVariable("signingKeyAsciiArmored")
if (signingKeyAsciiArmored.isPresent) {
subprojects {
plugins.withType<SigningPlugin> {
configure<SigningExtension> {
@Suppress("UnstableApiUsage")
useInMemoryPgpKeys(signingKeyAsciiArmored.get(), "")
sign(extensions.getByType<PublishingExtension>().publications)
}
}
}
} else {
logger.info("PGP signing key not defined, skipping signing configuration")
}
val downloadProtoc by configurations.creating {
isTransitive = false
}
val wellKnownTypes by configurations.creating {
isTransitive = false
}
dependencies {
downloadProtoc(
group = "com.google.protobuf",
name = "protoc",
version = Versions.protoc,
classifier = osdetector.classifier,
ext = "exe"
)
wellKnownTypes("com.google.protobuf:protobuf-java:${Versions.protobufJava}")
}
val extractWellKnownTypeProtos by tasks.registering(Sync::class) {
dependsOn(wellKnownTypes)
from({
wellKnownTypes.filter { it.extension == "jar" }.map { zipTree(it) }
})
include("**/*.proto")
includeEmptyDirs = false
into(layout.buildDirectory.dir("bundled-protos"))
}
allprojects {
repositories {
mavenCentral()
}
tasks.withType<AbstractTestTask> {
testLogging {
outputs.upToDateWhen { false }
showStandardStreams = true
exceptionFormat = TestExceptionFormat.FULL
events = setOf(
TestLogEvent.PASSED,
TestLogEvent.SKIPPED,
TestLogEvent.FAILED
)
}
}
if (publishToSonatype) {
plugins.withType<MavenPublishPlugin>() {
configure<PublishingExtension> {
repositories {
maven {
name = "sonatype"
url = when {
project.version.toString().endsWith("-SNAPSHOT") ->
uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
!sonatypeRepositoryId.isPresent ->
throw IllegalStateException("Sonatype Repository ID must be provided for non-SNAPSHOT builds")
else ->
uri("https://s01.oss.sonatype.org/service/local/staging/deployByRepositoryId/${sonatypeRepositoryId.get()}")
}
credentials {
username = sonatypeApiUser.get()
password = sonatypeApiKey.get()
}
}
}
}
}
}
}