Repository navigation
Expand file tree
/
Copy pathbuild.gradle
More file actions
83 lines (68 loc) · 2.85 KB
/
Copy pathbuild.gradle
File metadata and controls
83 lines (68 loc) · 2.85 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
plugins {
id 'com.gtnewhorizons.gtnhgradle' version '2.0.31'
}
def dhBuild = gradle.includedBuild('dh')
// mod_version comes from the git tag, see dh/version.gradle
group = modGroup
version = gradle.ext.mod_version
ext.modVersion = version
def sourceName = "${modName}-${dhLoader}-${version}-${minecraftVersion}"
// The publishers want TaskProvider<Jar>, but the jars are DH's -- clear Jar's own
// packaging action and copy them byte-for-byte instead.
def registerJarCopy = { String taskName, FileCollection source, String classifier ->
tasks.register(taskName, Jar) {
archiveFileName.set("${modName}-${version}${classifier}.jar")
inputs.files(source)
actions.clear()
doLast {
copy {
from source.singleFile
into destinationDirectory
rename { archiveFileName.get() }
}
}
}
}
def dhReleaseJar = files("dh/${dhLoader}/build/libs/${sourceName}.jar")
.builtBy(dhBuild.task(":${dhLoader}:assemble"))
def collectJars = registerJarCopy('collectJars', dhReleaseJar, '')
def releaseJar = collectJars.flatMap { it.archiveFile }
// Deobfuscate DH's release jar for use as the published compile-time dev jar.
def deobfJar = configurations.detachedConfiguration(dependencies.create(modUtils.deobfuscate(files(releaseJar))))
configurations.runtimeClasspath.attributes.keySet().each { attribute ->
deobfJar.attributes.attribute(attribute, configurations.runtimeClasspath.attributes.getAttribute(attribute))
}
def collectDevJars = registerJarCopy('collectDevJars', deobfJar, '-dev')
def devJar = collectDevJars.flatMap { it.archiveFile }
tasks.named('jar') { enabled = false }
['apiElements', 'runtimeElements'].each { name ->
configurations.named(name) {
outgoing.artifacts.clear()
outgoing.artifact(releaseJar) { builtBy collectJars }
}
}
// Modrinth and CurseForge upload these. ToolchainModule normally sets them, but it isn't applied here.
ext.publishableObfJar = collectJars
ext.publishableDevJar = collectDevJars
gtnhGradle.applyModuleByName(project, 'PublishingModule')
publishing.publications.named('maven') {
artifactId = System.getenv('ARTIFACT_ID') ?: modName
artifact(devJar) {
classifier = 'dev'
builtBy collectDevJars
}
}
afterEvaluate {
publishing.publications.named('maven') { version = project.version }
}
tasks.named('assemble') {
setDependsOn([])
dependsOn collectJars, collectDevJars
}
tasks.named('check') { dependsOn dhBuild.task(":${dhLoader}:check") }
tasks.named('clean') { dependsOn dhBuild.task(':clean') }
// Keep RFG from preparing Minecraft for this source-less wrapper project.
['compileClasspath', 'testCompileClasspath', 'runtimeClasspath', 'testRuntimeClasspath'].each { name ->
configurations.named(name) { setExtendsFrom([]) }
}
tasks.named('setupCIWorkspace') { setDependsOn([]) }