Skip to content

Commit 14c71de

Browse files
committed
Fat testmod jar
1 parent b95bf11 commit 14c71de

File tree

2 files changed

+66
-14
lines changed

2 files changed

+66
-14
lines changed

build.gradle

Lines changed: 46 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ plugins {
1010
id "eclipse"
1111
id "idea"
1212
id "maven-publish"
13-
id "fabric-loom" version "0.6.local" apply false
13+
id "fabric-loom" version "0.7.local" apply false
1414
id "org.cadixdev.licenser" version "0.5.0"
1515
id "org.ajoberstar.grgit" version "4.1.0"
1616
id "com.matthewprenger.cursegradle" version "1.4.0"
@@ -33,6 +33,7 @@ logger.lifecycle("Building Fabric: " + version)
3333

3434
import org.apache.commons.codec.digest.DigestUtils
3535
import net.fabricmc.loom.task.RemapJarTask
36+
import net.fabricmc.loom.task.RemapSourcesJarTask
3637

3738
def getSubprojectVersion(project, version) {
3839
if (grgit == null) {
@@ -150,13 +151,33 @@ allprojects {
150151
}
151152

152153
jar {
153-
archiveClassifier.set "dev"
154+
archiveClassifier = "dev"
154155
}
155156

157+
task testmodJar(type: Jar) {
158+
from sourceSets.testmod.output
159+
archiveClassifier = "testmod-dev"
160+
}
161+
162+
task remapTestmodJar(type: RemapJarTask, dependsOn: testmodJar) {
163+
input= testmodJar.getArchiveFile()
164+
archiveClassifier = "testmod"
165+
classpath sourceSets.testmod.compileClasspath
166+
addNestedDependencies = false
167+
}
168+
169+
task testmodSourceJar(type: Jar, dependsOn: classes) {
170+
classifier = 'testmodSources'
171+
from sourceSets.testmod.allSource
172+
}
173+
174+
// Gets setup fully in loom
175+
task remapTestmodSourcesJar(type: RemapSourcesJarTask)
176+
156177
afterEvaluate {
157178
remapJar {
158179
input = file("${project.buildDir}/libs/$archivesBaseName-${archiveVersion.get()}-dev.jar")
159-
archiveFileName.set "${archivesBaseName}-${archiveVersion.get()}.jar"
180+
archiveFileName = "${archivesBaseName}-${archiveVersion.get()}.jar"
160181
}
161182

162183
artifacts {
@@ -175,6 +196,17 @@ allprojects {
175196
header rootProject.file("HEADER")
176197
include "**/*.java"
177198
}
199+
200+
// Setup batched remap for testmod jars. Not really a supported api in loom so copy this at your own risk.
201+
net.fabricmc.loom.configuration.RemapConfiguration.setupRemap(
202+
project,
203+
"testmodJar",
204+
"testmodSourceJar",
205+
"remapTestmodJar",
206+
"remapTestmodSourcesJar",
207+
"remapAllTestmodJars",
208+
"remapAllTestmodSources"
209+
)
178210
}
179211

180212
task sourcesJar(type: Jar, dependsOn: classes) {
@@ -281,27 +313,27 @@ subprojects {
281313

282314
javadoc.enabled = false
283315

284-
task testmodJar(type: Jar) {
285-
from sourceSets.testmod.output
286-
archiveClassifier.set "testmod-dev"
287-
}
288-
289-
task remapTestmodJar(type: RemapJarTask, dependsOn: testmodJar) {
290-
input.set testmodJar.getArchiveFile()
291-
archiveClassifier.set "testmod"
292-
classpath sourceSets.testmod.compileClasspath
293-
addNestedDependencies = false
316+
if (file("src/testmod").exists()) {
317+
afterEvaluate {
318+
project.rootProject.remapTestmodJar {
319+
include remapTestmodJar.archivePath
320+
}
321+
}
294322
}
295323
}
296324

297325
task remapMavenJar(type: RemapJarTask, dependsOn: jar) {
298326
afterEvaluate {
299327
input = file("${project.buildDir}/libs/${archivesBaseName}-${archiveVersion.get()}-dev.jar")
300-
archiveFileName.set "${archivesBaseName}-${archiveVersion.get()}-maven.jar"
328+
archiveFileName = "${archivesBaseName}-${archiveVersion.get()}-maven.jar"
301329
addNestedDependencies = false
302330
}
303331
}
304332

333+
remapTestmodJar {
334+
addDefaultNestedDependencies = false
335+
}
336+
305337
publishing {
306338
publications {
307339
mavenJava(MavenPublication) {

src/testmod/resources/fabric.mod.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"schemaVersion": 1,
3+
"id": "fabric-testmod",
4+
"name": "Fabric API Testmod",
5+
"version": "${version}",
6+
"environment": "*",
7+
"license": "Apache-2.0",
8+
"contact": {
9+
"homepage": "https://fabricmc.net",
10+
"irc": "irc://irc.esper.net:6667/fabric",
11+
"issues": "https://github.com/FabricMC/fabric/issues",
12+
"sources": "https://github.com/FabricMC/fabric"
13+
},
14+
"authors": [
15+
"FabricMC"
16+
],
17+
"depends": {
18+
"fabric": "${version}"
19+
}
20+
}

0 commit comments

Comments
 (0)