-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathbuild.gradle
More file actions
178 lines (144 loc) · 6.02 KB
/
build.gradle
File metadata and controls
178 lines (144 loc) · 6.02 KB
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
plugins {
id 'java'
id 'java-gradle-plugin'
id 'maven-publish'
id 'com.gradle.plugin-publish' version '0.21.0'
id 'com.gradleup.shadow' version '9.0.0-beta12'
id 'xyz.wagyourtail.jvmdowngrader' version "1.3.3"
}
group = 'io.github.pacifistmc.forgix'
// Make sure to change the version number in io.github.pacifistmc.forgix.Forgix
def constantsSource = rootProject.file("src/main/java/io/github/pacifistmc/forgix/Forgix.java").text
version = (constantsSource =~ /\s+VERSION\s*=\s*"(.*)";/)[0][1]
configurations {
shade.extendsFrom downgradeShade
compileOnly.extendsFrom shade
testImplementation.extendsFrom compileOnly
testAnnotationProcessor.extendsFrom annotationProcessor
}
repositories {
mavenCentral()
maven {
name = 'FirstDarkDev'
url = 'https://maven.firstdarkdev.xyz/releases/'
}
maven {
name = 'FabricMC'
url = 'https://maven.fabricmc.net/'
}
}
String manifoldVersion = '2025.1.22'
dependencies {
implementation gradleApi()
shade "systems.manifold:manifold-rt:${manifoldVersion}"
shade "systems.manifold:manifold-props-rt:${manifoldVersion}"
shade "systems.manifold:manifold-params-rt:${manifoldVersion}"
shade "systems.manifold:manifold-ext-rt:${manifoldVersion}"
shade "systems.manifold:manifold-tuple-rt:${manifoldVersion}"
annotationProcessor "systems.manifold:manifold-exceptions:${manifoldVersion}"
annotationProcessor "systems.manifold:manifold-props:${manifoldVersion}"
annotationProcessor "systems.manifold:manifold-params:${manifoldVersion}"
annotationProcessor "systems.manifold:manifold-tuple:${manifoldVersion}"
annotationProcessor "systems.manifold:manifold-strings:${manifoldVersion}"
downgradeShade 'net.lingala.zip4j:zip4j:2.11.5'
downgradeShade 'commons-io:commons-io:2.19.0'
downgradeShade 'com.google.code.gson:gson:2.13.1'
downgradeShade('net.fabricmc:tiny-remapper:0.11.1') {
exclude group: 'org.ow2.asm'
}
downgradeShade 'org.ow2.asm:asm:9.8'
downgradeShade 'org.ow2.asm:asm-commons:9.8'
downgradeShade 'org.ow2.asm:asm-tree:9.8'
downgradeShade 'org.ow2.asm:asm-util:9.8'
shade fileTree(dir: 'src/main/resources/multiversion', include: '*.jar').filter { file ->
!file.name.contains('-javadoc') && !file.name.contains('-sources')
}
testImplementation platform('org.junit:junit-bom:5.10.0')
testImplementation 'org.junit.jupiter:junit-jupiter'
}
downgradeJar.inputFile = tasks.jar.archiveFile
jvmdg.dg(configurations.downgradeShade)
shadowJar {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
configurations = [project.configurations.shade]
relocate "net.fabricmc", "pacifistmc.libraries.net.fabricmc"
relocate "org.objectweb.asm", "pacifistmc.libraries.org.objectweb.asm"
relocate "org.apache.commons.io", "pacifistmc.libraries.org.apache.commons.io"
relocate "net.lingala.zip4j", "pacifistmc.libraries.net.lingala.zip4j"
relocate "com.google", "pacifistmc.libraries.com.google"
exclude 'META-INF/services/**'
// Make shadowJar use shadeDowngradedApi
dependsOn tasks.shadeDowngradedApi
from(zipTree(tasks.named('shadeDowngradedApi').flatMap { it.archiveFile }))
archiveClassifier.set(null)
}
gradlePlugin {
plugins {
Forgix {
id = "io.github.pacifistmc.forgix"
displayName = 'Forgix'
description = 'This plugin merges all your modloader & plugin jars into a single jar.'
implementationClass = "io.github.pacifistmc.forgix.plugin.ForgixGradlePlugin"
}
}
}
pluginBundle {
website = 'https://github.com/PacifistMC'
vcsUrl = 'https://github.com/PacifistMC/Forgix'
tags = ['forge', 'minecraftforge', 'merge', 'jars', 'fabric', 'fabricmc', 'quilt', 'quiltmc', 'neoforge', 'neoforged', 'minecraft', 'architectury', 'forgix', 'pacifistmc']
}
publishing {
repositories {
maven {
name = 'localPluginRepository'
url = '../local-plugin-repository'
}
}
}
tasks.withType(GenerateModuleMetadata).configureEach {
enabled = false
}
tasks.withType(Sign).configureEach {
enabled = false
}
tasks.withType(JavaCompile).configureEach {
options.compilerArgs += ['-Xplugin:Manifold', '--add-exports=java.base/jdk.internal.access=ALL-UNNAMED']
}
test.useJUnitPlatform()
jar.finalizedBy(shadowJar)
javadoc.enabled(false) // Doesn't work well with Manifold
// This task builds the multiversion mod and copies it to resources
tasks.register('buildMultiversionMod', Exec) {
description = 'Builds the Forgix-Multiversion-Mod and copies the merged jar to resources'
group = 'forgix'
// Check if the multiversion jar already exists
def resourcesDir = file('src/main/resources/multiversion')
def multiversionJar = new File(resourcesDir, 'forgix-multiversion.jar')
// Skip the task if the jar already exists
onlyIf {
!multiversionJar.exists()
}
workingDir = file('./Forgix-Multiversion-Mod')
// Run assemble and then mergeJars tasks in the multiversion mod project
def isWindows = System.getProperty('os.name').toLowerCase().contains('windows')
commandLine isWindows ? 'gradlew.bat' : './gradlew', 'assemble'
commandLine isWindows ? 'gradlew.bat' : './gradlew', 'mergeJars'
doLast {
// Create the resources directory if it doesn't exist
resourcesDir.mkdirs()
// Find the merged jar in the multiversion mod's build directory
def mergedJarDir = file('./Forgix-Multiversion-Mod/build/merged')
def mergedJar = mergedJarDir.listFiles().find { it.name.endsWith('.jar') }
if (!mergedJar) {
throw new GradleException("No merged jar found in ${mergedJarDir}")
}
// Copy the merged jar to the resources directory
copy {
from mergedJar
into resourcesDir
rename { 'forgix-multiversion.jar' }
}
}
}
// Run the buildMultiversionMod task before compiling Java sources so that the merged jar is available in resources
compileJava.dependsOn buildMultiversionMod