From 5395ec40c1f01e6bc37bd333c78bf44c7f28fa4c Mon Sep 17 00:00:00 2001 From: RaphiMC <50594595+RaphiMC@users.noreply.github.com> Date: Thu, 12 Jan 2023 18:48:45 +0100 Subject: [PATCH] Cursed Java 17 compatibility --- build.gradle | 15 +++++++-- src/java17compat/java/java/lang/Record.java | 37 +++++++++++++++++++++ 2 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 src/java17compat/java/java/lang/Record.java diff --git a/build.gradle b/build.gradle index b8abc4f..f51f212 100644 --- a/build.gradle +++ b/build.gradle @@ -4,10 +4,17 @@ plugins { id "net.kyori.blossom" version "1.3.1" } +sourceSets { + java17compat +} + java.toolchain.languageVersion = JavaLanguageVersion.of(17) -compileJava.sourceCompatibility = JavaVersion.VERSION_1_8 -compileJava.targetCompatibility = JavaVersion.VERSION_1_8 -compileJava.options.encoding = compileTestJava.options.encoding = javadoc.options.encoding = "UTF-8" +[compileJava, compileTestJava, compileJava17compatJava].each { + it.options.encoding = "UTF-8" + it.sourceCompatibility = JavaVersion.VERSION_1_8 + it.targetCompatibility = JavaVersion.VERSION_1_8 +} +javadoc.options.encoding = "UTF-8" group = project.maven_group archivesBaseName = project.maven_name @@ -50,6 +57,8 @@ repositories { } dependencies { + compileOnly sourceSets.java17compat.output + include "com.viaversion:viaversion:4.5.2-SNAPSHOT" include("com.viaversion:viabackwards-common:4.5.2-SNAPSHOT") { exclude group: "com.viaversion", module: "viaversion" diff --git a/src/java17compat/java/java/lang/Record.java b/src/java17compat/java/java/lang/Record.java new file mode 100644 index 0000000..98bd836 --- /dev/null +++ b/src/java17compat/java/java/lang/Record.java @@ -0,0 +1,37 @@ +/* + * This file is part of ViaProxy - https://github.com/RaphiMC/ViaProxy + * Copyright (C) 2023 RK_01/RaphiMC and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package java.lang; + +/** + * Dummy class to make IntelliJ able to access records in Java 8 code + */ +public abstract class Record { + + protected Record() { + } + + @Override + public abstract boolean equals(Object obj); + + @Override + public abstract int hashCode(); + + @Override + public abstract String toString(); + +}