-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle.kts
75 lines (63 loc) · 1.99 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
import java.io.ByteArrayOutputStream
plugins {
id("java-library")
id("maven-publish")
}
fun getGitCommit(): String {
val stdout = ByteArrayOutputStream()
exec {
commandLine("git", "rev-parse", "--short", "HEAD")
standardOutput = stdout
}
return stdout.toString().trim()
}
tasks["jar"].enabled = false
subprojects {
apply<JavaLibraryPlugin>()
apply<MavenPublishPlugin>()
version = "1.4.3+${getGitCommit()}"
group = "dev.booky"
repositories {
mavenCentral()
maven("https://maven.fabricmc.net/")
maven("https://libraries.minecraft.net/")
}
java {
withSourcesJar()
toolchain {
languageVersion = JavaLanguageVersion.of(17)
vendor = JvmVendorSpec.ADOPTIUM
}
}
publishing {
publications.create<MavenPublication>("maven") {
artifactId = project.name.lowercase()
from(components["java"])
}
if (rootProject.ext.has("publishingRepo")) {
val publishingRepo = rootProject.ext.get("publishingRepo") as String
repositories.maven(publishingRepo) {
name = url.host.replace(".", "")
authentication { create<BasicAuthentication>("basic") }
credentials(PasswordCredentials::class)
}
}
}
tasks {
withType<JavaCompile> {
options.encoding = Charsets.UTF_8.name()
options.release = 17
}
withType<Jar>().configureEach {
destinationDirectory = rootProject.layout.buildDirectory.dir("libs")
archiveBaseName = project.name.replace("-", "")
sequenceOf("COPYING", "COPYING.LESSER")
.map { rootProject.layout.projectDirectory.file(it) }
.forEach { sourceFile ->
from(sourceFile) {
rename { return@rename "${it}_${rootProject.name.lowercase()}" }
}
}
}
}
}