From 9897f7029dc3ced4b837d1483fdda7836e169e07 Mon Sep 17 00:00:00 2001 From: Vankka Date: Tue, 11 Jul 2023 19:50:19 +0300 Subject: [PATCH] Relocate kotlin, update OkHTTP, exclude dependencies in bulk --- api/build.gradle | 7 ----- build.gradle | 11 ++++++++ buildscript/relocations.gradle | 3 ++ common/build.gradle | 51 +++++++++++++++++++++++----------- settings.gradle | 7 ++--- 5 files changed, 52 insertions(+), 27 deletions(-) diff --git a/api/build.gradle b/api/build.gradle index e5a0e4ae..8de186a3 100644 --- a/api/build.gradle +++ b/api/build.gradle @@ -8,13 +8,6 @@ dependencies { // JDA api(libs.jda) { - // Annotations are suppose to be compile time only - exclude group: 'org.jetbrains', module: 'annotations' - exclude group: 'com.google.code.findbugs', module: 'jsr305' - - // Downgrade okhttp (due to kotlin) - exclude group: 'com.squareup.okhttp3', module: 'okhttp' - // We don't use audio exclude module: 'opus-java' } diff --git a/build.gradle b/build.gradle index 16a22784..ace73830 100644 --- a/build.gradle +++ b/build.gradle @@ -26,6 +26,17 @@ subprojects { } configurations { + // Exclude dependencies from being included in jars + runtimeExclude { + // Annotations are suppose to be compile time only + exclude group: 'org.jetbrains', module: 'annotations' + exclude group: 'com.google.code.findbugs', module: 'jsr305' + exclude group: 'com.google.errorprone', module: 'error_prone_annotations' + } + runtimeClasspath.extendsFrom runtimeExclude + runtimeDownloadOnly.extendsFrom runtimeExclude + + // Create runtimeDownloadApi configuration (compileOnlyApi + runtimeDownloadOnly) runtimeDownloadApi compileOnlyApi.extendsFrom runtimeDownloadApi runtimeDownloadOnly.extendsFrom runtimeDownloadApi diff --git a/buildscript/relocations.gradle b/buildscript/relocations.gradle index 6e203b82..83b5c9da 100644 --- a/buildscript/relocations.gradle +++ b/buildscript/relocations.gradle @@ -16,6 +16,9 @@ 'okhttp3', 'okio', + // Kotlin + 'kotlin', + // DependencyDownload 'dev.vankka.dependencydownload', 'dev.vankka.mcdependencydownload', diff --git a/common/build.gradle b/common/build.gradle index 947b609e..59e79d04 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -1,12 +1,27 @@ import dev.vankka.dependencydownload.task.GenerateDependencyDownloadResourceTask configurations { - hikari - h2Driver - mysqlDriver - mariadbDriver - mcAuthLib - compileOnly.extendsFrom hikari, h2Driver, mysqlDriver, mariadbDriver, mcAuthLib + // Dependencies to exclude from runtime downloaded jars + runtimeDownloadExclude { + extendsFrom runtimeExclude + } + + hikariOnly + hikari.extendsFrom hikariOnly, runtimeDownloadExclude + + h2DriverOnly + h2Driver.extendsFrom h2DriverOnly, runtimeDownloadExclude + + mysqlDriverOnly + mysqlDriver.extendsFrom mysqlDriverOnly, runtimeDownloadExclude + + mariadbDriverOnly + mariadbDriver.extendsFrom mariadbDriverOnly, runtimeDownloadExclude + + mcAuthLibOnly + mcAuthLib.extendsFrom mcAuthLibOnly, runtimeDownloadExclude + + compileOnly.extendsFrom hikariOnly, h2DriverOnly, mysqlDriverOnly, mariadbDriverOnly, mcAuthLibOnly testRuntimeOnly.extendsFrom runtimeDownloadOnly } @@ -53,12 +68,13 @@ dependencies { runtimeDownloadApi(libs.commons.io) // Caffeine - runtimeDownloadApi(libs.caffeine) { - exclude group: 'com.google.errorprone', module: 'error_prone_annotations' - } + runtimeDownloadApi(libs.caffeine) // DynamicProxy - runtimeDownloadApi(libs.dynamicproxy) + runtimeDownloadApi(libs.dynamicproxy) { + // Not needed at runtime + exclude module: 'javaparser-symbol-solver-core' + } // Jackson (transitive in :api) compileOnlyApi(libs.jackson.databind) @@ -79,15 +95,18 @@ dependencies { runtimeDownloadApi(libs.enhancedlegacytext) // Database - hikari(libs.hikaricp) - h2Driver(libs.h2) - mysqlDriver(libs.mysql) - mariadbDriver(libs.mariadb) + hikariOnly(libs.hikaricp) { + // Already provided + exclude group: 'org.slf4j' + } + h2DriverOnly(libs.h2) + mysqlDriverOnly(libs.mysql) + mariadbDriverOnly(libs.mariadb) // MinecraftAuthentication library - mcAuthLib(libs.minecraftauth.lib) { + mcAuthLibOnly(libs.minecraftauth.lib) { + // JUnit is a testing library exclude group: 'junit', module: 'junit' - exclude group: 'org.jetbrains', module: 'annotations' } // Brigadier diff --git a/settings.gradle b/settings.gradle index 1b51f8c9..c776dff8 100644 --- a/settings.gradle +++ b/settings.gradle @@ -57,10 +57,9 @@ dependencyResolutionManagement { // JDA library('jda', 'net.dv8tion', 'JDA').version('5.0.0-beta.10.webhooks_2') - library('okhttp', 'com.squareup.okhttp3', 'okhttp').version { - prefer '3.14.9' - reject '[4,)' // Kotlin - } + + // OkHTTP + library('okhttp', 'com.squareup.okhttp3', 'okhttp').version('4.11.0') // Apache commons library('commons-lang', 'org.apache.commons', 'commons-lang3').version('3.12.0')