-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
89 lines (75 loc) · 2.56 KB
/
Copy pathbuild.gradle.kts
File metadata and controls
89 lines (75 loc) · 2.56 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
import org.jetbrains.gradle.ext.settings
import org.jetbrains.gradle.ext.taskTriggers
val pluginId: String by project
val pluginName: String by project
val pluginGroup: String by project
val pluginLicense: String by project
val pluginUrl: String by project
val pluginVersion: String by project
val pluginAuthors: String by project
val pluginDescription: String by project
group = pluginGroup
version = pluginVersion
plugins {
java
eclipse
idea
id("com.github.johnrengelman.shadow") version "7.1.2"
id("org.jetbrains.gradle.plugin.idea-ext") version "1.1.7"
}
repositories {
maven { url = uri("https://maven.aliyun.com/repository/public/") }
maven { url = uri("https://maven.aliyun.com/repository/spring/") }
maven("papermc-repo") { url = uri("https://repo.papermc.io/repository/maven-public/") }
maven("sonatype") { url = uri("https://oss.sonatype.org/content/groups/public/") }
maven("jitpack") { url = uri("https://jitpack.io") }
mavenCentral()
}
dependencies {
implementation("com.github.dsx137:jable:1.0.11")
compileOnly("org.projectlombok:lombok:1.18.20")
annotationProcessor("org.projectlombok:lombok:1.18.20")
compileOnly("com.velocitypowered:velocity-api:3.3.0-SNAPSHOT")
annotationProcessor("com.velocitypowered:velocity-api:3.3.0-SNAPSHOT")
}
java {
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
}
val templateSource = file("src/main/templates")
val templateDest = layout.buildDirectory.dir("generated/sources/templates")
val generateTemplates by tasks.registering(Copy::class) {
val props = mapOf(
"plugin_id" to pluginId,
"plugin_name" to pluginName,
"plugin_group" to pluginGroup,
"plugin_version" to pluginVersion,
"plugin_authors" to pluginAuthors,
"plugin_url" to pluginUrl,
"plugin_description" to pluginDescription
)
inputs.properties(props)
from(templateSource)
into(templateDest)
expand(props)
}
// 将生成的模板文件夹添加到源文件夹中
sourceSets["main"].java.srcDirs(generateTemplates.map { it.destinationDir })
// 当Gradle项目的构建文件有更改并重新导入到IDE中时自动运行generateTemplates任务
rootProject.idea.project.settings.taskTriggers.afterSync(generateTemplates)
project.eclipse.synchronizationTasks(generateTemplates)
tasks.jar {
manifest {
attributes(
"Implementation-Title" to pluginName,
"Implementation-Version" to pluginVersion
)
}
}
tasks {
shadowJar {
minimize()
}
}
tasks.build {
dependsOn("shadowJar")
}