-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle.kts
123 lines (104 loc) · 3.82 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
import io.papermc.hangarpublishplugin.model.Platforms
import org.sonarqube.gradle.SonarQubePlugin
import org.sonarqube.gradle.SonarTask
plugins {
id("java-library")
id("maven-publish")
id("com.github.johnrengelman.shadow") version "8.1.1"
id("io.papermc.hangar-publish-plugin") version "0.1.2"
id("apartium-maven-publish")
id("org.sonarqube") version "5.1.0.4882"
jacoco
}
val releaseWorkflow = "PoweredByApartium/cocoa-beans/.github/workflows/release.yml"
val snapshot: Boolean = System.getenv("GITHUB_WORKFLOW_REF") == null || !(System.getenv("GITHUB_WORKFLOW_REF").startsWith(releaseWorkflow))
val isCi = System.getenv("GITHUB_ACTOR") != null
group = "net.apartium.cocoa-beans"
version = (if (System.getenv("VERSION") == null) "dev" else System.getenv("VERSION")) + (if (snapshot) "-SNAPSHOT" else "")
allprojects {
apply<JavaLibraryPlugin>()
apply<MavenPublishPlugin>()
apply<JacocoPlugin>()
apply<SonarQubePlugin>()
publishing {
repositories {
if (isCi) {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/poweredbyapartium/cocoa-beans")
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}
}
if (isCi || project.findProperty("apartium.nexus.username") != null) {
maven {
name = "ApartiumMaven"
url = uri("https://nexus.voigon.dev/repository/apartium-releases")
credentials {
username = (System.getenv("APARTIUM_NEXUS_USERNAME")
?: project.findProperty("apartium.nexus.username")).toString()
password = (System.getenv("APARTIUM_NEXUS_PASSWORD")
?: project.findProperty("apartium.nexus.password")).toString()
}
}
}
}
}
repositories {
maven {
name = "ApartiumNexus"
url = uri("https://nexus.voigon.dev/repository/apartium")
}
}
dependencies {
compileOnlyApi("com.fasterxml.jackson.core:jackson-annotations:${findProperty("versions.jackson.annotations")}")
compileOnly("org.jetbrains:annotations:${findProperty("versions.jetbrains.annotations")}")
}
tasks {
test {
useJUnitPlatform()
}
}
tasks.withType<JacocoReport> {
dependsOn(tasks.test)
reports {
xml.required = true
}
}
tasks.withType<SonarTask> {
dependsOn(tasks.test)
dependsOn(tasks.jacocoTestReport)
}
sonar {
properties {
if (isCi) {
val tokenFromEnv = System.getenv("SONAR_PROP_TOKEN") ?: throw RuntimeException("sonar.token is not set")
if (tokenFromEnv.isEmpty())
throw RuntimeException("sonar.token cannot be empty")
property("sonar.token", tokenFromEnv)
} else {
property("sonar.token", project.findProperty("apartium.sonar.token").toString())
}
}
}
}
hangarPublish {
publications.register("plugin") {
version = project.version as String
if (snapshot) {
channel.set("Snapshot")
} else {
channel.set("Release")
}
apiKey = System.getenv("HANGAR_TOKEN") ?: project.findProperty("hangar.token.key").toString()
id.set("CocoaBeans")
platforms {
register(Platforms.PAPER) {
jar.set(project(":plugin").tasks.shadowJar.flatMap { it.archiveFile })
platformVersions = listOf("1.17", "1.19", "1.20")
}
}
}
}