switch to unimined

This commit is contained in:
Wagyourtail 2022-12-01 23:04:40 -07:00
parent 4fa43ce201
commit 85790c0b2f
No known key found for this signature in database
GPG Key ID: 0D30679891BED858
15 changed files with 202 additions and 351 deletions

View File

@ -15,24 +15,13 @@
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
buildscript {
dependencies {
classpath "org.ow2.asm:asm:9.3"
}
}
plugins {
id "architectury-plugin" version "3.4.135"
id 'dev.architectury.loom' version '0.12.0.282' apply false
}
subprojects {
allprojects {
apply plugin: 'java'
apply plugin: "xyz.wagyourtail.unimined"
apply plugin: "maven-publish"
apply plugin: "dev.architectury.loom"
archivesBaseName = rootProject.archives_base_name
def vers = 'git describe --always --tags --dirty'.execute().text.trim();
def vers = 'git describe --always --tags --dirty'.execute().text.trim()
if (!vers.startsWith("v")) {
println "git doesn't appear to be installed!"
println "using version number: " + rootProject.mod_version
@ -44,36 +33,15 @@ subprojects {
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_17
loom {
silentMojangMappingsLicense()
}
dependencies {
minecraft "com.mojang:minecraft:${rootProject.minecraft_version}"
// The following line declares the mojmap mappings, you may use other mappings as well
mappings loom.officialMojangMappings()
// The following line declares the yarn mappings you may select this one as well.
// mappings "net.fabricmc:yarn:1.17.1+build.32:v2"
}
tasks.withType(JavaCompile).configureEach {
it.options.encoding = "UTF-8"
def targetVersion = 17
if (JavaVersion.current().isJava9Compatible()) {
it.options.release = targetVersion
}
}
}
allprojects {
apply plugin: "architectury-plugin"
repositories {
maven {
name = 'spongepowered-repo'
url = 'https://repo.spongepowered.org/repository/maven-public/'
}
maven {
name = 'fabric-maven'
url = 'https://maven.fabricmc.net/'
}
maven {
name = 'impactdevelopment-repo'
url = 'https://impactdevelopment.github.io/maven/'
@ -92,4 +60,79 @@ allprojects {
}
mavenCentral()
}
dependencies {
minecraft "net.minecraft:minecraft:${rootProject.minecraft_version}"
// The following line declares the mojmap mappings, you may use other mappings as well
mappings "net.fabricmc:intermediary:${rootProject.minecraft_version}:v2"
mappings "net.minecraft:minecraft:${rootProject.minecraft_version}:client-mappings"
implementation "org.spongepowered:mixin:0.8.5"
implementation "org.ow2.asm:asm:9.3"
// The following line declares the yarn mappings you may select this one as well.
// mappings "net.fabricmc:yarn:1.17.1+build.32:v2"
}
tasks.withType(JavaCompile).configureEach {
it.options.encoding = "UTF-8"
def targetVersion = 17
if (JavaVersion.current().isJava9Compatible()) {
it.options.release = targetVersion
}
}
}
minecraft {
runs.off = true
}
archivesBaseName = archivesBaseName + "-common"
sourceSets {
api {
compileClasspath += main.compileClasspath
runtimeClasspath += main.runtimeClasspath
}
main {
compileClasspath += api.output
runtimeClasspath += api.output
}
test {
compileClasspath += main.compileClasspath + main.runtimeClasspath + main.output
runtimeClasspath += main.compileClasspath + main.runtimeClasspath + main.output
}
launch {
compileClasspath += main.compileClasspath + main.runtimeClasspath + main.output
runtimeClasspath += main.compileClasspath + main.runtimeClasspath + main.output
}
schematica_api {
compileClasspath += main.compileClasspath
runtimeClasspath += main.runtimeClasspath
}
main {
compileClasspath += schematica_api.output
runtimeClasspath += schematica_api.output
}
}
dependencies {
testImplementation 'junit:junit:4.13.2'
}
jar {
from sourceSets.main.output, sourceSets.launch.output, sourceSets.api.output
}
remapJar {
targetNamespace = "named"
fallbackTargetNamespace = "intermediary"
}
javadoc {
options.addStringOption('Xwerror', '-quiet') // makes the build fail on travis when there is a javadoc error
options.linkSource true
options.encoding "UTF-8" // allow emoji in comments :^)
source = sourceSets.api.allJava
classpath += sourceSets.api.compileClasspath
}

View File

@ -16,10 +16,25 @@
*/
repositories {
mavenLocal()
maven {
name = 'WagYourMaven'
url = 'https://maven.wagyourtail.xyz/snapshots'
}
maven {
name = 'ForgeMaven'
url = 'https://maven.minecraftforge.net/'
}
maven {
name = 'FabricMaven'
url = 'https://maven.fabricmc.net/'
}
mavenCentral()
}
dependencies {
implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.5'
implementation group: 'com.google.code.gson', name: 'gson', version: '2.9.0'
implementation group: 'commons-io', name: 'commons-io', version: '2.6'
implementation group: 'xyz.wagyourtail.unimined', name: 'xyz.wagyourtail.unimined.gradle.plugin', version: '0.3.0'
}

View File

@ -26,6 +26,9 @@ import org.gradle.api.tasks.TaskCollection;
import org.gradle.api.tasks.compile.ForkOptions;
import org.gradle.api.tasks.compile.JavaCompile;
import org.gradle.internal.jvm.Jvm;
import xyz.wagyourtail.unimined.api.Constants;
import xyz.wagyourtail.unimined.api.minecraft.EnvType;
import xyz.wagyourtail.unimined.api.minecraft.MinecraftProvider;
import java.io.*;
import java.net.MalformedURLException;
@ -81,29 +84,14 @@ public class ProguardTask extends BaritoneGradleTask {
cleanup();
}
private boolean isMcJar(File f) {
return f.getName().startsWith(compType.equals("FORGE") ? "forge-" : "minecraft-") && f.getName().contains("minecraft-merged-named");
MinecraftProvider<?, ?> provider = this.getProject().getExtensions().getByType(MinecraftProvider.class);
private File getMcJar() {
return provider.getMinecraftWithMapping(EnvType.COMBINED, provider.getMcPatcher().getProdNamespace(), provider.getMcPatcher().getProdFallbackNamespace()).toFile();
}
private File getMcJar() throws IOException {
File mcClientJar = this.getProject().getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().findByName("main").getCompileClasspath().getFiles()
.stream()
.filter(this::isMcJar)
.map(f -> {
switch (compType) {
case "OFFICIAL":
return new File(f.getParentFile().getParentFile(), "minecraft-merged.jar");
case "FABRIC":
return new File(f.getParentFile().getParentFile(), "minecraft-merged-intermediary.jar");
case "FORGE":
return new File(f.getParentFile().getParentFile(), f.getName().replace("-named.jar", "-srg.jar"));
}
return null;
})
.findFirst()
.get();
if (!mcClientJar.exists()) throw new IOException("Failed to find minecraft! " + mcClientJar.getAbsolutePath());
return mcClientJar;
private boolean isMcJar(File f) {
return this.getProject().getConfigurations().getByName(Constants.MINECRAFT_COMBINED_PROVIDER).getFiles().contains(f);
}
private void processArtifact() throws Exception {

View File

@ -1,136 +0,0 @@
import baritone.gradle.task.CreateDistTask
import baritone.gradle.task.ProguardTask
architectury {
injectInjectables = false
common(System.getProperty("Baritone.enabled_platforms").split(","))
}
//loom {
// mixin {
// legacyRemapToNamespace = "official"
// }
//}
// ignore this jank, it's so I don't have to move the src folder, as that creates unnecessary git conflicts
sourceSets {
realmain {
java {
java {
srcDir "$rootDir/src/main/java"
}
resources {
srcDir "$rootDir/src/main/resources"
}
}
}
api {
compileClasspath += main.compileClasspath
runtimeClasspath += main.runtimeClasspath
java {
java {
srcDir "$rootDir/src/api/java"
}
resources {
srcDir "$rootDir/src/api/resources"
}
}
}
realmain {
compileClasspath += main.compileClasspath + api.output
runtimeClasspath += main.runtimeClasspath + api.output
}
test {
compileClasspath += realmain.compileClasspath + realmain.output
runtimeClasspath += realmain.runtimeClasspath + realmain.output
java {
java {
srcDir "$rootDir/src/test/java"
}
resources {
srcDir "$rootDir/src/test/resources"
}
}
}
main {
compileClasspath += realmain.output + api.output
runtimeClasspath += realmain.output + api.output
java {
java {
srcDir "$rootDir/src/launch/java"
}
resources {
srcDir "$rootDir/src/launch/resources"
}
}
}
schematica_api {
compileClasspath += realmain.compileClasspath
runtimeClasspath += realmain.runtimeClasspath
java {
java {
srcDir "$rootDir/src/schematica_api/java"
}
resources {
srcDir "$rootDir/src/schematica_api/resources"
}
}
}
realmain {
compileClasspath += schematica_api.output
runtimeClasspath += schematica_api.output
}
}
configurations {
transformProductionTweaker {
canBeConsumed = true
canBeResolved = false
// If you want this configuration to share the same dependencies, otherwise omit this line
extendsFrom implementation, runtimeOnly
}
}
dependencies {
// We depend on fabric loader here to use the fabric @Environment annotations and get the mixin dependencies
// Do NOT use other classes from fabric loader
modCompileOnly "net.fabricmc:fabric-loader:${project.fabric_version}"
compileOnly 'com.google.code.findbugs:jsr305:3.0.2'
testImplementation 'junit:junit:4.12'
}
javadoc {
options.addStringOption('Xwerror', '-quiet') // makes the build fail on travis when there is a javadoc error
options.linkSource true
options.encoding "UTF-8" // allow emoji in comments :^)
source = sourceSets.api.allJava
classpath += sourceSets.api.compileClasspath
}
jar {
classifier "dev"
from sourceSets.main.output, sourceSets.realmain.output, sourceSets.api.output
preserveFileTimestamps = false
reproducibleFileOrder = true
manifest {
attributes(
'MixinConfigs': 'mixins.baritone.json',
"MixinConnector": "baritone.launch.BaritoneMixinConnector",
'Implementation-Title': 'Baritone',
'Implementation-Version': version,
)
}
}
task removeDist(type: Delete) {
delete new File(rootProject.rootDir, "dist")
}
clean.finalizedBy(removeDist)

View File

@ -24,8 +24,7 @@ plugins {
archivesBaseName = archivesBaseName + "-" + project.name
architectury {
platformSetupLoomIde()
minecraft {
fabric()
}
@ -34,14 +33,17 @@ configurations {
shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this.
compileClasspath.extendsFrom common
runtimeClasspath.extendsFrom common
developmentFabric.extendsFrom common
}
dependencies {
modImplementation "net.fabricmc:fabric-loader:${project.fabric_version}"
fabric "net.fabricmc:fabric-loader:${project.fabric_version}"
common(project(path: ":common", configuration: "namedElements")) { transitive false }
shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { transitive false }
// because of multiple sourcesets `common project(":")` doesn't work
for (sourceSet in rootProject.sourceSets) {
if (sourceSet == rootProject.sourceSets.test) continue
common sourceSet.output
shadowCommon sourceSet.output
}
}
processResources {
@ -58,7 +60,7 @@ shadowJar {
}
remapJar {
input.set shadowJar.archiveFile
inputFile.set shadowJar.archiveFile
dependsOn shadowJar
classifier null
}

View File

@ -24,49 +24,52 @@ plugins {
archivesBaseName = archivesBaseName + "-" + project.name
architectury {
platformSetupLoomIde()
forge()
}
loom {
minecraft {
forge {
mixinConfig 'mixins.baritone.json'
devFallbackNamespace = "intermediary"
mixinConfig = ["mixins.baritone.json"]
}
}
//loom {
// forge {
// mixinConfig 'mixins.baritone.json'
// }
//}
configurations {
common
shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this.
compileClasspath.extendsFrom common
runtimeClasspath.extendsFrom common
developmentFabric.extendsFrom common
}
dependencies {
forge "net.minecraftforge:forge:${rootProject.forge_version}"
common(project(path: ":common", configuration: "namedElements")) { transitive false }
shadowCommon(project(path: ":common", configuration: "transformProductionForge")) { transitive false }
// because of multiple sourcesets `common project(":")` doesn't work
for (sourceSet in rootProject.sourceSets) {
if (sourceSet == rootProject.sourceSets.test) continue
common sourceSet.output
shadowCommon sourceSet.output
}
}
processResources {
inputs.property "version", project.version
filesMatching("fabric.mod.json") {
filesMatching("META-INF/mods.toml") {
expand "version": project.version
}
}
shadowJar {
exclude("fabric.mod.json")
configurations = [project.configurations.shadowCommon]
classifier "dev-shadow"
}
remapJar {
input.set shadowJar.archiveFile
inputFile.set shadowJar.archiveFile
dependsOn shadowJar
classifier null
}
@ -99,7 +102,6 @@ task proguard(type: ProguardTask) {
task createDist(type: CreateDistTask, dependsOn: proguard)
build.finalizedBy(createDist)
publishing {

View File

@ -15,7 +15,7 @@ issueTrackerURL="https://github.com/cabaletta/baritone/issues" #optional
# The modid of the mod
modId="baritoe" #mandatory
# The version number of the mod - there's a few well known ${} variables useable here or just hardcode it
version="${file.jarVersion}" #mandatory
version="${version}" #mandatory
# A display name for the mod
displayName="Baritone" #mandatory
# A URL for the "homepage" for this mod, displayed in the mod UI

View File

@ -0,0 +1,6 @@
{
"pack": {
"description": "null",
"pack_format": 8
}
}

View File

@ -5,5 +5,5 @@ maven_group=baritone
archives_base_name=baritone
minecraft_version=1.19.2
forge_version=1.19.2-43.0.0
forge_version=1.19.2-43.1.65
fabric_version=0.14.9

View File

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View File

@ -17,32 +17,30 @@
pluginManagement {
repositories {
maven { url "https://maven.architectury.dev/" }
mavenLocal()
maven {
name = 'WagYourMaven'
url = 'https://maven.wagyourtail.xyz/snapshots'
}
maven {
name = 'ForgeMaven'
url = 'https://maven.minecraftforge.net/'
}
maven {
name = 'FabricMaven'
url = 'https://maven.fabricmc.net/'
}
maven {
name = 'forge'
url = 'https://files.minecraftforge.net/maven'
}
maven {
name = 'impactdevelopment-repo'
url = 'https://impactdevelopment.github.io/maven/'
}
maven {
url = 'https://www.dogforce-games.com/maven/'
}
maven {
url = 'https://libraries.minecraft.net/'
}
mavenCentral()
gradlePluginPortal()
gradlePluginPortal() {
content {
excludeGroup "org.apache.logging.log4j"
}
}
}
}
rootProject.name = 'baritone'
include("common")
include("tweaker")
if (System.getProperty("Baritone.enabled_platforms") == null) {
System.setProperty("Baritone.enabled_platforms", "fabric,forge")

View File

@ -1,6 +0,0 @@
{
"pack": {
"description": "baritoe",
"pack_format": 5
}
}

View File

@ -1,111 +1,53 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
import baritone.gradle.task.CreateDistTask
import baritone.gradle.task.ProguardTask
import baritone.gradle.task.TweakerJsonAssembler
architectury {
injectInjectables = false
plugins {
id "com.github.johnrengelman.shadow" version "7.0.0"
}
loom {
mixin {
refmapTargetNamespace = "official"
defaultRefmapName = "baritone-common-refmap.json"
}
}
loom.mixin.useLegacyMixinAp = false;
// ignore this jank, it's so I don't have to move the src folder, as that creates unnecessary git conflicts
sourceSets {
realmain {
java {
java {
srcDir "$rootDir/src/main/java"
}
resources {
srcDir "$rootDir/src/main/resources"
}
}
}
api {
compileClasspath += main.compileClasspath
runtimeClasspath += main.runtimeClasspath
java {
java {
srcDir "$rootDir/src/api/java"
}
resources {
srcDir "$rootDir/src/api/resources"
}
}
}
realmain {
compileClasspath += main.compileClasspath + api.output
runtimeClasspath += main.runtimeClasspath + api.output
}
test {
compileClasspath += realmain.compileClasspath + realmain.output
runtimeClasspath += realmain.runtimeClasspath + realmain.output
java {
java {
srcDir "$rootDir/src/test/java"
}
resources {
srcDir "$rootDir/src/test/resources"
}
}
}
tweaker {
compileClasspath += realmain.output + api.output + main.compileClasspath
runtimeClasspath += realmain.output + api.output + main.compileClasspath
}
main {
compileClasspath += realmain.output + api.output + tweaker.output
runtimeClasspath += realmain.output + api.output + tweaker.output
java {
java {
srcDir "$rootDir/src/launch/java"
}
resources {
srcDir "$rootDir/src/launch/resources"
}
}
}
schematica_api {
compileClasspath += realmain.compileClasspath
runtimeClasspath += realmain.runtimeClasspath
java {
java {
srcDir "$rootDir/src/schematica_api/java"
}
resources {
srcDir "$rootDir/src/schematica_api/resources"
}
}
}
realmain {
compileClasspath += schematica_api.output
runtimeClasspath += schematica_api.output
minecraft {
runs.client = {
mainClass = "net.minecraft.launchwrapper.Launch"
args.addAll(["--tweakClass", "baritone.launch.BaritoneTweaker"])
}
}
configurations {
transformProductionTweaker {
canBeConsumed = true
canBeResolved = false
// If you want this configuration to share the same dependencies, otherwise omit this line
extendsFrom implementation, runtimeOnly
}
common
shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this.
compileClasspath.extendsFrom common
runtimeClasspath.extendsFrom common
}
dependencies {
// We depend on fabric loader here to use the fabric @Environment annotations and get the mixin dependencies
// Do NOT use other classes from fabric loader
modCompileOnly "net.fabricmc:fabric-loader:${project.fabric_version}"
implementation "org.spongepowered:mixin:0.8.5"
// for some reason mixin isn't including these...
implementation "org.ow2.asm:asm:9.3"
implementation "org.ow2.asm:asm-tree:9.3"
implementation "org.ow2.asm:asm-commons:9.3"
implementation "org.ow2.asm:asm-util:9.3"
implementation "org.ow2.asm:asm-analysis:9.3"
// want in the pom but not to compile against as it's also provided by loom
runtimeOnly "org.spongepowered:mixin:0.8.4"
// this makes it compile with the forge tweak stuff
implementation 'com.github.ImpactDevelopment:SimpleTweaker:1.2'
implementation('net.minecraft:launchwrapper:of-2.3') {
exclude module: 'lwjgl'
@ -114,20 +56,21 @@ dependencies {
compileOnly 'com.google.code.findbugs:jsr305:3.0.2'
testImplementation 'junit:junit:4.12'
// because of multiple sourcesets `common project(":")` doesn't work
for (sourceSet in rootProject.sourceSets) {
if (sourceSet == rootProject.sourceSets.test) continue
common sourceSet.output
shadowCommon sourceSet.output
}
}
javadoc {
options.addStringOption('Xwerror', '-quiet') // makes the build fail on travis when there is a javadoc error
options.linkSource true
options.encoding "UTF-8" // allow emoji in comments :^)
source = sourceSets.api.allJava
classpath += sourceSets.api.compileClasspath
shadowJar {
configurations = [project.configurations.shadowCommon]
classifier "dev-shadow"
}
jar {
classifier "dev"
from sourceSets.main.output, sourceSets.realmain.output, sourceSets.api.output, sourceSets.tweaker.output
preserveFileTimestamps = false
reproducibleFileOrder = true
@ -143,10 +86,6 @@ jar {
}
}
remapJar {
targetNamespace = 'official'
}
task proguard(type: ProguardTask) {
url 'https://github.com/Guardsquare/proguard/releases/download/v7.2.1/proguard-7.2.1.zip'
extract 'proguard-7.2.1/lib/proguard.jar'