Download dependencies at runtime on all platforms (not just Paper), and read dependency info from file in plugin jar generated by Gradle task (#259)

* Download dependencies at runtime on all platforms (not just Paper), and read dependency info from file in plugin jar generated by Gradle task

* Add maven central as fallback for paper mirror

* filter duplicate dependencies

* fix fabric runServer

* add todo

* enable hangar publishing

* - exclude unneeded deps from runtime dl
- sort deps and relocations in the list file
- other misc fixes

* move jdbi relocation

* don't log anything when we don't download or relocate any dependencies

* add back mariadb driver and download more dependencies at runtime

and other related build changes

* build cleanup

* build cleanup

* remove useless dependencies block
This commit is contained in:
Jason authored and GitHub committed 2023-07-04 00:24:00 -07:00
1 parent 82c22a08fa
commit 307395ce5b
16 files changed
+694 -95

No files matched your search

@@ -20,17 +20,53 @@
package net.draycia.carbon.fabric;
import com.google.inject.Guice;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.nio.file.Path;
import java.util.Objects;
import net.draycia.carbon.api.CarbonChatProvider;
import net.draycia.carbon.common.util.DependencyDownloader;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.launch.common.FabricLauncherBase;
import org.apache.logging.log4j.LogManager;
public class CarbonFabricBootstrap implements ModInitializer {
@Override
public void onInitialize() {
this.loadDependencies();
final CarbonChatFabric carbonChat = Guice.createInjector(new CarbonChatFabricModule())
.getInstance(CarbonChatFabric.class);
CarbonChatProvider.register(carbonChat);
carbonChat.onInitialize();
}
private void loadDependencies() {
final DependencyDownloader downloader = new DependencyDownloader(
LogManager.getLogger(this.getClass().getSimpleName()),
FabricLoader.getInstance().getConfigDir().resolve("carbonchat").resolve("libraries")
);
try (final InputStream stream = Objects.requireNonNull(this.getClass().getClassLoader().getResourceAsStream("carbon-dependencies.list"))) {
downloader.load(stream);
} catch (final IOException ex) {
throw new RuntimeException("Couldn't load dependencies", ex);
}
for (final Path dep : downloader.resolve()) {
addJarToClasspath(dep);
}
}
private static void addJarToClasspath(final Path file) {
try {
FabricLauncherBase.getLauncher().propose(file.toUri().toURL());
} catch (final MalformedURLException e) {
throw new RuntimeException(e);
}
}
}