-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
132 lines (112 loc) · 3.88 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
import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.net.URI
plugins {
`java-library`
`maven-publish`
signing
kotlin("jvm") version "1.5.21"
id("org.jetbrains.dokka") version "1.5.0"
}
group = "dev.thecodewarrior"
val library_version: String by project
val snapshotVersion = System.getenv("SNAPSHOT_REF")?.let { ref ->
if(!ref.startsWith("refs/heads/"))
throw IllegalStateException("SNAPSHOT_REF `$ref` doesn't start with refs/heads/")
ref.removePrefix("refs/heads/").replace("[^.\\w-]".toRegex(), "-") + "-SNAPSHOT"
}
val mirror_version = snapshotVersion ?: library_version
version = mirror_version
repositories {
mavenCentral()
jcenter()
}
dependencies {
implementation(kotlin("reflect"))
testImplementation("org.junit.jupiter:junit-jupiter-api:5.6.0")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.6.0")
testImplementation("io.mockk:mockk:1.10.0")
}
kotlin {
explicitApi()
}
tasks.withType<KotlinCompile> {
kotlinOptions {
jvmTarget = "1.8"
javaParameters = true
freeCompilerArgs = freeCompilerArgs + listOf("-Xjvm-default=all", "-Xinline-classes")
}
}
tasks.withType<JavaCompile> {
options.compilerArgs.add("-parameters")
}
tasks.withType<Test> {
useJUnitPlatform()
}
// ---------------------------------------------------------------------------------------------------------------------
//region // Publishing
tasks.register<Jar>("javadocJar") {
archiveClassifier.set("javadoc")
from(tasks.named("dokkaJavadoc"))
}
java {
withSourcesJar()
withJavadocJar()
}
publishing {
publications {
register<MavenPublication>("maven") {
from(components["java"])
pom {
name.set("Mirror")
description.set("Advanced reflection made accessible")
url.set("https://github.com/thecodewarrior/Mirror")
licenses {
license {
name.set("BSD-2-Clause")
url.set("https://opensource.org/licenses/BSD-2-Clause")
}
}
developers {
developer {
id.set("thecodewarrior")
name.set("Pierce Corcoran")
email.set("[email protected]")
url.set("https://thecodewarrior.dev")
}
}
scm {
connection.set("scm:git:https://github.com/thecodewarrior/Mirror.git")
developerConnection.set("scm:git:ssh://github.com:thecodewarrior/Mirror.git")
url.set("https://github.com/thecodewarrior/Mirror")
}
}
}
}
repositories {
maven {
name = "ossrh"
val stagingRepo = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
val snapshotRepo = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
url = URI(if(mirror_version.endsWith("SNAPSHOT")) snapshotRepo else stagingRepo)
credentials {
username = project.findProperty("ossrhUsername") as String? ?: System.getenv("OSSRH_USERNAME") ?: "N/A"
password = project.findProperty("ossrhPassword") as String? ?: System.getenv("OSSRH_PASSWORD") ?: "N/A"
}
}
}
}
signing {
if(System.getenv("SIGNING_KEY") != null) {
useInMemoryPgpKeys(
System.getenv("SIGNING_KEY_ID"),
System.getenv("SIGNING_KEY"),
System.getenv("SIGNING_KEY_PASSWORD")
)
} else {
useGpgCmd()
}
sign(publishing.publications["maven"])
}
//endregion // Publishing
// ---------------------------------------------------------------------------------------------------------------------