diff --git a/build.gradle b/build.gradle index 77ee29fc..240d5982 100644 --- a/build.gradle +++ b/build.gradle @@ -3,6 +3,7 @@ plugins { id 'maven-publish' id "net.neoforged.gradleutils" version "3.0.0-alpha.13" id 'com.gradle.plugin-publish' version '1.1.0' + id 'io.github.goooler.shadow' version '8.1.7' } group = 'net.neoforged' @@ -58,15 +59,32 @@ sourceSets { } } +configurations { + // Configuration for all dependencies that we want shaded. + shaded + // Place shaded dependencies into `compileOnly` so that they do not leak into our publications' dependencies. + compileOnly.extendsFrom shaded + shadowRuntimeElements { + // `shadowRuntimeElements` is what gets published. + // We want it to contain the non-shaded runtime dependencies. + it.extendsFrom implementation, runtimeOnly + } + // Change the Category attribute so that includeBuilds don't select the default `runtimeElements` configuration. + // The Plugin Publish plugin already disables Maven publication of this configuration automatically. + runtimeElements { + attributes { + attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category, "not-wanted-publication")) + } + } +} + dependencies { compileOnly gradleApi() compileOnly "com.intellij:annotations:9.0.4" - implementation "com.google.code.gson:gson:2.10.1" + shaded "com.google.code.gson:gson:2.10.1" implementation "gradle.plugin.org.jetbrains.gradle.plugin.idea-ext:gradle-idea-ext:1.1.8" - implementation "net.neoforged:JarJarMetadata:0.4.1" implementation "net.neoforged:EclipseLaunchConfigs:0.1.11" - api "gradle.plugin.org.jetbrains.gradle.plugin.idea-ext:gradle-idea-ext:1.1.8" - api "net.neoforged:JarJarMetadata:0.4.1" + implementation "net.neoforged:JarJarMetadata:0.4.1" java8CompileOnly gradleApi() @@ -90,6 +108,18 @@ jar { from sourceSets.java8.output } +shadowJar { + archiveClassifier = "" // Required for the Plugin Publish Plugin to publish this jar + + from sourceSets.java8.output + + configurations = [project.configurations.shaded] + enableRelocation true + relocationPrefix = "net.neoforged.moddev.shadow" +} + +assemble.dependsOn shadowJar + tasks.named("compileJava8Java").configure { javaCompiler = javaToolchains.compilerFor { languageVersion = JavaLanguageVersion.of(8) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a4413138..6f7a6eb3 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-all.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME