-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle.kts
151 lines (128 loc) · 4.12 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
import net.blueberrymc.gradle.buildSrc.Util.getBuildNumber
import net.blueberrymc.gradle.buildSrc.constants.KOTLIN_VERSION
import net.blueberrymc.gradle.buildSrc.constants.API_VERSION
import net.blueberrymc.gradle.buildSrc.constants.MINECRAFT_VERSION
plugins {
java
kotlin("jvm") version net.blueberrymc.gradle.buildSrc.constants.KOTLIN_VERSION
`maven-publish`
`java-library`
}
apply<net.blueberrymc.gradle.buildSrc.BuildPlugin>()
group = "net.blueberrymc"
version = "dev-SNAPSHOT"
repositories {
mavenCentral()
}
tasks {
register("printVersion") {
group = "blueberry"
doLast {
if (project.properties["BUILD_NUMBER"].toString().toLongOrNull() != null) {
println("$MINECRAFT_VERSION-${API_VERSION.replace("-SNAPSHOT", "")}.${getBuildNumber(project)}")
} else {
println("$MINECRAFT_VERSION-${API_VERSION.replace("-SNAPSHOT", "")}")
}
}
}
}
subprojects {
group = parent!!.group
apply {
plugin("java")
plugin("org.jetbrains.kotlin.jvm")
plugin("maven-publish")
plugin("java-library")
}
java {
withJavadocJar()
withSourcesJar()
}
val javaComponent = components["java"] as AdhocComponentWithVariants
javaComponent.withVariantsFromConfiguration(configurations["sourcesElements"]) {
skip()
}
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io"); name = "Jitpack" }
maven { url = uri("https://libraries.minecraft.net/"); name = "Minecraft" }
maven { url = uri("https://repo.spongepowered.org/maven/"); name = "Sponge Powered" }
maven { url = uri("https://repo.blueberrymc.net/repository/maven-public/"); name = "blueberrymc-repo" }
mavenLocal() // use mavenLocal to provide net.blueberrymc.minecraft:minecraft, for now.
}
dependencies {
implementation(kotlin("stdlib", KOTLIN_VERSION))
}
publishing {
publications {
create<MavenPublication>("mavenJava") {
from(components["java"])
}
}
repositories {
maven {
name = "blueberryRepo"
credentials(PasswordCredentials::class)
url = uri(
if (API_VERSION.endsWith("-SNAPSHOT"))
"https://repo.blueberrymc.net/repository/maven-snapshots/"
else
"https://repo.blueberrymc.net/repository/maven-releases/"
)
}
}
}
if (name == "blueberry") {
tasks.names.forEach { taskName ->
if (taskName.startsWith("publish")) {
tasks.named(taskName).get().enabled = false
}
}
}
}
allprojects {
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
}
tasks {
compileKotlin {
kotlinOptions.jvmTarget = "17"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "17"
}
javadoc {
options.encoding = "UTF-8"
}
compileJava {
options.compilerArgs.add("-Xmaxerrs")
options.compilerArgs.add("99999")
options.encoding = "UTF-8"
options.isDeprecation = true
}
test {
useJUnitPlatform()
}
processResources {
/*
from(sourceSets.main.get().resources.srcDirs) {
include("**")
val tokenReplacementMap = mapOf("version" to project.version)
filter<org.apache.tools.ant.filters.ReplaceTokens>("tokens" to tokenReplacementMap)
}
*/
filteringCharset = "UTF-8"
duplicatesStrategy = DuplicatesStrategy.INCLUDE
from(projectDir) { include("LICENSE") }
}
}
}
subprojects {
dependencies {
testImplementation("org.jetbrains.kotlin:kotlin-test-junit:$KOTLIN_VERSION")
testImplementation("org.junit.jupiter:junit-jupiter:5.8.0")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
}
}