File tree Expand file tree Collapse file tree 4 files changed +36
-11
lines changed
Expand file tree Collapse file tree 4 files changed +36
-11
lines changed Original file line number Diff line number Diff line change 1+ import org.jetbrains.gradle.ext.settings
2+ import org.jetbrains.gradle.ext.taskTriggers
13import java.time.OffsetDateTime
24import java.time.ZoneOffset
35
46plugins {
57 java
6- id(" net.raphimc.class-token-replacer" ) version(" 1.1.4" )
7- idea
8+ id(" org.jetbrains.gradle.plugin.idea-ext" ) version " 1.1.10"
89}
910
1011group = properties[" maven_group" ] as String
@@ -81,6 +82,24 @@ tasks {
8182 dependsOn(copyPluginTask)
8283 }
8384
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+
84103 jar {
85104 manifest { // metadata about the plugin build
86105 attributes(mapOf (
@@ -92,14 +111,6 @@ tasks {
92111 }
93112}
94113
95- sourceSets {
96- main {
97- classTokenReplacer {
98- property(" \$ {version}" , project.version)
99- }
100- }
101- }
102-
103114idea {
104115 module {
105116 excludeDirs.add(runDirectory.asFile)
Original file line number Diff line number Diff line change 1+ pluginManagement {
2+ repositories {
3+ mavenLocal()
4+ gradlePluginPortal()
5+ }
6+ }
7+
18rootProject.name = " ZenithProxyExamplePlugin"
Original file line number Diff line number Diff line change 1111
1212@ Plugin (
1313 id = "example-plugin" ,
14- version = "${version}" ,
14+ version = BuildConstants . VERSION ,
1515 description = "ZenithProxy Example Plugin" ,
1616 url = "https://github.com/rfresh2/ZenithProxyExamplePlugin" ,
1717 authors = {"rfresh2" },
Original file line number Diff line number Diff line change 1+ package org .example ;
2+
3+ // The constants are replaced before compilation
4+ public class BuildConstants {
5+
6+ public static final String VERSION = "${version}" ;
7+ }
You can’t perform that action at this time.
0 commit comments