@@ -3,15 +3,12 @@ plugins {
33 id ' eclipse'
44 id ' idea'
55 id ' maven-publish'
6+ id ' pmd'
7+ id ' com.diffplug.spotless' version ' 7.0.3'
68 id ' net.neoforged.gradle.userdev' version ' 7.0.152'
79}
810
911tasks. named(' wrapper' , Wrapper ). configure {
10- // Define wrapper values here so as to not have to always do so when updating gradlew.properties.
11- // Switching this to Wrapper.DistributionType.ALL will download the full gradle sources that comes with
12- // documentation attached on cursor hover of gradle classes and methods. However, this comes with increased
13- // file size for Gradle. If you do switch this to ALL, run the Gradle wrapper task twice afterwards.
14- // (Verify by checking gradle/wrapper/gradle-wrapper.properties to see if distributionUrl now points to `-all`)
1512 distributionType = Wrapper.DistributionType . BIN
1613}
1714
@@ -35,33 +32,37 @@ base {
3532 archivesName = mod_id
3633}
3734
35+ spotless {
36+ java {
37+ target project. fileTree(dir : ' src/main/java/vazkii/psi' , include : ' **/*.java' )
38+ eclipse(). configFile ' spotless/eclipseformat.xml'
39+ removeUnusedImports()
40+ importOrderFile ' spotless/eclipse.importorder'
41+ replaceRegex ' Too much space after if' , ' (if|for|while|switch) +\\ (' , ' $1('
42+ }
43+ }
44+
45+ pmd {
46+ ruleSetFiles = files(" spotless/pmd-ruleset.xml" )
47+ }
48+
49+ tasks. register(' checkSyntax' ) {
50+ dependsOn spotlessJavaCheck, pmdMain
51+ }
52+
3853// Mojang ships Java 21 to end users starting in 1.20.5, so mods should target Java 21.
3954java. toolchain. languageVersion = JavaLanguageVersion . of(21 )
4055
4156minecraft. accessTransformers. file file(' src/main/resources/META-INF/accesstransformer.cfg' )
4257
43- // Default run configurations.
44- // These can be tweaked, removed, or duplicated as needed.
4558runs {
46- // applies to all the run configs below
4759 configureEach {
48- // Recommended logging data for a userdev environment
49- // The markers can be added/remove as needed separated by commas.
50- // "SCAN": For mods scan.
51- // "REGISTRIES": For firing of registry events.
52- // "REGISTRYDUMP": For getting the contents of all registries.
5360 systemProperty ' forge.logging.markers' , ' REGISTRIES'
54-
55- // Recommended logging level for the console
56- // You can set various levels here.
57- // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
5861 systemProperty ' forge.logging.console.level' , ' debug'
59-
6062 modSource project. sourceSets. main
6163 }
6264
6365 client {
64- // Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
6566 systemProperty ' forge.enabledGameTestNamespaces' , project. mod_id
6667 }
6768
@@ -70,13 +71,6 @@ runs {
7071 programArgument ' --nogui'
7172 }
7273
73- // This run config launches GameTestServer and runs all registered gametests, then exits.
74- // By default, the server will crash when no gametests are provided.
75- // The gametest system is also enabled by default for other run configs under the /test command.
76- gameTestServer {
77- systemProperty ' forge.enabledGameTestNamespaces' , project. mod_id
78- }
79-
8074 data {
8175 // example of overriding the workingDirectory set in configureEach above, uncomment if you want to use it
8276 // workingDirectory project.file('run-data')
@@ -86,24 +80,12 @@ runs {
8680 }
8781}
8882
89- // Include resources generated by data generators.
9083sourceSets. main. resources { srcDir ' src/generated/resources' }
91-
92- // Sets up a dependency configuration called 'localRuntime'.
93- // This configuration should be used instead of 'runtimeOnly' to declare
94- // a dependency that will be present for runtime testing but that is
95- // "optional", meaning it will not be pulled by dependents of this mod.
9684configurations {
9785 runtimeClasspath. extendsFrom localRuntime
9886}
9987
10088dependencies {
101- // Specify the version of Minecraft to use.
102- // Depending on the plugin applied there are several options. We will assume you applied the userdev plugin as shown above.
103- // The group for userdev is net.neoforged, the module name is neoforge, and the version is the same as the neoforge version.
104- // You can however also use the vanilla plugin (net.neoforged.gradle.vanilla) to use a version of Minecraft without the neoforge loader.
105- // 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.
106- // For all intends and purposes: You can treat this dependency as if it is a normal library you would use.
10789 implementation " net.neoforged:neoforge:${ neo_version} "
10890
10991 // Example optional mod dependency with JEI
@@ -113,29 +95,11 @@ dependencies {
11395 // We add the full version to localRuntime, not runtimeOnly, so that we do not publish a dependency on it
11496 localRuntime " mezz.jei:jei-${ minecraft_version} -neoforge:${ jei_version} "
11597
116- compileOnly " vazkii.patchouli:Patchouli:1.21-87-NEOFORGE:api"
117- runtimeOnly " vazkii.patchouli:Patchouli:1.21-87-NEOFORGE"
118-
119- // Example mod dependency using a mod jar from ./libs with a flat dir repository
120- // This maps to ./libs/coolmod-${mc_version}-${coolmod_version}.jar
121- // The group id is ignored when searching -- in this case, it is "blank"
122- // implementation "blank:coolmod-${mc_version}:${coolmod_version}"
123-
124- // Example mod dependency using a file as dependency
125- // implementation files("libs/coolmod-${mc_version}-${coolmod_version}.jar")
126-
127- // Example project dependency using a sister or child project:
128- // implementation project(":myproject")
129-
130- // For more info:
131- // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
132- // http://www.gradle.org/docs/current/userguide/dependency_management.html
98+ compileOnly " vazkii.patchouli:Patchouli:${ patchouli_version} -NEOFORGE:api"
99+ runtimeOnly " vazkii.patchouli:Patchouli:${ patchouli_version} -NEOFORGE"
133100}
134101
135- // This block of code expands all declared replace properties in the specified resource targets.
136- // A missing property will result in an error. Properties are expanded using ${} Groovy notation.
137- // When "copyIdeResources" is enabled, this will also run before the game launches in IDE environments.
138- // See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
102+
139103tasks. withType(ProcessResources ). configureEach {
140104 var replaceProperties = [
141105 minecraft_version : minecraft_version,
@@ -157,25 +121,11 @@ tasks.withType(ProcessResources).configureEach {
157121 }
158122}
159123
160- // Example configuration to allow publishing using the maven-publish plugin
161- publishing {
162- publications {
163- register(' mavenJava' , MavenPublication ) {
164- from components. java
165- }
166- }
167- repositories {
168- maven {
169- url " file://${ project.projectDir} /repo"
170- }
171- }
172- }
173124
174125tasks. withType(JavaCompile ). configureEach {
175- options. encoding = ' UTF-8' // Use the UTF-8 charset for Java compilation
126+ options. encoding = ' UTF-8'
176127}
177128
178- // IDEA no longer automatically downloads sources/javadoc jars for dependencies, so we need to explicitly enable the behavior.
179129idea {
180130 module {
181131 downloadSources = true
0 commit comments