|
1 | 1 | plugins { |
2 | | - id 'fabric-loom' version '1.0-SNAPSHOT' |
3 | | - id 'maven-publish' |
4 | | - id 'org.ajoberstar.grgit' version '4.1.0' |
| 2 | + alias libs.plugins.fabric.loom |
| 3 | + id "maven-publish" |
5 | 4 | } |
6 | 5 |
|
7 | | -def getVersionMetadata() { |
8 | | - // CI builds version numbers |
9 | | - def build_id = System.getenv("RELEASE_NUMBER") |
10 | | - if (build_id != null) { |
11 | | - return build_id + ".0.0" |
12 | | - } |
13 | | - |
14 | | - // Development builds |
15 | | - if (grgit == null) { |
16 | | - return "dev" |
17 | | - } |
18 | | - |
19 | | - // Named development builds |
20 | | - def id = grgit.head().abbreviatedId |
21 | | - if (!grgit.status().clean) { |
22 | | - id += "-dirty" |
23 | | - } |
| 6 | +version = "$mod_version+$target_version" |
| 7 | +group = maven_group |
24 | 8 |
|
25 | | - return "rev.${id}" |
| 9 | +base { |
| 10 | + archivesName = archives_name |
26 | 11 | } |
27 | 12 |
|
28 | | -archivesBaseName = "${project.mod_id}-${project.supported_versions}" |
29 | | -version = "${getVersionMetadata()}" |
30 | | -group = project.maven_group |
31 | | - |
32 | 13 | repositories { |
33 | | - // Add repositories to retrieve artifacts from in here. |
34 | | - // You should only use this when depending on other mods because |
35 | | - // Loom adds the essential maven repositories to download Minecraft and libraries from automatically. |
36 | | - // See https://docs.gradle.org/current/userguide/declaring_repositories.html |
37 | | - // for more information about repositories. |
| 14 | + maven { url "https://s01.oss.sonatype.org/content/repositories/snapshots" } |
| 15 | +} |
| 16 | + |
| 17 | +loom { |
| 18 | + decompilers { |
| 19 | + vineflower { |
| 20 | + options.putAll(["mark-corresponding-synthetics": "1", "ind": " "]) |
| 21 | + } |
| 22 | + } |
| 23 | + mixin { |
| 24 | + useLegacyMixinAp = false |
| 25 | + } |
38 | 26 | } |
39 | 27 |
|
40 | 28 | dependencies { |
41 | | - // To change the versions see the gradle.properties file |
42 | | - minecraft "com.mojang:minecraft:${project.minecraft_version}" |
43 | | - mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" |
44 | | - modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" |
| 29 | + minecraft libs.minecraft |
| 30 | + mappings variantOf(libs.yarn.mappings) { classifier "v2" } |
| 31 | + modImplementation libs.fabric.loader |
| 32 | + vineflowerDecompilerClasspath libs.vineflower |
45 | 33 | } |
46 | 34 |
|
47 | 35 | processResources { |
48 | | - inputs.property "mod_id", project.mod_id |
49 | | - inputs.property "version", project.version |
50 | | - filteringCharset "UTF-8" |
51 | | - |
52 | | - filesMatching("fabric.mod.json") { |
53 | | - expand "mod_id": project.mod_id, "version": project.version |
| 36 | + filesMatching "fabric.mod.json", { |
| 37 | + expand "version": version |
54 | 38 | } |
55 | 39 | } |
56 | 40 |
|
57 | 41 | tasks.withType(JavaCompile).configureEach { |
58 | | - // Minecraft 1.18 (1.18-pre2) upwards uses Java 17. |
59 | | - // it.options.release = 17 |
| 42 | + it.options.encoding = "UTF-8" |
| 43 | + if (JavaVersion.current().isJava9Compatible()) it.options.release.set(8) |
60 | 44 | } |
61 | 45 |
|
62 | 46 | java { |
63 | | - // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task |
64 | | - // if it is present. |
65 | | - // If you remove this line, sources will not be generated. |
66 | | - withSourcesJar() |
| 47 | + sourceCompatibility = targetCompatibility = JavaVersion.VERSION_1_8 |
67 | 48 | } |
68 | 49 |
|
69 | 50 | jar { |
70 | | - from("LICENSE") { |
71 | | - rename { "${it}_${project.archivesBaseName}"} |
72 | | - } |
| 51 | + from "LICENSE" |
73 | 52 | } |
74 | 53 |
|
75 | | -// configure the maven publication |
76 | 54 | publishing { |
77 | | - publications { |
78 | | - mavenJava(MavenPublication) { |
79 | | - artifact(remapJar) { |
80 | | - builtBy remapJar |
81 | | - } |
82 | | - artifact(sourcesJar) { |
83 | | - builtBy remapSourcesJar |
84 | | - } |
85 | | - } |
86 | | - } |
87 | | - |
88 | | - // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. |
89 | | - repositories { |
90 | | - // Add repositories to publish to here. |
91 | | - // Notice: This block does NOT have the same function as the block in the top level. |
92 | | - // The repositories here will be used for publishing your artifact, not for |
93 | | - // retrieving dependencies. |
| 55 | + publications.create("mavenJava", MavenPublication) { |
| 56 | + from components.java |
94 | 57 | } |
| 58 | + repositories {} |
95 | 59 | } |
0 commit comments