Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shade GSON to avoid problems with outdated settings dependencies such as old versions of the foojay plugin #22

Merged
merged 4 commits into from
Jun 15, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 33 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -58,15 +59,31 @@ 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.
Technici4n marked this conversation as resolved.
Show resolved Hide resolved
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()

Expand All @@ -90,6 +107,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)
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Loading