-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
163 lines (134 loc) · 4.58 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.net.URI
val isSnapshot = true
group = "dev.reactant"
version = "0.2.0${if (isSnapshot) "-SNAPSHOT" else ""}"
val kotlinVersion = "1.3.72"
plugins {
java
`maven-publish`
signing
kotlin("jvm") version "1.3.72"
id("com.github.johnrengelman.shadow") version "5.0.0"
id("org.jetbrains.dokka") version "0.10.0"
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
kotlinOptions.freeCompilerArgs = listOf("-Xjvm-default=compatibility")
}
repositories {
jcenter()
mavenCentral()
maven { url = URI.create("https://hub.spigotmc.org/nexus/content/repositories/snapshots") }
maven { url = URI.create("https://repo.dmulloy2.net/nexus/repository/public/") }
maven { url = URI.create("https://oss.sonatype.org/content/repositories/snapshots/") }
}
dependencies {
compileOnly(kotlin("stdlib-jdk8", kotlinVersion))
compileOnly("dev.reactant:reactant:0.2.0-SNAPSHOT")
compileOnly("org.xerial:sqlite-jdbc:3.30.1")
compileOnly("com.comphenix.protocol:ProtocolLib:4.5.0")
compileOnly("com.comphenix.packetwrapper:PacketWrapper:1.13-R0.1-SNAPSHOT")
compileOnly("org.spigotmc:spigot-api:1.15.2-R0.1-SNAPSHOT")
}
val dokka = (tasks["dokka"] as DokkaTask).apply {
outputFormat = "html"
}
val dokkaJavadoc by tasks.registering(DokkaTask::class) {
outputFormat = "javadoc"
outputDirectory = "$buildDir/javadoc"
}
val dokkaJar by tasks.registering(Jar::class) {
dependsOn(dokka)
archiveClassifier.set("dokka")
from(tasks.dokka)
}
val javadocJar by tasks.registering(Jar::class) {
dependsOn(dokkaJavadoc)
archiveClassifier.set("javadoc")
from(tasks.javadoc)
}
val sourcesJar by tasks.registering(Jar::class) {
dependsOn(JavaPlugin.CLASSES_TASK_NAME)
archiveClassifier.set("sources")
from(sourceSets.main.get().allSource)
}
val shadowJar = (tasks["shadowJar"] as ShadowJar).apply {
relocate("org.from.package", "org.target.package")
}
val deployPlugin by tasks.registering(Copy::class) {
dependsOn(shadowJar)
System.getenv("PLUGIN_DEPLOY_PATH")?.let {
from(shadowJar)
into(it)
}
}
val build = (tasks["build"] as Task).apply {
arrayOf(
sourcesJar
, shadowJar
, deployPlugin
).forEach { dependsOn(it) }
}
publishing {
publications {
create<MavenPublication>("maven") {
from(components["java"])
artifact(sourcesJar.get())
artifact(shadowJar)
artifact(javadocJar.get())
artifact(dokkaJar.get())
groupId = group.toString()
artifactId = project.name
version = version
pom {
name.set(project.name)
description.set("Interactive block & machine library for Reactant")
url.set("https://reactant.dev")
licenses {
license {
name.set("GPL-3.0")
url.set("https://www.gnu.org/licenses/gpl-3.0.txt")
}
}
scm {
connection.set("scm:git:[email protected]:reactant/mechanism.git")
url.set("https://gitlab.com/reactant/mechanism/")
}
developers {
developer {
id.set("setako")
name.set("Setako")
organization.set("Reactant Dev Team")
organizationUrl.set("https://gitlab.com/reactant")
}
}
}
}
}
repositories {
maven {
val releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2"
val snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots"
url = uri(if (version.toString().endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl)
credentials {
username = System.getenv("SONATYPE_USERNAME")
password = System.getenv("SONATYPE_PASSWORD")
}
}
}
}
if (!isSnapshot) {
signing {
val signingKey: String? by project
val signingPassword: String? by project
useInMemoryPgpKeys(signingKey?.replace("\\n", "\n"), signingPassword)
sign(publishing.publications["maven"])
}
}