Skip to content

Commit

Permalink
Merge pull request #43 from GTNewHorizons/fix-shaded-dependencies
Browse files Browse the repository at this point in the history
Updated build script to switch shadowed dependencies to shaded depend…
  • Loading branch information
Dream-Master authored Dec 21, 2021
2 parents eb86eba + d0961fd commit 42d390b
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 30 deletions.
82 changes: 54 additions & 28 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//version: 29197fa3cf1ea6ef5c07884a613171d01c026d1d
//version: 8fa7883b6196c1765266f4e6ddf3118d5043aafb
/*
DO NOT CHANGE THIS FILE!
Expand Down Expand Up @@ -195,7 +195,9 @@ if(file("addon.gradle").exists()) {
apply from: 'repositories.gradle'

configurations {
implementation.extendsFrom(shadowImplementation)
implementation.extendsFrom(shadowImplementation) // TODO: remove after all uses are refactored
implementation.extendsFrom(shadowCompile)
implementation.extendsFrom(shadeCompile)
}

repositories {
Expand Down Expand Up @@ -261,16 +263,28 @@ task relocateShadowJar(type: ConfigureShadowRelocation) {
}

shadowJar {
project.configurations.shadeCompile.each { dep ->
from(project.zipTree(dep)) {
exclude 'META-INF', 'META-INF/**'
}
}

manifest {
attributes(getManifestAttributes())
}

minimize() // This will only allow shading for actually used classes
configurations = [project.configurations.shadowImplementation]
configurations = [project.configurations.shadowImplementation, project.configurations.shadowCompile]
dependsOn(relocateShadowJar)
}

jar {
project.configurations.shadeCompile.each { dep ->
from(project.zipTree(dep)) {
exclude 'META-INF', 'META-INF/**'
}
}

manifest {
attributes(getManifestAttributes())
}
Expand Down Expand Up @@ -344,31 +358,31 @@ tasks.withType(JavaExec).configureEach {
}

processResources
{
// this will ensure that this task is redone when the versions change.
inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version

// replace stuff in mcmod.info, nothing else
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'

// replace version and mcversion
expand "minecraftVersion": project.minecraft.version,
"modVersion": versionDetails().lastTag,
"modId": modId,
"modName": modName
}
{
// this will ensure that this task is redone when the versions change.
inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version

if(usesMixins.toBoolean()) {
from refMap
}
// replace stuff in mcmod.info, nothing else
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'

// copy everything else, thats not the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}
}
// replace version and mcversion
expand "minecraftVersion": project.minecraft.version,
"modVersion": versionDetails().lastTag,
"modId": modId,
"modName": modName
}

if(usesMixins.toBoolean()) {
from refMap
}

// copy everything else, thats not the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}
}

def getManifestAttributes() {
def manifestAttributes = [:]
Expand Down Expand Up @@ -401,6 +415,12 @@ task sourcesJar(type: Jar) {
}

task shadowDevJar(type: ShadowJar) {
project.configurations.shadeCompile.each { dep ->
from(project.zipTree(dep)) {
exclude 'META-INF', 'META-INF/**'
}
}

from sourceSets.main.output
getArchiveClassifier().set("dev")

Expand All @@ -409,7 +429,7 @@ task shadowDevJar(type: ShadowJar) {
}

minimize() // This will only allow shading for actually used classes
configurations = [project.configurations.shadowImplementation]
configurations = [project.configurations.shadowImplementation, project.configurations.shadowCompile]
}

task relocateShadowDevJar(type: ConfigureShadowRelocation) {
Expand All @@ -424,6 +444,12 @@ task circularResolverJar(type: Jar) {
}

task devJar(type: Jar) {
project.configurations.shadeCompile.each { dep ->
from(project.zipTree(dep)) {
exclude 'META-INF', 'META-INF/**'
}
}

from sourceSets.main.output
getArchiveClassifier().set("dev")

Expand Down Expand Up @@ -477,7 +503,7 @@ publishing {
version = System.getenv("ARTIFACT_VERSION") ?: project.version
}
}

repositories {
maven {
String owner = System.getenv("REPOSITORY_OWNER") ?: "Unknown"
Expand Down
4 changes: 2 additions & 2 deletions dependencies.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Add your dependencies here

dependencies {
shadowImplementation files("dependencies/OpenComputers-JNLua.jar")
shadowImplementation files("dependencies/OpenComputers-LuaJ.jar")
shadeCompile files("dependencies/OpenComputers-JNLua.jar")
shadeCompile files("dependencies/OpenComputers-LuaJ.jar")

compile("com.google.code.findbugs:jsr305:3.0.2")

Expand Down

0 comments on commit 42d390b

Please sign in to comment.