mirror of
https://github.com/YatopiaMC/Yatopia.git
synced 2024-09-18 10:31:25 +02:00
Merge branch 'ver/1.17' of https://github.com/YatopiaMC/Yatopia into ver/1.17
This commit is contained in:
commit
8553ecdd72
29
.github/workflows/build.yml
vendored
29
.github/workflows/build.yml
vendored
@ -5,10 +5,6 @@ on:
|
||||
paths-ignore:
|
||||
- '*.md'
|
||||
- 'Jenkinsfile'
|
||||
branches:
|
||||
- ver/1.17
|
||||
- dev/*
|
||||
- staging/1.17
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- '*.md'
|
||||
@ -44,21 +40,30 @@ jobs:
|
||||
path: ~/.gradle
|
||||
key: ${{ runner.os }}-mavenCache-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }}-openjdk-${{ matrix.java }}
|
||||
|
||||
- name: Configure git
|
||||
- name: Setup Yatopia Project
|
||||
run: |
|
||||
git config --global user.email "ci@github.com"
|
||||
git config --global user.name "Github CI"
|
||||
git config --global gc.auto 0
|
||||
sudo chmod -R -f 777 ./gradlew
|
||||
|
||||
- name: Apply Patches
|
||||
run: |
|
||||
./gradlew applyPatches
|
||||
|
||||
./gradlew initGitSubmodules
|
||||
|
||||
- name: Get MC Version
|
||||
run: echo "::set-output name=mcver::$(cat "Paper/work/BuildData/info.json" | grep minecraftVersion | cut -d '"' -f 4)"
|
||||
id: mcver
|
||||
|
||||
|
||||
- name: Pull Minecraft Decompile Cache
|
||||
uses: actions/cache@v2
|
||||
id: decompile-cache
|
||||
with:
|
||||
path: Paper/work/Minecraft/${{ steps.mcver.outputs.mcver }}
|
||||
key: ${{ hashFiles('Paper/work/BuildData/mappings/bukkit-$STEPS_MCVER_OUTPUTS_MCVER-cl.csrg') }}-${{ steps.mcver.outputs.mcver }}-${{ runner.os }}-openjdk-${{ matrix.java }}-minecraft-decomp
|
||||
|
||||
- name: Apply Patches
|
||||
run: |
|
||||
./gradlew setupUpstream
|
||||
./gradlew applyPatches
|
||||
|
||||
- name: Pull Maven Cache
|
||||
uses: actions/cache@v2
|
||||
id: maven-cache
|
||||
@ -68,7 +73,7 @@ jobs:
|
||||
|
||||
- name: Build Yatopia
|
||||
run: |
|
||||
./gradlew generatePaperclipPatch --no-build-cache
|
||||
./gradlew clean build paperclip --no-build-cache
|
||||
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-artifact@v2
|
||||
|
112
build.gradle.kts
112
build.gradle.kts
@ -1,64 +1,80 @@
|
||||
import org.yatopiamc.toothpick.*
|
||||
|
||||
plugins {
|
||||
java
|
||||
id("com.github.johnrengelman.shadow") version "7.0.0" apply false
|
||||
id("io.papermc.paperweight.patcher") version "1.0.0-SNAPSHOT"
|
||||
`java-library`
|
||||
`maven-publish`
|
||||
id("org.yatopiamc.toothpick") version "1.0.1-SNAPSHOT"
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven("https://wav.jfrog.io/artifactory/repo/") {
|
||||
content {
|
||||
onlyForConfigurations("paperclip")
|
||||
}
|
||||
toothpick {
|
||||
forkName = "Yatopia"
|
||||
groupId = "org.yatopiamc"
|
||||
val versionTag = System.getenv("BUILD_NUMBER")
|
||||
?: "\"${gitCmd("rev-parse", "--short", "HEAD").output}\""
|
||||
if(!System.getenv("BRANCH_NAME").isNullOrEmpty()) {
|
||||
currentBranch = System.getenv("BRANCH_NAME")
|
||||
} else if (!System.getenv("GITHUB_HEAD_REF").isNullOrEmpty()) {
|
||||
currentBranch = System.getenv("GITHUB_HEAD_REF")
|
||||
} else if (!System.getenv("GITHUB_REF").isNullOrEmpty()) {
|
||||
currentBranch = System.getenv("GITHUB_REF").substring("refs/heads/".length)
|
||||
} else {
|
||||
currentBranch = gitCmd("rev-parse", "--abbrev-ref", "HEAD").output.toString().trim()
|
||||
if(currentBranch == "HEAD") logger.warn("You are currently in \'detached HEAD\' state, branch information isn\'t available")
|
||||
}
|
||||
maven("https://maven.quiltmc.org/repository/release/") {
|
||||
content {
|
||||
onlyForConfigurations("remapper")
|
||||
}
|
||||
}
|
||||
}
|
||||
forkVersion = "git-$forkName-$currentBranch-$versionTag"
|
||||
forkUrl = "https://github.com/YatopiaMC/Yatopia"
|
||||
|
||||
dependencies {
|
||||
remapper("org.quiltmc:tiny-remapper:0.4.1")
|
||||
paperclip("io.papermc:paperclip:2.0.0-SNAPSHOT@jar")
|
||||
minecraftVersion = "1.17"
|
||||
nmsPackage = "1_17_R1"
|
||||
nmsRevision = "R0.1-SNAPSHOT"
|
||||
|
||||
upstream = "Paper"
|
||||
upstreamBranch = "origin/master"
|
||||
|
||||
paperclipName = "yatopia-$minecraftVersion-paperclip.jar"
|
||||
|
||||
patchCreditsOutput = "PATCHES.md"
|
||||
patchCreditsTemplate = ".template.md"
|
||||
|
||||
server {
|
||||
project = project(":$forkNameLowercase-server")
|
||||
patchesDir = rootProject.projectDir.resolve("patches/server")
|
||||
}
|
||||
api {
|
||||
project = project(":$forkNameLowercase-api")
|
||||
patchesDir = rootProject.projectDir.resolve("patches/api")
|
||||
}
|
||||
|
||||
logger.lifecycle("Configured version string: $calcVersionString")
|
||||
}
|
||||
|
||||
subprojects {
|
||||
apply(plugin = "java")
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion.set(JavaLanguageVersion.of(16))
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<JavaCompile>().configureEach {
|
||||
options.encoding = "UTF-8"
|
||||
options.release.set(16)
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven("https://oss.sonatype.org/content/groups/public/")
|
||||
maven("https://papermc.io/repo/repository/maven-public/")
|
||||
maven("https://ci.emc.gs/nexus/content/groups/aikar/")
|
||||
maven("https://repo.aikar.co/content/groups/aikar")
|
||||
maven("https://repo.md-5.net/content/repositories/releases/")
|
||||
maven("https://hub.spigotmc.org/nexus/content/groups/public/")
|
||||
maven("https://repo.aikar.co/content/groups/aikar/")
|
||||
maven("https://nexus.velocitypowered.com/repository/velocity-artifacts-snapshots/")
|
||||
maven("https://oss.sonatype.org/content/repositories/snapshots/")
|
||||
maven("https://libraries.minecraft.net")
|
||||
maven("https://repo.codemc.io/repository/maven-public/")
|
||||
maven("https://jitpack.io")
|
||||
maven("https://mvn.thearcanebrony.net/maven-public/")
|
||||
mavenLocal()
|
||||
maven("${rootProjectDir}/.repository")
|
||||
}
|
||||
}
|
||||
paperweight {
|
||||
serverProject.set(project(":Yatopia-Server"))
|
||||
|
||||
usePaperUpstream(providers.gradleProperty("paperCommit")) {
|
||||
withPaperPatcher {
|
||||
apiPatchDir.set(layout.projectDirectory.dir("patches/api"))
|
||||
apiOutputDir.set(layout.projectDirectory.dir("Yatopia-API"))
|
||||
|
||||
serverPatchDir.set(layout.projectDirectory.dir("patches/server"))
|
||||
serverOutputDir.set(layout.projectDirectory.dir("Yatopia-Server"))
|
||||
java {
|
||||
if(JavaVersion.VERSION_16 > JavaVersion.current()){
|
||||
error("This build must be run with Java 16 or newer")
|
||||
}
|
||||
sourceCompatibility = JavaVersion.VERSION_16
|
||||
targetCompatibility = JavaVersion.VERSION_16
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
tasks.withType<JavaCompile>().configureEach {
|
||||
options.isIncremental = true
|
||||
options.isFork = true
|
||||
options.encoding = "UTF-8"
|
||||
options.release.set(16)
|
||||
}
|
||||
}
|
||||
|
||||
|
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,7 +1,7 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.1-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
|
||||
# Check on https://gradle.org/release-checksums/
|
||||
distributionSha256Sum=dccda8aa069563c8ba2f6cdfd0777df0e34a5b4d15138ca8b9757e94f4e8a8cb
|
||||
distributionSha256Sum=0e46229820205440b48a5501122002842b82886e76af35f0f3a069243dca4b3c
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
135
mcdevimports.json
Normal file
135
mcdevimports.json
Normal file
@ -0,0 +1,135 @@
|
||||
{
|
||||
"nmsImports": [
|
||||
{
|
||||
"file": "HeightMap"
|
||||
}
|
||||
]
|
||||
"libraryImports": [
|
||||
{
|
||||
"group": "com.mojang",
|
||||
"library": "brigadier",
|
||||
"prefix": "com/mojang/brigadier",
|
||||
"file": "CommandDispatcher"
|
||||
},
|
||||
{
|
||||
"group": "com.mojang",
|
||||
"library": "brigadier",
|
||||
"prefix": "com/mojang/brigadier/tree",
|
||||
"file": "LiteralCommandNode"
|
||||
},
|
||||
{
|
||||
"group": "com.mojang",
|
||||
"library": "brigadier",
|
||||
"prefix": "com/mojang/brigadier/suggestion",
|
||||
"file": "SuggestionsBuilder"
|
||||
},
|
||||
{
|
||||
"group": "com.mojang",
|
||||
"library": "datafixerupper",
|
||||
"prefix": "com/mojang/datafixers",
|
||||
"file": "FieldFinder"
|
||||
},
|
||||
{
|
||||
"group": "com.mojang",
|
||||
"library": "datafixerupper",
|
||||
"prefix": "com/mojang/datafixers",
|
||||
"file": "DataFixUtils"
|
||||
},
|
||||
{
|
||||
"group": "com.mojang",
|
||||
"library": "datafixerupper",
|
||||
"prefix": "com/mojang/datafixers",
|
||||
"file": "TypeRewriteRule"
|
||||
},
|
||||
{
|
||||
"group": "com.mojang",
|
||||
"library": "datafixerupper",
|
||||
"prefix": "com/mojang/datafixers",
|
||||
"file": "Typed"
|
||||
},
|
||||
{
|
||||
"group": "com.mojang",
|
||||
"library": "datafixerupper",
|
||||
"prefix": "com/mojang/datafixers",
|
||||
"file": "TypedOptic"
|
||||
},
|
||||
{
|
||||
"group": "com.mojang",
|
||||
"library": "datafixerupper",
|
||||
"prefix": "com/mojang/datafixers",
|
||||
"file": "View"
|
||||
},
|
||||
{
|
||||
"group": "com.mojang",
|
||||
"library": "datafixerupper",
|
||||
"prefix": "com/mojang/datafixers",
|
||||
"file": "FieldFinder"
|
||||
},
|
||||
{
|
||||
"group": "com.mojang",
|
||||
"library": "datafixerupper",
|
||||
"prefix": "com/mojang/datafixers/functions",
|
||||
"file": "Apply"
|
||||
},
|
||||
{
|
||||
"group": "com.mojang",
|
||||
"library": "datafixerupper",
|
||||
"prefix": "com/mojang/datafixers/functions",
|
||||
"file": "Comp"
|
||||
},
|
||||
{
|
||||
"group": "com.mojang",
|
||||
"library": "datafixerupper",
|
||||
"prefix": "com/mojang/datafixers/functions",
|
||||
"file": "PointFree"
|
||||
},
|
||||
{
|
||||
"group": "com.mojang",
|
||||
"library": "datafixerupper",
|
||||
"prefix": "com/mojang/datafixers/functions",
|
||||
"file": "PointFreeRule"
|
||||
},
|
||||
{
|
||||
"group": "com.mojang",
|
||||
"library": "datafixerupper",
|
||||
"prefix": "com/mojang/datafixers/optics",
|
||||
"file": "IdAdapter"
|
||||
},
|
||||
{
|
||||
"group": "com.mojang",
|
||||
"library": "datafixerupper",
|
||||
"prefix": "com/mojang/datafixers/optics",
|
||||
"file": "Inj1"
|
||||
},
|
||||
{
|
||||
"group": "com.mojang",
|
||||
"library": "datafixerupper",
|
||||
"prefix": "com/mojang/datafixers/optics",
|
||||
"file": "Inj2"
|
||||
},
|
||||
{
|
||||
"group": "com.mojang",
|
||||
"library": "datafixerupper",
|
||||
"prefix": "com/mojang/datafixers/optics",
|
||||
"file": "Optics"
|
||||
},
|
||||
{
|
||||
"group": "com.mojang",
|
||||
"library": "datafixerupper",
|
||||
"prefix": "com/mojang/datafixers/optics",
|
||||
"file": "Proj1"
|
||||
},
|
||||
{
|
||||
"group": "com.mojang",
|
||||
"library": "datafixerupper",
|
||||
"prefix": "com/mojang/datafixers/optics",
|
||||
"file": "Proj2"
|
||||
},
|
||||
{
|
||||
"group": "com.mojang",
|
||||
"library": "datafixerupper",
|
||||
"prefix": "com/mojang/datafixers/types",
|
||||
"file": "Type"
|
||||
}
|
||||
]
|
||||
}
|
@ -1,262 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: snoopdoooggyttv <snoopdoooggyttv@users.noreply.github.com>
|
||||
Date: Wed, 5 May 2021 20:32:22 +0200
|
||||
Subject: [PATCH] Fix Log4j Warning
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/apache/logging/log4j/util/StackLocator.java b/src/main/java/org/apache/logging/log4j/util/StackLocator.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..44161840e64946b4b6ce0483495304809d15ade8
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/apache/logging/log4j/util/StackLocator.java
|
||||
@@ -0,0 +1,250 @@
|
||||
+/*
|
||||
+ * Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
+ * contributor license agreements. See the NOTICE file distributed with
|
||||
+ * this work for additional information regarding copyright ownership.
|
||||
+ * The ASF licenses this file to You under the Apache license, Version 2.0
|
||||
+ * (the "License"); you may not use this file except in compliance with
|
||||
+ * the License. You may obtain a copy of the License at
|
||||
+ *
|
||||
+ * http://www.apache.org/licenses/LICENSE-2.0
|
||||
+ *
|
||||
+ * Unless required by applicable law or agreed to in writing, software
|
||||
+ * distributed under the License is distributed on an "AS IS" BASIS,
|
||||
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
+ * See the license for the specific language governing permissions and
|
||||
+ * limitations under the license.
|
||||
+ */
|
||||
+package org.apache.logging.log4j.util;
|
||||
+
|
||||
+import java.lang.reflect.Method;
|
||||
+import java.util.Stack;
|
||||
+
|
||||
+/**
|
||||
+ * <em>Consider this class private.</em> Provides various methods to determine the caller class. <h3>Background</h3>
|
||||
+ * <p>
|
||||
+ * This method, available only in the Oracle/Sun/OpenJDK implementations of the Java Virtual Machine, is a much more
|
||||
+ * efficient mechanism for determining the {@link Class} of the caller of a particular method. When it is not available,
|
||||
+ * a {@link SecurityManager} is the second-best option. When this is also not possible, the {@code StackTraceElement[]}
|
||||
+ * returned by {@link Throwable#getStackTrace()} must be used, and its {@code String} class name converted to a
|
||||
+ * {@code Class} using the slow {@link Class#forName} (which can add an extra microsecond or more for each invocation
|
||||
+ * depending on the runtime ClassLoader hierarchy).
|
||||
+ * </p>
|
||||
+ * <p>
|
||||
+ * During Java 8 development, the {@code sun.reflect.Reflection.getCallerClass(int)} was removed from OpenJDK, and this
|
||||
+ * change was back-ported to Java 7 in version 1.7.0_25 which changed the behavior of the call and caused it to be off
|
||||
+ * by one stack frame. This turned out to be beneficial for the survival of this API as the change broke hundreds of
|
||||
+ * libraries and frameworks relying on the API which brought much more attention to the intended API removal.
|
||||
+ * </p>
|
||||
+ * <p>
|
||||
+ * After much community backlash, the JDK team agreed to restore {@code getCallerClass(int)} and keep its existing
|
||||
+ * behavior for the rest of Java 7. However, the method is deprecated in Java 8, and current Java 9 development has not
|
||||
+ * addressed this API. Therefore, the functionality of this class cannot be relied upon for all future versions of Java.
|
||||
+ * It does, however, work just fine in Sun JDK 1.6, OpenJDK 1.6, Oracle/OpenJDK 1.7, and Oracle/OpenJDK 1.8. Other Java
|
||||
+ * environments may fall back to using {@link Throwable#getStackTrace()} which is significantly slower due to
|
||||
+ * examination of every virtual frame of execution.
|
||||
+ * </p>
|
||||
+ */
|
||||
+public final class StackLocator {
|
||||
+
|
||||
+ // Checkstyle Suppress: the lower-case 'u' ticks off CheckStyle...
|
||||
+ // CHECKSTYLE:OFF
|
||||
+ static final int JDK_7u25_OFFSET;
|
||||
+ // CHECKSTYLE:OFF
|
||||
+
|
||||
+ private static final Method GET_CALLER_CLASS;
|
||||
+
|
||||
+ private static final StackLocator INSTANCE;
|
||||
+
|
||||
+ static {
|
||||
+ Method getCallerClass;
|
||||
+ int java7u25CompensationOffset = 0;
|
||||
+ try {
|
||||
+ final Class<?> sunReflectionClass = LoaderUtil.loadClass("sun.reflect.Reflection");
|
||||
+ getCallerClass = sunReflectionClass.getDeclaredMethod("getCallerClass", int.class);
|
||||
+ Object o = getCallerClass.invoke(null, 0);
|
||||
+ getCallerClass.invoke(null, 0);
|
||||
+ if (o == null || o != sunReflectionClass) {
|
||||
+ getCallerClass = null;
|
||||
+ java7u25CompensationOffset = -1;
|
||||
+ } else {
|
||||
+ o = getCallerClass.invoke(null, 1);
|
||||
+ if (o == sunReflectionClass) {
|
||||
+ System.out.println("WARNING: Java 1.7.0_25 is in use which has a broken implementation of Reflection.getCallerClass(). " +
|
||||
+ " Please consider upgrading to Java 1.7.0_40 or later.");
|
||||
+ java7u25CompensationOffset = 1;
|
||||
+ }
|
||||
+ }
|
||||
+ } catch (final Exception | LinkageError e) {
|
||||
+ //System.out.println("WARNING: sun.reflect.Reflection.getCallerClass is not supported. This will impact performance."); // Yatopia - Fix Error Message
|
||||
+ getCallerClass = null;
|
||||
+ java7u25CompensationOffset = -1;
|
||||
+ }
|
||||
+
|
||||
+ GET_CALLER_CLASS = getCallerClass;
|
||||
+ JDK_7u25_OFFSET = java7u25CompensationOffset;
|
||||
+
|
||||
+ INSTANCE = new StackLocator();
|
||||
+ }
|
||||
+
|
||||
+ public static StackLocator getInstance() {
|
||||
+ return INSTANCE;
|
||||
+ }
|
||||
+
|
||||
+ private StackLocator() {
|
||||
+ }
|
||||
+
|
||||
+ // TODO: return Object.class instead of null (though it will have a null ClassLoader)
|
||||
+ // (MS) I believe this would work without any modifications elsewhere, but I could be wrong
|
||||
+
|
||||
+ // migrated from ReflectiveCallerClassUtility
|
||||
+ @PerformanceSensitive
|
||||
+ public Class<?> getCallerClass(final int depth) {
|
||||
+ if (depth < 0) {
|
||||
+ throw new IndexOutOfBoundsException(Integer.toString(depth));
|
||||
+ }
|
||||
+ if (GET_CALLER_CLASS == null) {
|
||||
+ return null;
|
||||
+ }
|
||||
+ // note that we need to add 1 to the depth value to compensate for this method, but not for the Method.invoke
|
||||
+ // since Reflection.getCallerClass ignores the call to Method.invoke()
|
||||
+ try {
|
||||
+ return (Class<?>) GET_CALLER_CLASS.invoke(null, depth + 1 + JDK_7u25_OFFSET);
|
||||
+ } catch (final Exception e) {
|
||||
+ // theoretically this could happen if the caller class were native code
|
||||
+ // TODO: return Object.class
|
||||
+ return null;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ // migrated from Log4jLoggerFactory
|
||||
+ @PerformanceSensitive
|
||||
+ public Class<?> getCallerClass(final String fqcn, final String pkg) {
|
||||
+ return getCallerClass(fqcn, pkg, 0);
|
||||
+ }
|
||||
+
|
||||
+ @PerformanceSensitive
|
||||
+ public Class<?> getCallerClass(final String fqcn, final String pkg, final int skipDepth) {
|
||||
+ if (skipDepth < 0) {
|
||||
+ throw new IllegalArgumentException("skipDepth cannot be negative");
|
||||
+ }
|
||||
+ boolean next = false;
|
||||
+ Class<?> clazz;
|
||||
+ for (int i = 2; null != (clazz = getCallerClass(i)); i++) {
|
||||
+ if (fqcn.equals(clazz.getName())) {
|
||||
+ next = true;
|
||||
+ continue;
|
||||
+ }
|
||||
+ if (next && clazz.getName().startsWith(pkg)) {
|
||||
+ return skipDepth == 0
|
||||
+ ? clazz
|
||||
+ : getCallerClass(i + skipDepth);
|
||||
+ }
|
||||
+ }
|
||||
+ // TODO: return Object.class
|
||||
+ return null;
|
||||
+ }
|
||||
+
|
||||
+ // added for use in LoggerAdapter implementations mainly
|
||||
+ @PerformanceSensitive
|
||||
+ public Class<?> getCallerClass(final Class<?> anchor) {
|
||||
+ boolean next = false;
|
||||
+ Class<?> clazz;
|
||||
+ for (int i = 2; null != (clazz = getCallerClass(i)); i++) {
|
||||
+ if (anchor.equals(clazz)) {
|
||||
+ next = true;
|
||||
+ continue;
|
||||
+ }
|
||||
+ if (next) {
|
||||
+ return clazz;
|
||||
+ }
|
||||
+ }
|
||||
+ return Object.class;
|
||||
+ }
|
||||
+
|
||||
+ // migrated from ThrowableProxy
|
||||
+ @PerformanceSensitive
|
||||
+ public Stack<Class<?>> getCurrentStackTrace() {
|
||||
+ // benchmarks show that using the SecurityManager is much faster than looping through getCallerClass(int)
|
||||
+ if (PrivateSecurityManagerStackTraceUtil.isEnabled()) {
|
||||
+ return PrivateSecurityManagerStackTraceUtil.getCurrentStackTrace();
|
||||
+ }
|
||||
+ // slower version using getCallerClass where we cannot use a SecurityManager
|
||||
+ final Stack<Class<?>> classes = new Stack<>();
|
||||
+ Class<?> clazz;
|
||||
+ for (int i = 1; null != (clazz = getCallerClass(i)); i++) {
|
||||
+ classes.push(clazz);
|
||||
+ }
|
||||
+ return classes;
|
||||
+ }
|
||||
+
|
||||
+ public StackTraceElement calcLocation(final String fqcnOfLogger) {
|
||||
+ if (fqcnOfLogger == null) {
|
||||
+ return null;
|
||||
+ }
|
||||
+ // LOG4J2-1029 new Throwable().getStackTrace is faster than Thread.currentThread().getStackTrace().
|
||||
+ final StackTraceElement[] stackTrace = new Throwable().getStackTrace();
|
||||
+ boolean found = false;
|
||||
+ for (int i = 0; i < stackTrace.length; i++) {
|
||||
+ final String className = stackTrace[i].getClassName();
|
||||
+ if (fqcnOfLogger.equals(className)) {
|
||||
+
|
||||
+ found = true;
|
||||
+ continue;
|
||||
+ }
|
||||
+ if (found && !fqcnOfLogger.equals(className)) {
|
||||
+ return stackTrace[i];
|
||||
+ }
|
||||
+ }
|
||||
+ return null;
|
||||
+ }
|
||||
+
|
||||
+ public StackTraceElement getStackTraceElement(final int depth) {
|
||||
+ // (MS) I tested the difference between using Throwable.getStackTrace() and Thread.getStackTrace(), and
|
||||
+ // the version using Throwable was surprisingly faster! at least on Java 1.8. See ReflectionBenchmark.
|
||||
+ final StackTraceElement[] elements = new Throwable().getStackTrace();
|
||||
+ int i = 0;
|
||||
+ for (final StackTraceElement element : elements) {
|
||||
+ if (isValid(element)) {
|
||||
+ if (i == depth) {
|
||||
+ return element;
|
||||
+ }
|
||||
+ ++i;
|
||||
+ }
|
||||
+ }
|
||||
+ throw new IndexOutOfBoundsException(Integer.toString(depth));
|
||||
+ }
|
||||
+
|
||||
+ private boolean isValid(final StackTraceElement element) {
|
||||
+ // ignore native methods (oftentimes are repeated frames)
|
||||
+ if (element.isNativeMethod()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ final String cn = element.getClassName();
|
||||
+ // ignore OpenJDK internal classes involved with reflective invocation
|
||||
+ if (cn.startsWith("sun.reflect.")) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ final String mn = element.getMethodName();
|
||||
+ // ignore use of reflection including:
|
||||
+ // Method.invoke
|
||||
+ // InvocationHandler.invoke
|
||||
+ // Constructor.newInstance
|
||||
+ if (cn.startsWith("java.lang.reflect.") && (mn.equals("invoke") || mn.equals("newInstance"))) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // ignore use of Java 1.9+ reflection classes
|
||||
+ if (cn.startsWith("jdk.internal.reflect.")) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // ignore Class.newInstance
|
||||
+ if (cn.equals("java.lang.Class") && mn.equals("newInstance")) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // ignore use of Java 1.7+ MethodHandle.invokeFoo() methods
|
||||
+ if (cn.equals("java.lang.invoke.MethodHandle") && mn.startsWith("invoke")) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // any others?
|
||||
+ return true;
|
||||
+ }
|
||||
+}
|
@ -1,10 +1,30 @@
|
||||
import java.util.Locale
|
||||
|
||||
val forkName = "Yatopia"
|
||||
val forkNameLowercase = forkName.toLowerCase(Locale.ENGLISH)
|
||||
|
||||
rootProject.name = forkNameLowercase
|
||||
|
||||
pluginManagement {
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
maven("https://wav.jfrog.io/artifactory/repo/")
|
||||
maven("https://mvn.thearcanebrony.net/repository/maven-public/")
|
||||
maven("https://jitpack.io/")
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = "Yatopia"
|
||||
setupSubproject("$forkNameLowercase-api") {
|
||||
projectDir = File("$forkName-API")
|
||||
buildFileName = "../subprojects/api.gradle.kts"
|
||||
}
|
||||
setupSubproject("$forkNameLowercase-server") {
|
||||
projectDir = File("$forkName-Server")
|
||||
buildFileName = "../subprojects/server.gradle.kts"
|
||||
}
|
||||
setupSubproject("Yatoclip") { }
|
||||
|
||||
include("Yatopia-API", "Yatopia-Server")
|
||||
inline fun setupSubproject(name: String, block: ProjectDescriptor.() -> Unit) {
|
||||
include(name)
|
||||
project(":$name").apply(block)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user