-
Notifications
You must be signed in to change notification settings - Fork 118
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
134 lines (120 loc) · 4.5 KB
/
build.gradle.kts
File metadata and controls
134 lines (120 loc) · 4.5 KB
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
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
`maven-publish`
java
id("org.jetbrains.kotlin.jvm") version "1.8.22" apply false
id("com.github.johnrengelman.shadow") version "7.1.2" apply false
}
subprojects {
apply(plugin = "java-library")
apply(plugin = "org.jetbrains.kotlin.jvm")
apply(plugin = "com.github.johnrengelman.shadow")
apply(plugin = "maven-publish")
repositories {
maven("https://jitpack.io")
maven("https://libraries.minecraft.net")
maven("https://repo1.maven.org/maven2")
maven("https://maven.aliyun.com/repository/central")
maven("https://repo.codemc.io/repository/nms/")
maven("https://repo.tabooproject.org/repository/releases")
mavenLocal()
mavenCentral()
}
dependencies {
compileOnly(kotlin("stdlib"))
compileOnly("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3")
compileOnly("com.google.guava:guava:21.0")
compileOnly("com.google.code.gson:gson:2.8.7")
compileOnly("org.apache.commons:commons-lang3:3.5")
compileOnly("org.tabooproject.reflex:reflex:1.2.2")
compileOnly("org.tabooproject.reflex:analyser:1.2.2")
// 测试依赖
testImplementation(kotlin("stdlib"))
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3")
testImplementation("com.google.guava:guava:21.0")
testImplementation("com.google.code.gson:gson:2.8.7")
testImplementation("org.apache.commons:commons-lang3:3.5")
testImplementation("org.tabooproject.reflex:reflex:1.2.2")
testImplementation("org.tabooproject.reflex:analyser:1.2.2")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.1")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.1")
}
java {
withSourcesJar()
}
tasks.withType<Test> {
useJUnitPlatform()
}
tasks.withType<ShadowJar> {
archiveClassifier.set("")
relocate("org.tabooproject", "taboolib.library")
}
tasks.build {
dependsOn("shadowJar")
}
tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
options.compilerArgs.addAll(listOf("-XDenableSunApiLintControl"))
}
tasks.withType<KotlinCompile> {
kotlinOptions {
jvmTarget = "1.8"
freeCompilerArgs = listOf("-Xjvm-default=all")
}
}
configure<JavaPluginConvention> {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
}
gradle.buildFinished {
buildDir.deleteRecursively()
}
subprojects
.filter { it.name != "module" && it.name != "platform" && it.name != "expansion" && !it.name.startsWith("impl") }
.forEach { proj ->
proj.publishing { applyToSub(proj) }
}
fun PublishingExtension.applyToSub(subProject: Project) {
repositories {
maven("https://repo.tabooproject.org/repository/releases") {
credentials {
username = project.findProperty("taboolibUsername").toString()
password = project.findProperty("taboolibPassword").toString()
}
authentication {
create<BasicAuthentication>("basic")
}
}
// maven("http://repo.aeoliancloud.com/repository/releases") {
// isAllowInsecureProtocol = true
// credentials {
// username = project.findProperty("aeolianUsername").toString()
// password = project.findProperty("aeolianPassword").toString()
// }
// authentication {
// create<BasicAuthentication>("basic")
// }
// }
mavenLocal()
}
publications {
create<MavenPublication>("maven") {
// 构件名
artifactId = if (subProject.ext.has("publishId")) subProject.ext.get("publishId").toString() else subProject.name
// 组
groupId = "io.izzel.taboolib"
// 版本号
version = when {
project.hasProperty("devLocal") -> "${project.version}-local-dev"
project.hasProperty("dev") -> "${project.version}-dev"
else -> "${project.version}"
}
// 构件
artifact(subProject.tasks["kotlinSourcesJar"])
artifact(subProject.tasks["shadowJar"])
println("> Apply \"$groupId:$artifactId:$version\"")
}
}
}