Skip to content

Commit

Permalink
Shade GSON to avoid problems with outdated settings dependencies such…
Browse files Browse the repository at this point in the history
… as old versions of the foojay plugin (#22)

Closes #21.
  • Loading branch information
Technici4n authored Jun 15, 2024
1 parent d480632 commit 469dc9c
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 5 deletions.
38 changes: 34 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,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()

Expand All @@ -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)
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

0 comments on commit 469dc9c

Please sign in to comment.