|
1 | 1 | plugins { |
2 | | - id 'eclipse' |
3 | | - id 'idea' |
| 2 | + id 'java-library' |
4 | 3 | id 'maven-publish' |
5 | | - id 'net.minecraftforge.gradle' version '[6.0,6.2)' |
6 | | - id "com.matthewprenger.cursegradle" version "${cursegradle_version}" |
7 | | - id 'com.modrinth.minotaur' version "${minotaur_version}" |
| 4 | + id 'net.neoforged.gradle.userdev' version '7.0.181' |
| 5 | +} |
| 6 | + |
| 7 | +tasks.named('wrapper', Wrapper).configure { |
| 8 | + distributionType = Wrapper.DistributionType.BIN |
8 | 9 | } |
9 | 10 |
|
10 | 11 | version = mod_version |
11 | 12 | group = mod_group_id |
12 | 13 |
|
| 14 | +repositories { |
| 15 | + mavenLocal() |
| 16 | + maven { |
| 17 | + name "CurseMaven" |
| 18 | + url "https://www.cursemaven.com" |
| 19 | + } |
| 20 | +} |
| 21 | + |
13 | 22 | base { |
14 | 23 | archivesName = mod_id |
15 | 24 | } |
16 | 25 |
|
17 | | -java.toolchain.languageVersion = JavaLanguageVersion.of(17) |
18 | | - |
19 | | -println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}" |
20 | | -minecraft { |
21 | | - |
22 | | - mappings channel: mapping_channel, version: mapping_version |
23 | | - copyIdeResources = true |
24 | | - |
25 | | - runs { |
26 | | - client { |
| 26 | +java.toolchain.languageVersion = JavaLanguageVersion.of(21) |
27 | 27 |
|
28 | | - workingDirectory project.file('run') |
29 | | - |
30 | | - property 'forge.logging.markers', 'REGISTRIES' |
31 | | - property 'forge.logging.console.level', 'debug' |
32 | | - property 'forge.enabledGameTestNamespaces', mod_id |
33 | | - |
34 | | - mods { |
35 | | - "${mod_id}" { |
36 | | - source sourceSets.main |
37 | | - } |
38 | | - } |
39 | | - } |
40 | | - |
41 | | - server { |
42 | | - workingDirectory project.file('run') |
43 | | - |
44 | | - property 'forge.logging.markers', 'REGISTRIES' |
45 | | - property 'forge.logging.console.level', 'debug' |
46 | | - property 'forge.enabledGameTestNamespaces', mod_id |
47 | | - |
48 | | - mods { |
49 | | - "${mod_id}" { |
50 | | - source sourceSets.main |
51 | | - } |
52 | | - } |
53 | | - } |
54 | | - |
55 | | - gameTestServer { |
56 | | - workingDirectory project.file('run') |
57 | | - |
58 | | - property 'forge.logging.markers', 'REGISTRIES' |
59 | | - property 'forge.logging.console.level', 'debug' |
60 | | - property 'forge.enabledGameTestNamespaces', mod_id |
| 28 | +runs { |
| 29 | + configureEach { |
| 30 | + systemProperty 'forge.logging.markers', 'REGISTRIES' |
| 31 | + systemProperty 'forge.logging.console.level', 'debug' |
| 32 | + modSource project.sourceSets.main |
| 33 | + } |
61 | 34 |
|
62 | | - mods { |
63 | | - "${mod_id}" { |
64 | | - source sourceSets.main |
65 | | - } |
66 | | - } |
67 | | - } |
| 35 | + client { |
| 36 | + systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id |
| 37 | + } |
68 | 38 |
|
69 | | - data { |
70 | | - workingDirectory project.file('run') |
| 39 | + server { |
| 40 | + systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id |
| 41 | + argument '--nogui' |
| 42 | + } |
71 | 43 |
|
72 | | - property 'forge.logging.markers', 'REGISTRIES' |
73 | | - property 'forge.logging.console.level', 'debug' |
74 | | - args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') |
| 44 | + gameTestServer { |
| 45 | + systemProperty 'neoforge.enabledGameTestNamespaces', project.mod_id |
| 46 | + } |
75 | 47 |
|
76 | | - mods { |
77 | | - "${mod_id}" { |
78 | | - source sourceSets.main |
79 | | - } |
80 | | - } |
81 | | - } |
| 48 | + data { |
| 49 | + arguments.addAll '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath() |
82 | 50 | } |
83 | 51 | } |
84 | 52 |
|
85 | 53 | sourceSets.main.resources { srcDir 'src/generated/resources' } |
86 | 54 |
|
87 | | -repositories { |
88 | | - maven { |
89 | | - name "CurseMaven" |
90 | | - url "https://www.cursemaven.com" |
91 | | - } |
| 55 | +configurations { |
| 56 | + runtimeClasspath.extendsFrom localRuntime |
92 | 57 | } |
93 | 58 |
|
94 | 59 | dependencies { |
95 | | - minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" |
| 60 | + implementation "net.neoforged:neoforge:${neo_version}" |
96 | 61 |
|
97 | | - implementation fg.deobf("curse.maven:ccore-573646:${rootProject.ccore_file_id}") |
98 | | - runtimeOnly fg.deobf("curse.maven:jei-238222:${rootProject.jei_file_id}") |
| 62 | + runtimeOnly "curse.maven:jei-238222:${project.jei_file_id}" |
99 | 63 | } |
100 | 64 |
|
101 | | -def resourceTargets = ['META-INF/mods.toml', 'pack.mcmeta'] |
102 | | -def replaceProperties = [ |
103 | | - minecraft_version: minecraft_version, minecraft_version_range: minecraft_version_range, |
104 | | - forge_version: forge_version, forge_version_range: forge_version_range, |
105 | | - loader_version_range: loader_version_range, |
106 | | - mod_id: mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version, |
107 | | - mod_authors: mod_authors, mod_description: mod_description |
108 | | -] |
109 | | - |
110 | | -processResources { |
| 65 | +tasks.withType(ProcessResources).configureEach { |
| 66 | + var replaceProperties = [ |
| 67 | + minecraft_version : minecraft_version, |
| 68 | + minecraft_version_range: minecraft_version_range, |
| 69 | + neo_version : neo_version, |
| 70 | + neo_version_range : neo_version_range, |
| 71 | + loader_version_range : loader_version_range, |
| 72 | + mod_id : mod_id, |
| 73 | + mod_name : mod_name, |
| 74 | + mod_license : mod_license, |
| 75 | + mod_version : mod_version, |
| 76 | + mod_authors : mod_authors, |
| 77 | + mod_description : mod_description |
| 78 | + ] |
111 | 79 | inputs.properties replaceProperties |
112 | | - replaceProperties.put 'project', project |
113 | 80 |
|
114 | | - filesMatching(resourceTargets) { |
| 81 | + filesMatching(['META-INF/neoforge.mods.toml']) { |
115 | 82 | expand replaceProperties |
116 | 83 | } |
117 | 84 | } |
118 | 85 |
|
119 | | -jar { |
120 | | - manifest { |
121 | | - attributes([ |
122 | | - "Specification-Title" : mod_id, |
123 | | - "Specification-Vendor" : mod_authors, |
124 | | - "Specification-Version" : mod_version, |
125 | | - "Implementation-Title" : project.name, |
126 | | - "Implementation-Version" : project.jar.archiveVersion, |
127 | | - "Implementation-Vendor" : mod_authors, |
128 | | - "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") |
129 | | - ]) |
130 | | - } |
131 | | -} |
132 | | - |
133 | | -jar.finalizedBy('reobfJar') |
134 | | - |
135 | 86 | publishing { |
136 | 87 | publications { |
137 | | - mavenJava(MavenPublication) { |
138 | | - artifact jar |
| 88 | + register('mavenJava', MavenPublication) { |
| 89 | + from components.java |
139 | 90 | } |
140 | 91 | } |
141 | 92 | repositories { |
142 | 93 | maven { |
143 | | - url "file://${project.projectDir}/mcmodsrepo" |
| 94 | + url "file://${project.projectDir}/repo" |
144 | 95 | } |
145 | 96 | } |
146 | 97 | } |
147 | 98 |
|
148 | | -curseforge { |
149 | | - |
150 | | - apiKey = project.findProperty('curseforge_apikey') ?: '0' |
151 | | - |
152 | | - project { |
153 | | - |
154 | | - id = curseforge_project_id |
155 | | - releaseType = mod_release_type |
156 | | - |
157 | | - changelog = file("changelog.txt") |
158 | | - |
159 | | - addGameVersion "${minecraft_version}" |
160 | | - addGameVersion "Java 8" |
161 | | - |
162 | | - mainArtifact(jar) { |
163 | | - displayName = "[${rootProject.minecraft_version}] v${rootProject.mod_version}" |
164 | | - } |
165 | | - |
166 | | - relations { |
167 | | - requiredDependency 'ccore' |
168 | | - } |
169 | | - } |
170 | | -} |
171 | | - |
172 | | -tasks.modrinth.configure({ |
173 | | - group = 'upload' |
174 | | -}) |
175 | | - |
176 | | -modrinth { |
177 | | - |
178 | | - token = project.findProperty('modrinth_apikey') ?: '0' |
179 | | - |
180 | | - projectId = modrinth_project_id |
181 | | - versionType = mod_release_type.toUpperCase() |
182 | | - |
183 | | - changelog = file('changelog.txt').text |
184 | | - |
185 | | - versionNumber = "forge-${mod_version}" |
186 | | - versionName = "${mod_name} ${mod_version}" |
187 | | - uploadFile = jar |
188 | | - |
189 | | - gameVersions = [minecraft_version] |
190 | | - loaders = ['forge'] |
| 99 | +tasks.withType(JavaCompile).configureEach { |
| 100 | + options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation |
191 | 101 | } |
192 | | -tasks.modrinth.dependsOn(build) |
193 | 102 |
|
194 | | -tasks.withType(JavaCompile).configureEach { |
195 | | - options.encoding = 'UTF-8' |
| 103 | +idea { |
| 104 | + module { |
| 105 | + downloadSources = true |
| 106 | + downloadJavadoc = true |
| 107 | + } |
196 | 108 | } |
0 commit comments