1
+ // ONLY < neoforge-1.21.0
2
+ // RENAME build.gradle
3
+ plugins {
4
+ id ' java-library'
5
+ id ' eclipse'
6
+ id ' idea'
7
+ id ' maven-publish'
8
+ id ' net.neoforged.gradle.userdev' version ' 7.0.164'
9
+ }
10
+
11
+ def getVersionFromFile (String f ) {
12
+ def versionFile = file(f)
13
+ if (versionFile. exists()) {
14
+ return versionFile. text. trim()
15
+ } else {
16
+ throw new Exception (" Version file not found: ${ versionFile.absolutePath} " ) as Throwable
17
+ }
18
+ }
19
+
20
+ def code_version = getVersionFromFile(' ../../code_version.txt' )
21
+ def mod_version = getVersionFromFile(' ../../version.txt' )
22
+ version = mod_version + " +" + project. minecraft_version + " +neoforge"
23
+ group = mod_group_id
24
+
25
+ repositories {
26
+ mavenLocal()
27
+ mavenCentral()
28
+ flatDir {
29
+ dirs ' libs'
30
+ }
31
+ maven {
32
+ url " https://mvn.cloud.alipay.com/nexus/content/repositories/open/"
33
+ }
34
+
35
+ maven {
36
+ url ' https://maven.aliyun.com/nexus/content/groups/public/'
37
+ }
38
+
39
+ maven {
40
+ url ' https://maven.aliyun.com/nexus/content/repositories/google'
41
+ }
42
+ maven {
43
+ name " kituinMavenReleases"
44
+ url " https://maven.kituin.fun/releases"
45
+ }
46
+ }
47
+
48
+ base {
49
+ archivesName = mod_name
50
+ }
51
+ javadoc {
52
+ options. addStringOption(" tag" , " date:a:Date:" )
53
+ options. addStringOption(" charset" , " UTF-8" )
54
+ options. addStringOption(" encoding" , " UTF-8" )
55
+ if (JavaVersion . current(). isJava9Compatible()) {
56
+ options. addBooleanOption(' html5' , true )
57
+ }
58
+ }
59
+ // Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17.
60
+ java {
61
+ toolchain{
62
+ languageVersion = JavaLanguageVersion . of(project. targetJavaVersion)
63
+ }
64
+ withSourcesJar()
65
+ // withJavadocJar()
66
+ }
67
+
68
+ jarJar. enable()
69
+ tasks. named(' jarJar' ) {
70
+ archiveClassifier. set(' ' )
71
+ destinationDirectory = file(" ../../ChatImage-jar/${ mod_version} " )
72
+ }
73
+ // minecraft.accessTransformers.file rootProject.file('src/main/resources/META-INF/accesstransformer.cfg')
74
+ // minecraft.accessTransformers.entry public net.minecraft.client.Minecraft textureManager # textureManager
75
+
76
+ // Default run configurations.
77
+ // These can be tweaked, removed, or duplicated as needed.
78
+ runs {
79
+ // applies to all the run configs below
80
+ configureEach {
81
+ // Recommended logging data for a userdev environment
82
+ // The markers can be added/remove as needed separated by commas.
83
+ // "SCAN": For mods scan.
84
+ // "REGISTRIES": For firing of registry events.
85
+ // "REGISTRYDUMP": For getting the contents of all registries.
86
+ systemProperty ' forge.logging.markers' , ' REGISTRIES'
87
+
88
+ // Recommended logging level for the console
89
+ // You can set various levels here.
90
+ // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
91
+ systemProperty ' forge.logging.console.level' , ' debug'
92
+
93
+ modSource project. sourceSets. main
94
+ }
95
+
96
+ client {
97
+ // Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
98
+ systemProperty ' forge.enabledGameTestNamespaces' , project. mod_id
99
+ }
100
+
101
+ server {
102
+ systemProperty ' forge.enabledGameTestNamespaces' , project. mod_id
103
+ programArgument ' --nogui'
104
+ }
105
+
106
+ // This run config launches GameTestServer and runs all registered gametests, then exits.
107
+ // By default, the server will crash when no gametests are provided.
108
+ // The gametest system is also enabled by default for other run configs under the /test command.
109
+ gameTestServer {
110
+ systemProperty ' forge.enabledGameTestNamespaces' , project. mod_id
111
+ }
112
+
113
+ data {
114
+ // example of overriding the workingDirectory set in configureEach above, uncomment if you want to use it
115
+ // workingDirectory project.file('run-data')
116
+
117
+ // Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
118
+ programArguments. addAll ' --mod' , project. mod_id, ' --all' , ' --output' , file(' src/generated/resources/' ). getAbsolutePath(), ' --existing' , file(' src/main/resources/' ). getAbsolutePath()
119
+ }
120
+ }
121
+
122
+ // Include resources generated by data generators.
123
+ sourceSets. main. resources { srcDir ' src/generated/resources' }
124
+
125
+ // Sets up a dependency configuration called 'localRuntime'.
126
+ // This configuration should be used instead of 'runtimeOnly' to declare
127
+ // a dependency that will be present for runtime testing but that is
128
+ // "optional", meaning it will not be pulled by dependents of this mod.
129
+ configurations {
130
+ runtimeClasspath. extendsFrom localRuntime
131
+ }
132
+
133
+ dependencies {
134
+ // Specify the version of Minecraft to use.
135
+ // Depending on the plugin applied there are several options. We will assume you applied the userdev plugin as shown above.
136
+ // The group for userdev is net.neoforged, the module name is neoforge, and the version is the same as the neoforge version.
137
+ // You can however also use the vanilla plugin (net.neoforged.gradle.vanilla) to use a version of Minecraft without the neoforge loader.
138
+ // And its provides the option to then use net.minecraft as the group, and one of; client, server or joined as the module name, plus the game version as version.
139
+ // For all intends and purposes: You can treat this dependency as if it is a normal library you would use.
140
+ implementation " net.neoforged:neoforge:${ neo_version} "
141
+
142
+ // Example optional mod dependency with JEI
143
+ // The JEI API is declared for compile time use, while the full JEI artifact is used at runtime
144
+ // compileOnly "mezz.jei:jei-${mc_version}-common-api:${jei_version}"
145
+ // compileOnly "mezz.jei:jei-${mc_version}-neoforge-api:${jei_version}"
146
+ // We add the full version to localRuntime, not runtimeOnly, so that we do not publish a dependency on it
147
+ // localRuntime "mezz.jei:jei-${mc_version}-neoforge:${jei_version}"
148
+
149
+ // Example mod dependency using a mod jar from ./libs with a flat dir repository
150
+ // This maps to ./libs/coolmod-${mc_version}-${coolmod_version}.jar
151
+ // The group id is ignored when searching -- in this case, it is "blank"
152
+ // implementation "blank:coolmod-${mc_version}:${coolmod_version}"
153
+
154
+ // Example mod dependency using a file as dependency
155
+ // implementation files("libs/coolmod-${mc_version}-${coolmod_version}.jar")
156
+ implementation " io.github.kituin:ChatImageCode:${ code_version} "
157
+ jarJar(group : ' io.github.kituin' , name : ' ChatImageCode' , version : " ${ code_version} " ) {
158
+ jarJar. ranged(it, ' [0.9.2,1.0)' )
159
+ }
160
+ implementation " io.github.kituin:ActionLib:${ project.action_version} "
161
+ jarJar(group : ' io.github.kituin' , name : ' ActionLib' , version : " ${ project.action_version} " ) {
162
+ jarJar. ranged(it, ' [1.9.1,2.0)' )
163
+ }
164
+ // Example project dependency using a sister or child project:
165
+ // implementation project(":myproject")
166
+
167
+ // For more info:
168
+ // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
169
+ // http://www.gradle.org/docs/current/userguide/dependency_management.html
170
+ }
171
+
172
+ // This block of code expands all declared replace properties in the specified resource targets.
173
+ // A missing property will result in an error. Properties are expanded using ${} Groovy notation.
174
+ // When "copyIdeResources" is enabled, this will also run before the game launches in IDE environments.
175
+ // See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
176
+ tasks. withType(ProcessResources ). configureEach {
177
+ var replaceProperties = [
178
+ minecraft_version : minecraft_version,
179
+ minecraft_version_range : minecraft_version_range,
180
+ neo_version : neo_version,
181
+ neo_version_range : neo_version_range,
182
+ loader_version_range : loader_version_range,
183
+ mod_id : mod_id,
184
+ mod_name : mod_name,
185
+ mod_license : mod_license,
186
+ mod_version : mod_version,
187
+ mod_authors : mod_authors,
188
+ mod_description : mod_description
189
+ ]
190
+ inputs. properties replaceProperties
191
+ // IF < neoforge-1.20.5
192
+ // filesMatching(['META-INF/mods.toml']) {
193
+ // ELSE
194
+ // filesMatching(['META-INF/neoforge.mods.toml']) {
195
+ // END IF
196
+ expand replaceProperties
197
+ }
198
+ }
199
+
200
+ // Example configuration to allow publishing using the maven-publish plugin
201
+ publishing {
202
+ publications {
203
+ mavenJava(MavenPublication ) {
204
+ artifactId project. mod_name
205
+ groupId maven_group
206
+ version version
207
+ // from components.java
208
+ artifact jar
209
+ artifact sourcesJar
210
+ pom {
211
+ name = project. mod_name
212
+ description = ' A Minecraft Mod Which Could Show Image In Chat Line'
213
+ url = ' https://github.com/kitUIN/ChatImage'
214
+ licenses {
215
+ license {
216
+ name = ' MIT'
217
+ url = ' '
218
+ }
219
+ }
220
+ developers {
221
+ developer {
222
+ id = ' kitUIN'
223
+ name = ' kitUIN'
224
+ email = ' KIT_UIN@outlook.com'
225
+ }
226
+ }
227
+ scm {
228
+ connection = ' scm:git:git://github.com/kitUIN/ChatImage.git'
229
+ developerConnection = ' scm:git:ssh://github.com/kitUIN/ChatImage.git'
230
+ url = ' https://github.com/kitUIN/ChatImage'
231
+ }
232
+ }
233
+ }
234
+ }
235
+ repositories {
236
+ maven {
237
+ name = project. mod_name
238
+ if (project. version. toString(). endsWith(" -SNAPSHOT" )) {
239
+ url = " https://maven.kituin.fun/snapshots"
240
+ } else {
241
+ url = " https://maven.kituin.fun/releases"
242
+ }
243
+ // credentials(PasswordCredentials)
244
+ credentials {
245
+ username = findProperty(" user" ) ?: System . getenv(" KITUIN_USERNAME" )
246
+ password = findProperty(" pwd" ) ?: System . getenv(" KITUIN_PASSWORD" )
247
+ }
248
+ authentication {
249
+ basic(BasicAuthentication )
250
+ }
251
+ }
252
+ }
253
+ }
254
+
255
+ tasks. withType(JavaCompile ). configureEach {
256
+ options. encoding = ' UTF-8' // Use the UTF-8 charset for Java compilation
257
+ }
258
+
259
+ // IDEA no longer automatically downloads sources/javadoc jars for dependencies, so we need to explicitly enable the behavior.
260
+ idea {
261
+ module {
262
+ downloadSources = true
263
+ downloadJavadoc = true
264
+ }
265
+ }
0 commit comments