Skip to content

Commit

Permalink
Add task to build .jar with bundled mixin library
Browse files Browse the repository at this point in the history
  • Loading branch information
NeRdTheNed committed Jun 6, 2023
1 parent 64d5a0c commit f437be6
Showing 1 changed file with 32 additions and 3 deletions.
35 changes: 32 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ buildscript {
plugins {
id 'java-library'
id 'maven-publish'
id 'com.github.johnrengelman.shadow' version '7.1.2'
}

apply plugin: 'java'
Expand Down Expand Up @@ -81,15 +82,18 @@ configurations {
// Another list of dependencies to use with ProGaurd, as ForgeGradle isn't happy about resolving it the normal way.
// I'm not happy about it either.
proguardHack

shadowConfHack
}

dependencies {
minecraft "net.minecraftforge:forge:${project.forge_version}"

// Mixins
annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'
compileOnly 'org.spongepowered:mixin:0.8.5'
proguardHack 'org.spongepowered:mixin:0.8.5'
annotationProcessor 'org.spongepowered:mixin:0.8.3:processor'
compileOnly 'org.spongepowered:mixin:0.8.3'
proguardHack 'org.spongepowered:mixin:0.8.3'
shadowConfHack 'org.spongepowered:mixin:0.8.3'
}

mixin {
Expand Down Expand Up @@ -218,10 +222,35 @@ jar {
}
}

// Create jar with bundled mixin library
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar

task optimisedShadowJar(type: ShadowJar) {
dependsOn(reobfOptimisedJar)

archiveClassifier.set("with-mixins")
from zipTree(optimisedJar.outputs.files.singleFile)
configurations = [project.configurations.shadowConfHack]

exclude 'META-INF/*.SF'
exclude 'META-INF/*.RSA'
exclude 'META-INF/*.MF'

manifest {
attributes([
"MixinConfigs": "punch2prime.mixins.json",
"MixinConnector": "com.github.NeRdTheNed.Punch2Prime.Connector",
"TweakClass": "org.spongepowered.asm.launch.MixinTweaker",
'ForceLoadAsMod': 'true'
])
}
}

// Creates the listed artifacts on building the mod.
artifacts {
archives sourcesJar
archives optimisedJar
archives optimisedShadowJar
}

// TODO this is a bit dumb
Expand Down

0 comments on commit f437be6

Please sign in to comment.