11plugins {
2- id ' fabric-loom' version ' 1.6-SNAPSHOT'
3- id ' maven-publish'
2+ id ' java-library'
3+ id ' maven-publish'
4+ id ' net.neoforged.moddev' version ' 2.0.140'
5+ id ' idea'
46}
57
6- version = project. mod_version
7- group = project. maven_group
8-
9- base {
10- archivesName = project. archives_base_name
8+ tasks. named(' wrapper' , Wrapper ). configure {
9+ // Define wrapper values here so as to not have to always do so when updating gradlew.properties.
10+ // Switching this to Wrapper.DistributionType.ALL will download the full gradle sources that comes with
11+ // documentation attached on cursor hover of gradle classes and methods. However, this comes with increased
12+ // file size for Gradle. If you do switch this to ALL, run the Gradle wrapper task twice afterwards.
13+ // (Verify by checking gradle/wrapper/gradle-wrapper.properties to see if distributionUrl now points to `-all`)
14+ distributionType = Wrapper.DistributionType . BIN
1115}
1216
17+ version = mod_version
18+ group = mod_group_id
19+
1320repositories {
14- // Add repositories to retrieve artifacts from in here.
15- // You should only use this when depending on other mods because
16- // Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
17- // See https://docs.gradle.org/current/userguide/declaring_repositories.html
18- // for more information about repositories.
21+ // Add here additional repositories if required by some of the dependencies below.
1922}
2023
21- dependencies {
22- // To change the versions see the gradle.properties file
23- minecraft " com.mojang:minecraft:${ project.minecraft_version} "
24- // mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
25- mappings loom. officialMojangMappings()
26- modImplementation " net.fabricmc:fabric-loader:${ project.loader_version} "
27-
28- // Fabric API. This is technically optional, but you probably want it anyway.
29- modImplementation " net.fabricmc.fabric-api:fabric-api:${ project.fabric_version} "
30-
31- // Uncomment the following line to enable the deprecated Fabric API modules.
32- // These are included in the Fabric API production distribution and allow you to update your mod to the latest modules at a later more convenient time.
33-
34- // modImplementation "net.fabricmc.fabric-api:fabric-api-deprecated:${project.fabric_version}"
24+ base {
25+ archivesName = mod_id
3526}
3627
37- processResources {
38- inputs . property " version " , project . version
28+ // Mojang ships Java 21 to end users in 1.21.1, so mods should target Java 21.
29+ java . toolchain . languageVersion = JavaLanguageVersion . of( 21 )
3930
40- filesMatching( " fabric.mod.json " ) {
41- expand " version " : project . version
42- }
31+ java {
32+ withSourcesJar()
33+ withJavadocJar()
4334}
4435
45- tasks. withType(JavaCompile ). configureEach {
46- it. options. release = 16
36+ neoForge {
37+ // Specify the version of NeoForge to use.
38+ version = project. neo_version
39+
40+ parchment {
41+ mappingsVersion = project. parchment_mappings_version
42+ minecraftVersion = project. parchment_minecraft_version
43+ }
44+
45+ // This line is optional. Access Transformers are automatically detected
46+ // accessTransformers = project.files('src/main/resources/META-INF/accesstransformer.cfg')
47+
48+ // Default run configurations.
49+ // These can be tweaked, removed, or duplicated as needed.
50+ runs {
51+ client {
52+ client()
53+
54+ // Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
55+ systemProperty ' neoforge.enabledGameTestNamespaces' , project. mod_id
56+ }
57+
58+ server {
59+ server()
60+ programArgument ' --nogui'
61+ systemProperty ' neoforge.enabledGameTestNamespaces' , project. mod_id
62+ }
63+
64+ // This run config launches GameTestServer and runs all registered gametests, then exits.
65+ // By default, the server will crash when no gametests are provided.
66+ // The gametest system is also enabled by default for other run configs under the /test command.
67+ gameTestServer {
68+ type = " gameTestServer"
69+ systemProperty ' neoforge.enabledGameTestNamespaces' , project. mod_id
70+ }
71+
72+ data {
73+ data()
74+
75+ // example of overriding the workingDirectory set in configureEach above, uncomment if you want to use it
76+ // gameDirectory = project.file('run-data')
77+
78+ // Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
79+ programArguments. addAll ' --mod' , project. mod_id, ' --all' , ' --output' , file(' src/generated/resources/' ). getAbsolutePath(), ' --existing' , file(' src/main/resources/' ). getAbsolutePath()
80+ }
81+
82+ // applies to all the run configs above
83+ configureEach {
84+ // Recommended logging data for a userdev environment
85+ // The markers can be added/remove as needed separated by commas.
86+ // "SCAN": For mods scan.
87+ // "REGISTRIES": For firing of registry events.
88+ // "REGISTRYDUMP": For getting the contents of all registries.
89+ systemProperty ' forge.logging.markers' , ' REGISTRIES'
90+
91+ // Recommended logging level for the console
92+ // You can set various levels here.
93+ // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
94+ logLevel = org.slf4j.event.Level . DEBUG
95+ }
96+ }
97+
98+ mods {
99+ // define mod <-> source bindings
100+ // these are used to tell the game which sources are for which mod
101+ // multi mod projects should define one per mod
102+ " ${ mod_id} " {
103+ sourceSet(sourceSets. main)
104+ }
105+ }
47106}
48107
49- java {
50- // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
51- // if it is present.
52- // If you remove this line, sources will not be generated .
53- withSourcesJar()
54- withJavadocJar()
55-
56- sourceCompatibility = JavaVersion . VERSION_16
57- targetCompatibility = JavaVersion . VERSION_16
108+ // Include resources generated by data generators.
109+ sourceSets . main . resources { srcDir ' src/generated/resources ' }
110+
111+ // Sets up a dependency configuration called 'localRuntime' .
112+ // This configuration should be used instead of 'runtimeOnly' to declare
113+ // a dependency that will be present for runtime testing but that is
114+ // "optional", meaning it will not be pulled by dependents of this mod.
115+ configurations {
116+ runtimeClasspath . extendsFrom localRuntime
58117}
59118
60- jar {
61- from(" LICENSE" ) {
62- rename { " ${ it} _${ project.base.archivesName.get()} " }
63- }
119+ dependencies {
120+ // Example optional mod dependency with JEI
121+ // The JEI API is declared for compile time use, while the full JEI artifact is used at runtime
122+ // compileOnly "mezz.jei:jei-${mc_version}-common-api:${jei_version}"
123+ // compileOnly "mezz.jei:jei-${mc_version}-neoforge-api:${jei_version}"
124+ // We add the full version to localRuntime, not runtimeOnly, so that we do not publish a dependency on it
125+ // localRuntime "mezz.jei:jei-${mc_version}-neoforge:${jei_version}"
126+
127+ // Example mod dependency using a mod jar from ./libs with a flat dir repository
128+ // This maps to ./libs/coolmod-${mc_version}-${coolmod_version}.jar
129+ // The group id is ignored when searching -- in this case, it is "blank"
130+ // implementation "blank:coolmod-${mc_version}:${coolmod_version}"
131+
132+ // Example mod dependency using a file as dependency
133+ // implementation files("libs/coolmod-${mc_version}-${coolmod_version}.jar")
134+
135+ // Example project dependency using a sister or child project:
136+ // implementation project(":myproject")
137+
138+ // For more info:
139+ // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
140+ // http://www.gradle.org/docs/current/userguide/dependency_management.html
64141}
65142
66- // configure the maven publication
143+ // This block of code expands all declared replace properties in the specified resource targets.
144+ // A missing property will result in an error. Properties are expanded using ${} Groovy notation.
145+ var generateModMetadata = tasks. register(" generateModMetadata" , ProcessResources ) {
146+ var replaceProperties = [
147+ minecraft_version : minecraft_version,
148+ minecraft_version_range : minecraft_version_range,
149+ neo_version : neo_version,
150+ loader_version_range : loader_version_range,
151+ mod_id : mod_id,
152+ mod_name : mod_name,
153+ mod_license : mod_license,
154+ mod_version : mod_version,
155+ ]
156+ inputs. properties replaceProperties
157+ expand replaceProperties
158+ from " src/main/templates"
159+ into " build/generated/sources/modMetadata"
160+ }
161+ // Include the output of "generateModMetadata" as an input directory for the build
162+ // this works with both building through Gradle and the IDE.
163+ sourceSets. main. resources. srcDir generateModMetadata
164+ // To avoid having to run "generateModMetadata" manually, make it run on every project reload
165+ neoForge. ideSyncTask generateModMetadata
166+
167+ // Example configuration to allow publishing using the maven-publish plugin
67168publishing {
68- publications {
69- mavenJava(MavenPublication ) {
70- from components. java
71- }
72- }
73-
74- // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
75- repositories {
76- // Add repositories to publish to here.
77- // Notice: This block does NOT have the same function as the block in the top level.
78- // The repositories here will be used for publishing your artifact, not for
79- // retrieving dependencies.
80- }
81- }
169+ publications {
170+ register(' mavenJava' , MavenPublication ) {
171+ from components. java
172+ }
173+ }
174+ repositories {
175+ maven {
176+ url " file://${ project.projectDir} /repo"
177+ }
178+ }
179+ }
180+
181+ tasks. withType(JavaCompile ). configureEach {
182+ options. encoding = ' UTF-8' // Use the UTF-8 charset for Java compilation
183+ }
184+
185+ // IDEA no longer automatically downloads sources/javadoc jars for dependencies, so we need to explicitly enable the behavior.
186+ idea {
187+ module {
188+ downloadSources = true
189+ downloadJavadoc = true
190+ }
191+ }
0 commit comments