From 75b9f3edaa82ef841de9377e4eeca85c43b12e02 Mon Sep 17 00:00:00 2001 From: wizjany Date: Thu, 15 May 2014 14:41:26 -0400 Subject: [PATCH] [Forge] Add dependency shading via the gradle shadow plugin. --- build.gradle | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index cb0a83187..ea1ad00fa 100644 --- a/build.gradle +++ b/build.gradle @@ -7,16 +7,19 @@ buildscript { repositories { mavenCentral() maven { url = "http://files.minecraftforge.net/maven" } + jcenter() } dependencies { classpath 'net.minecraftforge.gradle:ForgeGradle:1.0-SNAPSHOT' + classpath 'com.github.jengelman.gradle.plugins:shadow:0.8' } } apply plugin: 'java' apply plugin: 'maven' apply plugin: 'forge' +apply plugin: 'shadow' group = 'com.sk89q' version = '6.0.0-SNAPSHOT' @@ -76,4 +79,35 @@ processResources { from (sourceSets.main.resources.srcDirs) { exclude 'mcmod.info' } -} \ No newline at end of file +} + +// shade needed runtime dependencies +shadow { + //artifactAttached false + destinationDir "${buildDir}/libs/" + artifactSet { + include '*:jchronic:jar:' + } +} + +task deleteOrig(type: Delete) { + delete "${project.tasks.jar.getArchivePath().getPath()}" +} + +task renameShaded(type: Copy) { + from file("${buildDir}/libs") + into file("${buildDir}/libs") + rename { String fileName -> + fileName.replace('-shadow', '') + } +} + +task deleteShaded(type: Delete) { + delete "${project.tasks.jar.getArchivePath().getPath().replace('.jar', '-shadow.jar')}" +} + +// follow all the steps +build.dependsOn(deleteShaded) +deleteShaded.dependsOn(renameShaded) +renameShaded.dependsOn(deleteOrig) +deleteOrig.dependsOn(shadowJar)