|
1 | | -import org.jetbrains.gradle.ext.settings |
2 | | -import org.jetbrains.gradle.ext.taskTriggers |
3 | | -import java.time.OffsetDateTime |
4 | | -import java.time.ZoneOffset |
5 | | - |
6 | 1 | plugins { |
7 | 2 | java |
8 | | - id("org.jetbrains.gradle.plugin.idea-ext") version "1.1.10" |
| 3 | + id("zenithproxy-dev") version "1.0.0-SNAPSHOT" |
9 | 4 | } |
10 | 5 |
|
11 | 6 | group = properties["maven_group"] as String |
12 | 7 | version = properties["plugin_version"] as String |
13 | | -val mc: String by properties |
14 | | - |
15 | | -val javaVersion = JavaLanguageVersion.of(23) // the java version used for development |
16 | | -val javaReleaseVersion = JavaLanguageVersion.of(21) // the java version of the compiled plugin jar |
17 | | -java { toolchain { languageVersion = javaVersion } } |
18 | | - |
19 | | -repositories { |
20 | | - mavenLocal() |
21 | | - maven("https://maven.2b2t.vc/releases") |
22 | | - maven("https://libraries.minecraft.net") { |
23 | | - content { includeGroup("com.mojang") } |
24 | | - } |
25 | | - maven("https://repo.opencollab.dev/maven-releases/") { |
26 | | - content { includeGroupByRegex("org.cloudburstmc.*") } |
27 | | - } |
28 | | - maven("https://repo.papermc.io/repository/maven-public/") { |
29 | | - content { includeGroup("com.velocitypowered") } |
30 | | - } |
31 | | - maven("https://repo.viaversion.com") { |
32 | | - content { |
33 | | - includeGroup("com.viaversion") |
34 | | - includeGroup("net.raphimc") |
35 | | - } |
36 | | - } |
37 | | - maven("https://maven.lenni0451.net/releases") { |
38 | | - content { |
39 | | - includeGroup("net.raphimc") |
40 | | - includeGroup("net.lenni0451") |
41 | | - } |
42 | | - } |
43 | | - mavenCentral() |
44 | | -} |
45 | | - |
46 | | -dependencies { |
47 | | - implementation(annotationProcessor("com.zenith:ZenithProxy:${mc}-SNAPSHOT")!!) |
48 | | -} |
49 | | - |
50 | | -val runDirectory = layout.projectDirectory.dir("run") |
51 | 8 |
|
52 | | -tasks { |
53 | | - withType(JavaCompile::class.java) { |
54 | | - options.encoding = "UTF-8" |
55 | | - options.isDeprecation = true |
56 | | - options.release = javaReleaseVersion.asInt() |
57 | | - } |
58 | | - |
59 | | - val copyPluginTask = register("copyPlugin", Copy::class.java) { |
60 | | - group = "build" |
61 | | - description = "Copy Plugin To ZenithProxy" |
62 | | - from(layout.buildDirectory.dir("libs")) { |
63 | | - include("*.jar") |
64 | | - rename("(.*)", "plugin.jar") |
65 | | - } |
66 | | - into(runDirectory.dir("plugins")) |
67 | | - dependsOn(build) |
68 | | - } |
69 | | - |
70 | | - register("run", JavaExec::class.java) { |
71 | | - group = "build" |
72 | | - description = "Execute ZenithProxy With Plugin" |
73 | | - classpath = sourceSets.main.get().runtimeClasspath |
74 | | - // filter out duplicate classpath entries |
75 | | - // we want zenith to load our plugin classes from the run directory like it would in prod |
76 | | - .filter { !it.path.contains(layout.buildDirectory.asFile.get().path) } |
77 | | - workingDir = runDirectory.asFile |
78 | | - mainClass.set("com.zenith.Proxy") |
79 | | - jvmArgs = listOf("-Xmx300m", "-XX:+UseG1GC") |
80 | | - standardInput = System.`in` |
81 | | - environment("ZENITH_DEV", "true") |
82 | | - dependsOn(copyPluginTask) |
83 | | - } |
84 | | - |
85 | | - val templateTask = register("generateTemplates", Copy::class.java) { |
86 | | - group = "build" |
87 | | - description = "Generates class templates" |
88 | | - val props = mapOf( |
89 | | - "version" to project.version |
90 | | - ) |
91 | | - inputs.properties(props) |
92 | | - from(file("src/main/templates")) |
93 | | - into(layout.buildDirectory.dir("generated/sources/templates")) |
94 | | - expand(props) |
95 | | - } |
96 | | - sourceSets.main.get().java.srcDir(templateTask.map { it.outputs }) |
97 | | - project.idea.project.settings.taskTriggers.afterSync(templateTask) |
98 | | - |
99 | | - compileJava { |
100 | | - dependsOn(templateTask) |
101 | | - } |
102 | | - |
103 | | - jar { |
104 | | - manifest { // metadata about the plugin build |
105 | | - attributes(mapOf( |
106 | | - "Date" to OffsetDateTime.now().withOffsetSameInstant(ZoneOffset.UTC).toString(), |
107 | | - "Java-Version" to javaReleaseVersion, |
108 | | - "MC-Version" to mc |
109 | | - )) |
110 | | - } |
111 | | - } |
112 | | -} |
| 9 | +java { toolchain { languageVersion = JavaLanguageVersion.of(23) } } |
113 | 10 |
|
114 | | -idea { |
115 | | - module { |
116 | | - excludeDirs.add(runDirectory.asFile) |
117 | | - excludeDirs.add(layout.projectDirectory.dir(".idea").asFile) |
118 | | - } |
| 11 | +zenithProxy { |
| 12 | + mc = properties["mc"] as String |
119 | 13 | } |
0 commit comments