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