Skip to content

Commit

Permalink
Merge branch 'refs/heads/master' into ver/1.2.0
Browse files Browse the repository at this point in the history
# Conflicts:
#	build.gradle.kts
#	core/build.gradle.kts
  • Loading branch information
zlataovce committed May 9, 2024
2 parents 8897e2e + 20c86e2 commit 3d1082e
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 159 deletions.
33 changes: 0 additions & 33 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,25 +1,7 @@
import kotlinx.benchmark.gradle.JvmBenchmarkTarget

plugins {
id("takenaka.base-conventions")
id("takenaka.kotlin-conventions")
id("takenaka.publish-conventions")
alias(libs.plugins.kotlinx.benchmark)
alias(libs.plugins.kotlin.plugin.allopen)
}

sourceSets {
create("benchmark") {
compileClasspath += sourceSets.main.get().output
runtimeClasspath += sourceSets.main.get().output
}
}

val benchmarkImplementation by configurations.getting {
extendsFrom(configurations.implementation.get())
}
val benchmarkRuntimeOnly by configurations.getting {
extendsFrom(configurations.runtimeOnly.get())
}

dependencies {
Expand All @@ -31,23 +13,8 @@ dependencies {
implementation(libs.kotlinx.coroutines.core.jvm)
testImplementation(kotlin("test"))
testRuntimeOnly(libs.slf4j.simple)
benchmarkImplementation(libs.kotlinx.benchmark.runtime)
benchmarkRuntimeOnly(libs.slf4j.simple)
}

allOpen {
annotation("org.openjdk.jmh.annotations.State")
}

tasks.withType<Test> {
maxHeapSize = "2048m"
}

benchmark {
targets {
register("benchmark") {
this as JvmBenchmarkTarget
jmhVersion = libs.versions.jmh.get()
}
}
}

This file was deleted.

1 change: 0 additions & 1 deletion core/src/benchmark/resources/simplelogger.properties

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package me.kcra.takenaka.accessor.platform;

import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;

import java.lang.reflect.InvocationTargetException;
Expand All @@ -33,6 +34,43 @@
* @author Matouš Kučera
*/
public enum MapperPlatforms implements MapperPlatform {
/**
* A generic abstraction for Mojang software derivatives (Mojang mappings).
*/
MOJANG {
private String minecraftVersion = null;

{
try {
final Class<?> constClass = Class.forName("net.minecraft.SharedConstants", true, getClassLoader());
final Object gameVersion = constClass.getMethod("getCurrentVersion").invoke(null);

minecraftVersion = (String) gameVersion.getClass().getMethod("getName").invoke(gameVersion);
} catch (IllegalAccessException | InvocationTargetException e) {
throw new RuntimeException("Failed to get Minecraft version", e);
} catch (ClassNotFoundException | NoSuchMethodException ignored) {
}
}

@Override
public boolean isSupported() {
return minecraftVersion != null;
}

@Override
public @NotNull String getVersion() {
if (!isSupported()) {
throw new UnsupportedOperationException("Mojang is not supported by this environment");
}
return minecraftVersion;
}

@Override
public @NotNull String[] getMappingNamespaces() {
return new String[] { "mojang" };
}
},

/**
* An abstraction for platforms that implement the Bukkit API (Spigot mappings).
*/
Expand Down Expand Up @@ -84,39 +122,25 @@ public boolean isSupported() {

/**
* An abstraction for NeoForge-based platforms (Mojang mappings).
*
* @deprecated use {@link #MOJANG}
*/
@Deprecated
@ApiStatus.ScheduledForRemoval(inVersion = "2.0.0")
NEOFORGE {
private String minecraftVersion = null;

{
try {
final Class<?> neoFormVersionClass = Class.forName(
"net.neoforged.neoforge.internal.versions.neoform.NeoFormVersion",
true, getClassLoader()
);
minecraftVersion = (String) neoFormVersionClass.getMethod("getMCVersion").invoke(null);
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
throw new RuntimeException("Failed to get Minecraft version", e);
} catch (ClassNotFoundException ignored) {
}
}

@Override
public boolean isSupported() {
return minecraftVersion != null;
return MOJANG.isSupported();
}

@Override
public @NotNull String getVersion() {
if (!isSupported()) {
throw new UnsupportedOperationException("NeoForge is not supported by this environment");
}
return minecraftVersion;
return MOJANG.getVersion();
}

@Override
public @NotNull String[] getMappingNamespaces() {
return new String[] { "mojang" };
return MOJANG.getMappingNamespaces();
}
},

Expand Down
9 changes: 2 additions & 7 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
[versions]
kotlin = "1.9.22"
asm = "9.7"
jackson = "2.17.0"
jmh = "1.37"
kotlinx-benchmark = "0.4.10"
jackson = "2.17.1"
kotlinpoet = "1.16.0"

[libraries]
Expand All @@ -16,11 +14,10 @@ jackson-datatype-jsr310 = { group = "com.fasterxml.jackson.datatype", name = "ja
jackson-dataformat-xml = { group = "com.fasterxml.jackson.dataformat", name = "jackson-dataformat-xml", version.ref = "jackson" }
mapping-io = { group = "net.fabricmc", name = "mapping-io", version = "0.4.2" }
kotlin-logging-jvm = { group = "io.github.microutils", name = "kotlin-logging-jvm", version = "3.0.5" }
slf4j-simple = { group = "org.slf4j", name = "slf4j-simple", version = "2.0.12" }
slf4j-simple = { group = "org.slf4j", name = "slf4j-simple", version = "2.0.13" }
kotlinx-coroutines-core-jvm = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core-jvm", version = "1.8.0" }
kotlinx-html-jvm = { group = "org.jetbrains.kotlinx", name = "kotlinx-html-jvm", version = "0.11.0" }
kotlinx-cli-jvm = { group = "org.jetbrains.kotlinx", name = "kotlinx-cli-jvm", version = "0.3.6" }
kotlinx-benchmark-runtime = { group = "org.jetbrains.kotlinx", name = "kotlinx-benchmark-runtime", version.ref = "kotlinx-benchmark" }
jb-annotations = { group = "org.jetbrains", name = "annotations", version = "24.1.0" }
javapoet = { group = "com.squareup", name = "javapoet", version = "1.13.0" }
kotlinpoet = { group = "com.squareup", name = "kotlinpoet", version.ref = "kotlinpoet" }
Expand All @@ -36,7 +33,5 @@ jackson = ["jackson-module-kotlin", "jackson-datatype-jsr310", "jackson-dataform

[plugins]
shadow = { id = "io.github.goooler.shadow", version = "8.1.7" }
kotlinx-benchmark = { id = "org.jetbrains.kotlinx.benchmark", version.ref = "kotlinx-benchmark" }
kotlin-plugin-allopen = { id = "org.jetbrains.kotlin.plugin.allopen", version.ref = "kotlin" }
gradle-plugin-publish = { id = "com.gradle.plugin-publish", version = "1.2.1" }
build-config = { id = "com.github.gmazzo.buildconfig", version = "5.3.5" }

0 comments on commit 3d1082e

Please sign in to comment.