-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
145 lines (121 loc) · 3.94 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
@file:Suppress("UnstableApiUsage")
plugins {
`java-library`
`maven-publish`
signing
id("io.github.gradle-nexus.publish-plugin") version "1.+"
id("me.champeau.jmh") version "0.6.+"
}
group = "enterprises.stardust"
version = "0.0.1-SNAPSHOT"
repositories {
mavenCentral()
}
dependencies {
implementation("org.jetbrains", "annotations", "24.0.1")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.2")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.9.2")
}
java {
withJavadocJar()
withSourcesJar()
toolchain {
languageVersion.set(JavaLanguageVersion.of(8))
}
}
tasks {
getByName<Test>("test") {
useJUnitPlatform()
}
val apiJar = create("apiJar", Jar::class.java) {
archiveClassifier.set("api")
from(sourceSets["main"].output)
exclude("enterprises/stardust/interstellair/impl")
exclude("enterprises/stardust/interstellair/impl/**/*")
manifest.attributes(
"Specification-Title" to project.name,
"Specification-Version" to "1",
"Specification-Vendor" to "Stardust Enterprises",
)
}
jar {
manifest.attributes += apiJar.manifest.attributes
manifest.attributes(
"Implementation-Title" to project.name,
"Implementation-Version" to project.version,
"Implementation-Vendor" to "Stardust Enterprises",
)
}
afterEvaluate {
// Task priority
val publishToSonatype by getting
val closeAndReleaseSonatypeStagingRepository by getting
closeAndReleaseSonatypeStagingRepository
.mustRunAfter(publishToSonatype)
// Wrapper task since calling both one after the other in IntelliJ
// seems to cause some problems.
create("releaseToSonatype") {
group = "publishing"
dependsOn(
publishToSonatype,
closeAndReleaseSonatypeStagingRepository
)
}
}
}
val artifactTasks = arrayOf(
tasks["apiJar"],
)
artifacts {
artifactTasks.forEach {
add("archives", it)
}
}
val projectName: String = project.name
val desc = "A Java Stream API near drop-in alternative designed around simplicity and efficiency"
val repo = "stardust-enterprises/$projectName"
publishing.publications {
create<MavenPublication>("mavenJava") {
from(components["java"])
artifactTasks.forEach(::artifact)
pom {
name.set(projectName)
description.set(desc)
url.set("https://github.com/$repo")
licenses {
license {
name.set("ISC License")
url.set("https://opensource.org/licenses/ISC")
distribution.set("repo")
}
}
developers {
developer {
id.set("xtrm")
name.set("xtrm")
email.set("[email protected]")
}
}
scm {
connection.set("scm:git:git://github.com/$repo.git")
developerConnection.set("scm:git:ssh://github.com/$repo.git")
url.set("https://github.com/$repo")
}
}
// Configure the signing extension to sign this Maven artifact.
signing {
isRequired = project.properties["signing.keyId"] != null
sign(this@create)
}
}
}
// Set up the Sonatype artifact publishing.
nexusPublishing.repositories.sonatype {
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(
uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
)
// Skip this step if environment variables NEXUS_USERNAME or NEXUS_PASSWORD aren't set.
username.set(properties["NEXUS_USERNAME"] as? String ?: return@sonatype)
password.set(properties["NEXUS_PASSWORD"] as? String ?: return@sonatype)
}