mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-01 22:15:08 +00:00
Adjust dependency loading and relocations (#234)
This commit is contained in:
1 parent
2ee7c85a35
commit
1397cd4c4f
7 files changed
+57
-62
No files matched your search
@@ -45,6 +45,8 @@ class PaperPluginDescription(project: Project) : PluginDescription {
|
||||
@Input
|
||||
var main: String? = null
|
||||
@Input
|
||||
var loader: String? = null
|
||||
@Input
|
||||
@Optional
|
||||
var description: String? = null
|
||||
@Input
|
||||
|
||||
@@ -12,6 +12,7 @@ tasks {
|
||||
shadowJar {
|
||||
archiveClassifier.set(null as String?)
|
||||
configureShadowJar()
|
||||
mergeServiceFiles()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,12 +31,12 @@ fun ShadowJar.standardRelocations() {
|
||||
relocateDependency("redis.clients.jedis")
|
||||
relocateDependency("ninja.egg82.messenger")
|
||||
relocateDependency("org.antlr")
|
||||
//relocateDependency("com.github.luben")
|
||||
//relocateDependency("io.netty")
|
||||
relocateDependency("io.nats")
|
||||
relocateDependency("com.rabbitmq")
|
||||
relocateDependency("com.electronwill")
|
||||
relocateDependency("net.byteflux")
|
||||
relocateDependency("net.i2p.crypto")
|
||||
relocateDependency("org.apache.commons.pool2")
|
||||
relocateDependency("org.flywaydb")
|
||||
}
|
||||
|
||||
fun ShadowJar.relocateCloud() {
|
||||
@@ -53,15 +53,16 @@ fun ShadowJar.configureShadowJar() {
|
||||
//minimize()
|
||||
standardRelocations()
|
||||
dependencies {
|
||||
// not needed at runtime
|
||||
// not needed or provided by platform at runtime
|
||||
exclude(dependency("com.google.code.findbugs:jsr305"))
|
||||
exclude(dependency("com.google.errorprone:error_prone_annotations"))
|
||||
exclude(dependency("com.google.guava:guava"))
|
||||
exclude { it.moduleGroup == "com.google.guava" }
|
||||
exclude(dependency("com.google.j2objc:j2objc-annotations"))
|
||||
exclude(dependency("io.netty:netty-all"))
|
||||
exclude(dependency("io.netty:netty-buffer"))
|
||||
exclude(dependency("it.unimi.dsi:fastutil"))
|
||||
exclude(dependency("org.checkerframework:checker-qual"))
|
||||
exclude(dependency("org.slf4j:slf4j-api"))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,6 @@ versions:
|
||||
rabbitmq: 5.13.1
|
||||
nats: 2.12.0
|
||||
pluginYml: 0.5.3
|
||||
libby: 1.1.5
|
||||
|
||||
dependencies:
|
||||
adventureBom:
|
||||
@@ -328,9 +327,4 @@ dependencies:
|
||||
name: discordsrv
|
||||
version: { ref: discordsrv }
|
||||
|
||||
libbyBukkit:
|
||||
group: net.byteflux
|
||||
name: libby-bukkit
|
||||
version: { ref: libby }
|
||||
|
||||
bundles:
|
||||
@@ -1,5 +1,3 @@
|
||||
import net.minecrell.pluginyml.bukkit.BukkitPluginDescription
|
||||
|
||||
plugins {
|
||||
id("carbon.shadow-platform")
|
||||
id("net.minecrell.plugin-yml.bukkit")
|
||||
@@ -20,7 +18,6 @@ dependencies {
|
||||
|
||||
// Misc
|
||||
implementation(libs.bstatsBukkit)
|
||||
implementation(libs.libbyBukkit)
|
||||
|
||||
// Plugins
|
||||
compileOnly("me.clip:placeholderapi:2.10.9") // TODO: move this to libs.versions.yml
|
||||
@@ -45,6 +42,7 @@ tasks {
|
||||
paper {
|
||||
name = rootProject.name
|
||||
version = project.version as String
|
||||
loader = "net.draycia.carbon.paper.CarbonPaperLoader"
|
||||
main = "net.draycia.carbon.paper.CarbonPaperBootstrap"
|
||||
apiVersion = "1.19"
|
||||
author = "Draycia"
|
||||
@@ -70,8 +68,6 @@ bukkit {
|
||||
|
||||
carbonPermission.permissions.get().forEach {
|
||||
setOf(bukkit.permissions, paper.permissions).forEach { container ->
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
container as NamedDomainObjectContainer<BukkitPluginDescription.Permission>
|
||||
container.register(it.string) {
|
||||
description = it.description
|
||||
childrenMap = it.children
|
||||
|
||||
@@ -20,8 +20,6 @@
|
||||
package net.draycia.carbon.paper;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import net.byteflux.libby.BukkitLibraryManager;
|
||||
import net.byteflux.libby.Library;
|
||||
import net.draycia.carbon.api.CarbonChatProvider;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
@@ -35,8 +33,6 @@ public final class CarbonPaperBootstrap extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
this.loadLibraries();
|
||||
|
||||
this.carbonChat = Guice.createInjector(new CarbonChatPaperModule(this))
|
||||
.getInstance(CarbonChatPaper.class);
|
||||
CarbonChatProvider.register(this.carbonChat);
|
||||
@@ -56,46 +52,4 @@ public final class CarbonPaperBootstrap extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
private void loadLibraries() {
|
||||
final BukkitLibraryManager libraryManager = new BukkitLibraryManager(this);
|
||||
libraryManager.addMavenCentral();
|
||||
libraryManager.addSonatype();
|
||||
|
||||
// TODO: move this into common, supply library manager
|
||||
final Library messenger = Library.builder()
|
||||
.groupId("com.github.luben")
|
||||
.artifactId("zstd-jni")
|
||||
.version("1.5.1-1")
|
||||
.build();
|
||||
|
||||
libraryManager.loadLibrary(messenger);
|
||||
|
||||
final Library guava = Library.builder()
|
||||
.groupId("com.google.guava")
|
||||
.artifactId("guava")
|
||||
.version("30.1-jre")
|
||||
.relocate("com.google.common", "net.draycia.carbon.libs.com.google.common")
|
||||
.build();
|
||||
|
||||
libraryManager.loadLibrary(guava);
|
||||
|
||||
final Library protobuf = Library.builder()
|
||||
.groupId("com.google.protobuf")
|
||||
.artifactId("protobuf-java")
|
||||
.version("3.21.12")
|
||||
.relocate("com.google.protobuf", "net.draycia.carbon.libs.com.google.protobuf")
|
||||
.build();
|
||||
|
||||
libraryManager.loadLibrary(protobuf);
|
||||
|
||||
final Library mysqlConnector = Library.builder()
|
||||
.groupId("com.mysql")
|
||||
.artifactId("mysql-connector-j")
|
||||
.version("8.0.31")
|
||||
//.relocate("mysql-connector-j", "net.draycia.carbon.libs.mysql")
|
||||
.build();
|
||||
|
||||
libraryManager.loadLibrary(mysqlConnector);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* CarbonChat
|
||||
*
|
||||
* Copyright (c) 2023 Josua Parks (Vicarious)
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.draycia.carbon.paper;
|
||||
|
||||
import io.papermc.paper.plugin.loader.PluginClasspathBuilder;
|
||||
import io.papermc.paper.plugin.loader.PluginLoader;
|
||||
import io.papermc.paper.plugin.loader.library.impl.MavenLibraryResolver;
|
||||
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
import org.eclipse.aether.artifact.DefaultArtifact;
|
||||
import org.eclipse.aether.graph.Dependency;
|
||||
import org.eclipse.aether.repository.RemoteRepository;
|
||||
import org.springframework.lang.NonNull;
|
||||
|
||||
@DefaultQualifier(NonNull.class)
|
||||
public class CarbonPaperLoader implements PluginLoader {
|
||||
|
||||
@Override
|
||||
public void classloader(final PluginClasspathBuilder classpathBuilder) {
|
||||
final MavenLibraryResolver maven = new MavenLibraryResolver();
|
||||
|
||||
maven.addRepository(new RemoteRepository.Builder("paper", "default", "https://repo.papermc.io/repository/maven-public/").build());
|
||||
|
||||
maven.addDependency(new Dependency(new DefaultArtifact("com.github.luben:zstd-jni:1.5.1-1"), null));
|
||||
maven.addDependency(new Dependency(new DefaultArtifact("com.google.protobuf:protobuf-java:3.21.12"), null));
|
||||
maven.addDependency(new Dependency(new DefaultArtifact("com.mysql:mysql-connector-j:8.0.31"), null));
|
||||
|
||||
classpathBuilder.addLibrary(maven);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user