-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.gradle
182 lines (160 loc) · 5.74 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
buildscript {
repositories {
gradlePluginPortal()
mavenCentral()
}
dependencies {
classpath("net.kyori:blossom:1.3.0")
classpath("org.ow2.asm:asm:9.2")
}
}
apply plugin: "java"
apply plugin: "net.kyori.blossom"
apply plugin: "signing"
sourceCompatibility = 1.8
targetCompatibility = 1.8
group = "io.github.lxgaming"
archivesBaseName = "_MixinBootstrap"
version = "1.1.1"
blossom {
replaceToken("@version@", version)
}
configurations {
compileJar {
implementation.extendsFrom(compileJar)
}
// build.finalizedBy("signJar")
}
repositories {
mavenCentral()
maven {
name = "minecraftforge"
url = "https://maven.minecraftforge.net/"
}
maven {
name = "spongepowered"
url = "https://repo.spongepowered.org/repository/maven-public/"
}
}
dependencies {
compileOnly("com.google.code.findbugs:jsr305:3.0.2")
compileOnly("cpw.mods:modlauncher:5.1.2")
implementation("io.github.lxgaming:classloaderutils:1.0.0")
compileOnly("net.sf.jopt-simple:jopt-simple:5.0.4")
compileOnly("org.apache.logging.log4j:log4j-api:2.17.0")
compileJar("org.ow2.asm:asm-analysis:6.2") {
transitive = false
}
compileJar("org.ow2.asm:asm-util:6.2") {
transitive = false
}
implementation("org.spongepowered:mixin:0.8.5") {
transitive = false
}
}
jar {
dependsOn("patchMixinModule")
duplicatesStrategy = DuplicatesStrategy.INCLUDE
manifest {
attributes(
"Automatic-Module-Name": "mixinbootstrap",
"TweakClass": "org.spongepowered.asm.launch.MixinTweaker",
"TweakOrder": 0
)
}
from ((configurations.runtimeClasspath - configurations.compileJar).findAll({
it.isDirectory() || it.name.endsWith(".jar")
}).collect({
it.isDirectory() ? it : zipTree(it)
})) {
exclude("META-INF/services/cpw.mods.modlauncher.*")
exclude("META-INF/services/org.spongepowered.asm.service.*")
exclude("META-INF/*.RSA")
exclude("META-INF/*.SF")
exclude("module-info.class")
}
into ("META-INF/libraries") {
from (configurations.compileJar.findAll({
it.name.endsWith(".jar")
}).collect({
it
}))
}
}
java {
disableAutoTargetJvm()
}
processResources {
from("LICENSE")
rename("LICENSE", "LICENSE-MixinBootstrap")
}
task signJar {
doFirst {
if (!project.hasProperty("signing.keyStorePath") || !project.hasProperty("signing.secretKeyRingFile")) {
project.logger.warn("========== [WARNING] ==========")
project.logger.warn("")
project.logger.warn(" This build is not signed! ")
project.logger.warn("")
project.logger.warn("========== [WARNING] ==========")
throw new StopExecutionException()
}
}
doLast {
configurations.archives.allArtifacts.files.each {
ant.signjar(
jar: it,
alias: project.property("signing.alias"),
storepass: project.property("signing.keyStorePassword"),
keystore: project.property("signing.keyStorePath"),
keypass: project.property("signing.keyStorePassword"),
preservelastmodified: project.property("signing.preserveLastModified"),
tsaurl: project.property("signing.timestampAuthority"),
digestalg: project.property("signing.digestAlgorithm")
)
project.logger.lifecycle("JAR Signed: ${it.name}")
signing.sign(it)
project.logger.lifecycle("PGP Signed: ${it.name}")
}
}
}
import java.util.zip.ZipFile
import org.objectweb.asm.ClassReader
import org.objectweb.asm.ClassVisitor
import org.objectweb.asm.ClassWriter
import org.objectweb.asm.ModuleVisitor
import org.objectweb.asm.Opcodes
task patchMixinModule {
doLast {
configurations.compileClasspath.asFileTree.filter({
it.name.startsWith("mixin-")
}).forEach({ file ->
sourceSets.main.java.classesDirectory.get().file("module-info.class").asFile.withOutputStream { outputStream ->
ZipFile zipFile = new ZipFile(file)
ClassReader classReader = new ClassReader(zipFile.getInputStream(zipFile.getEntry("module-info.class")))
ClassWriter classWriter = new ClassWriter(0)
classReader.accept(new ClassVisitor(Opcodes.ASM9, classWriter) {
@Override
ModuleVisitor visitModule(String name, int access, String version) {
return new ModuleVisitor(Opcodes.ASM9, super.visitModule("io.github.lxgaming.mixin.launch", access, version)) {
@Override
void visitExport(String exportPackage, int exportAccess, String... modules) {
}
@Override
void visitProvide(String service, String... providers) {
// clean all mixin services
if (service == "cpw/mods/modlauncher/api/ITransformationService") {
providers = ["io/github/lxgaming/mixin/launch/MixinTransformationService"]
}
super.visitProvide(service, providers)
}
}.with { moduleVisitor ->
moduleVisitor.visitRequire("jdk.unsupported", 0, null)
moduleVisitor
}
}
}, 0)
outputStream.write(classWriter.toByteArray())
}
})
}
}