|
| 1 | +plugins { |
| 2 | + java |
| 3 | + id("net.fabricmc.fabric-loom-remap") version "1.15.+" |
| 4 | + id("ploceus") version "1.15.+" |
| 5 | + `maven-publish` |
| 6 | + id("com.modrinth.minotaur") version "2.+" |
| 7 | + id("io.freefair.lombok") version "9.+" |
| 8 | + id("dev.yumi.gradle.licenser") version "1.0.+" |
| 9 | +} |
| 10 | + |
| 11 | +var featherBuild = "1" |
| 12 | +var fabricLoader = "0.19.1" |
| 13 | +var client = "3.1.10-beta.1" |
| 14 | +var config = "3.1.13" |
| 15 | +var osl = "0.17.2" |
| 16 | +var legacyLwjgl3 = "1.2.11" |
| 17 | +version = "1.1.0" |
| 18 | +group = "io.github.axolotlclient.oldanimations" |
| 19 | +base.archivesName = "AxolotlClient-OldAnimations" |
| 20 | + |
| 21 | +repositories { |
| 22 | + maven("https://moehreag.duckdns.org/maven/snapshots") |
| 23 | + maven("https://moehreag.duckdns.org/maven/releases") |
| 24 | + maven("https://repo.hypixel.net/repository/Hypixel/") { |
| 25 | + content { |
| 26 | + includeGroup("net.hypixel") |
| 27 | + } |
| 28 | + } |
| 29 | + mavenLocal() |
| 30 | + mavenCentral() |
| 31 | +} |
| 32 | + |
| 33 | +ploceus { |
| 34 | + setIntermediaryGeneration(2) |
| 35 | +} |
| 36 | + |
| 37 | +loom { |
| 38 | + accessWidenerPath.set(file("src/main/resources/oldanimations.accesswidener")) |
| 39 | + |
| 40 | + mods { |
| 41 | + create("axolotlclient-oldanimations") { |
| 42 | + sourceSet("main") |
| 43 | + } |
| 44 | + } |
| 45 | + runs { |
| 46 | + getByName("client") { |
| 47 | + vmArgs("-XX:+AllowEnhancedClassRedefinition", "-XX:+IgnoreUnrecognizedVMOptions") |
| 48 | + } |
| 49 | + remove(getByName("server")) |
| 50 | + } |
| 51 | +} |
| 52 | + |
| 53 | +dependencies { |
| 54 | + minecraft("com.mojang:minecraft:1.8.9") |
| 55 | + mappings(ploceus.featherMappings(featherBuild)) |
| 56 | + |
| 57 | + modImplementation("net.fabricmc:fabric-loader:$fabricLoader") |
| 58 | + |
| 59 | + modImplementation("io.github.axolotlclient:AxolotlClient:$client+1.8.9") |
| 60 | + modImplementation(include("io.github.axolotlclient:AxolotlClient-config:$config+1.8.9")!!) |
| 61 | + ploceus.dependOsl(osl) |
| 62 | + |
| 63 | + modImplementation("io.github.moehreag:legacy-lwjgl3:$legacyLwjgl3+1.8.9") |
| 64 | + modImplementation("com.terraformersmc:modmenu:0.4.0+mc1.8.9") |
| 65 | +} |
| 66 | + |
| 67 | +configurations.configureEach { |
| 68 | + exclude("org.lwjgl.lwjgl") |
| 69 | + resolutionStrategy { |
| 70 | + dependencySubstitution { |
| 71 | + substitute(module("io.netty:netty-all:4.0.23.Final")).using(module("io.netty:netty-all:4.0.56.Final")) |
| 72 | + } |
| 73 | + force("io.netty:netty-all:4.0.56.Final") |
| 74 | + } |
| 75 | +} |
| 76 | + |
| 77 | +tasks.processResources { |
| 78 | + inputs.property("version", version) |
| 79 | + |
| 80 | + filesMatching("fabric.mod.json") { |
| 81 | + expand("version" to version) |
| 82 | + } |
| 83 | +} |
| 84 | + |
| 85 | +tasks.withType(JavaCompile::class).configureEach { |
| 86 | + options.encoding = "UTF-8" |
| 87 | + |
| 88 | + if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_18)) { |
| 89 | + options.release = 17 |
| 90 | + } |
| 91 | +} |
| 92 | + |
| 93 | +java { |
| 94 | + withSourcesJar() |
| 95 | + sourceCompatibility = JavaVersion.VERSION_17 |
| 96 | + targetCompatibility = JavaVersion.VERSION_17 |
| 97 | +} |
| 98 | + |
| 99 | +license { |
| 100 | + rule(file("HEADER")) |
| 101 | + include("**/*.java") |
| 102 | +} |
| 103 | + |
| 104 | +// Configure the maven publication |
| 105 | +publishing { |
| 106 | + publications { |
| 107 | + create<MavenPublication>("mavenJava") { |
| 108 | + artifactId = base.archivesName.get() |
| 109 | + from(components["java"]) |
| 110 | + } |
| 111 | + } |
| 112 | + |
| 113 | + repositories { |
| 114 | + maven { |
| 115 | + name = "owlMaven" |
| 116 | + val repository = if (project.version.toString().contains("beta") || project.version.toString() |
| 117 | + .contains("alpha") |
| 118 | + ) "snapshots" else "releases" |
| 119 | + url = uri("https://maven.axolotlclient.com/$repository") |
| 120 | + credentials(PasswordCredentials::class) |
| 121 | + authentication { |
| 122 | + create<BasicAuthentication>("basic") |
| 123 | + } |
| 124 | + } |
| 125 | + } |
| 126 | +} |
| 127 | + |
| 128 | +modrinth { |
| 129 | + token = System.getenv("MODRINTH_TOKEN") |
| 130 | + projectId = "UD5CuiYt" |
| 131 | + versionNumber = "${project.version}" |
| 132 | + versionType = "release" |
| 133 | + uploadFile = tasks.remapJar.get() |
| 134 | + gameVersions.set( |
| 135 | + listOf("1.8.9") |
| 136 | + ) |
| 137 | + loaders.set( |
| 138 | + listOf("fabric", "quilt") |
| 139 | + ) |
| 140 | + additionalFiles.set(listOf(tasks.remapSourcesJar)) |
| 141 | + dependencies { |
| 142 | + required.project("osl") |
| 143 | + optional.project("axolotlclient") |
| 144 | + } |
| 145 | + |
| 146 | + // Changelog fetching: Credit LambdAurora. |
| 147 | + // https://github.com/LambdAurora/LambDynamicLights/blob/1ef85f486084873b5d97b8a08df72f57859a3295/build.gradle#L145 |
| 148 | + // License: MIT |
| 149 | + val changelogText = file("CHANGELOG.md").readText() |
| 150 | + val regexVersion = |
| 151 | + ((project.version) as String).split("+")[0].replace("\\.".toRegex(), "\\.").replace("\\+".toRegex(), "+") |
| 152 | + val changelogRegex = "###? ${regexVersion}\\n\\n(( *- .+\\n)+)".toRegex() |
| 153 | + val matcher = changelogRegex.find(changelogText) |
| 154 | + |
| 155 | + if (matcher != null) { |
| 156 | + var changelogContent = matcher.groups[1]?.value |
| 157 | + |
| 158 | + val changelogLines = changelogText.split("\n") |
| 159 | + val linkRefRegex = "^\\[([A-z0-9 _\\-/+.]+)]: ".toRegex() |
| 160 | + for (line in changelogLines.reversed()) { |
| 161 | + if ((linkRefRegex.matches(line))) |
| 162 | + changelogContent += "\n" + line |
| 163 | + else break |
| 164 | + } |
| 165 | + changelog = changelogContent |
| 166 | + } else { |
| 167 | + afterEvaluate { |
| 168 | + tasks.modrinth.configure { isEnabled = false } |
| 169 | + } |
| 170 | + } |
| 171 | +} |
0 commit comments