Adjust dependency loading and relocations (#234)

This commit is contained in:
Jason authored and GitHub committed 2023-03-27 16:16:48 -07:00
1 parent 2ee7c85a35
commit 1397cd4c4f
7 files changed
+57 -62

No files matched your search

@@ -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);
}
}