Skip to content

Commit

Permalink
Merge pull request OrnitheMC#143 from zeichenreihe/simplify-gradle-bu…
Browse files Browse the repository at this point in the history
…ildscript

Simplify the gradle buildscript
  • Loading branch information
SpaceWalkerRS authored Nov 3, 2023
2 parents c5f8ad2 + ee51869 commit a2a202d
Show file tree
Hide file tree
Showing 3 changed files with 188 additions and 17 deletions.
27 changes: 10 additions & 17 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -522,14 +522,14 @@ task downloadMcJars(dependsOn: downloadVersionDetails) {
}
}

task downloadCalamus(dependsOn: downloadMcJars, type: Download) {
task downloadCalamus(type: Download) {
group = buildMappingGroup
def url = "https://github.com/OrnitheMC/calamus/raw/main/mappings/${version_id}.tiny"
src UrlEscapers.urlFragmentEscaper().escape(url)
dest calamusV1File
}

task downloadCalamusV2(dependsOn: downloadMcJars, type: Download) {
task downloadCalamusV2(type: Download) {
group = buildMappingGroup
def url = "https://maven.ornithemc.net/releases/net/ornithemc/calamus-${namespace}/${version_id}/calamus-${namespace}-${version_id}-v2.jar"
src UrlEscapers.urlFragmentEscaper().escape(url)
Expand Down Expand Up @@ -849,38 +849,31 @@ task feather(dependsOn: [nestJar, separateMappings]) {
}
}

task separateMappingsForBuild(type: WithV2FileOutput) {
task separateMappingsForBuild(type: FileOutput) {
inputs.dir mappingsDir

v1Output = new File(tempDir, "separated-mappings.tiny")
v2Output = new File(tempDir, "separated-mappings-v2.tiny")

output = new File(tempDir, "separated-mappings-v2.tiny")
outputs.file(output)
outputs.upToDateWhen { false }

doLast {
VersionGraph graph = VersionGraph.of(Format.TINY_V2, mappingsDir.toPath())
Mappings mappings = MappingUtils.separateMappings(graph, version_id);

mappings.setValidator(REMOVE_DUMMY)
Format.TINY_V2.writeMappings(v2Output.toPath(), mappings)

new ConvertMappingsCommand().run(
"tinyv2",
v2Output.getAbsolutePath(),
"tiny:${namespace}:named",
v1Output.getAbsolutePath())
Format.TINY_V2.writeMappings(output.toPath(), mappings)
}
}

task checkMappings(dependsOn: [mapCalamusJar, separateMappingsForBuild]) {
group = buildMappingGroup
inputs.file separateMappingsForBuild.v2Output
inputs.file separateMappingsForBuild.output
doLast {
logger.lifecycle(":checking mappings")

String[] args = [
mainJar.getAbsolutePath(),
separateMappingsForBuild.v2Output.getAbsolutePath()
separateMappingsForBuild.output.getAbsolutePath()
]

try {
Expand All @@ -893,7 +886,7 @@ task checkMappings(dependsOn: [mapCalamusJar, separateMappingsForBuild]) {

task buildFeatherTiny(dependsOn: [mapCalamusJar, separateMappingsForBuild], type: WithV2FileOutput) {
group = buildMappingGroup
inputs.file separateMappingsForBuild.v2Output
inputs.file separateMappingsForBuild.output
if (!libs.exists()) {
libs.mkdirs()
}
Expand All @@ -909,7 +902,7 @@ task buildFeatherTiny(dependsOn: [mapCalamusJar, separateMappingsForBuild], type
new MapSpecializedMethodsCommand().run(
calamusJar.getAbsolutePath(),
"tinyv2",
separateMappingsForBuild.v2Output.getAbsolutePath(),
separateMappingsForBuild.output.getAbsolutePath(),
"tinyv2:${namespace}:named",
v2Output.getAbsolutePath()
)
Expand Down
178 changes: 178 additions & 0 deletions tasks.dot
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
// color = pink:
// Any task you would "invoke" from externally
//
// color = lightblue:
// Any task that is used internally
//
// shape = rect:
// Any "download" task
//
// subgraph {}
// Any task for some given topic

digraph G {
node [style=filled];
color = blue;

// COMMENT OUT

insertMappings[color = pink];
patchNests -> insertMappings;

propagateMappingsDown[color = pink];
patchNests -> propagateMappingsDown;

propagateMappingsUp[color = pink];
patchNests -> propagateMappingsUp;

propagateMappings[color = pink];
patchNests -> propagateMappings;

feather[color = pink];
nestJar, separateMappings -> feather;

importMappingsOfficial[color = pink];
invertCalamus -> importMappingsOfficial;

patchCalamus[color = pink];
mergeJars, downloadCalamus -> patchCalamus;

exportMappingsOfficial[color = pink];
downloadCalamus -> exportMappingsOfficial;

decompileCFR[color = pink];
mapNamedJar -> decompileCFR;

decompileQuiltFlower[color = pink];
mapNamedJar -> decompileQuiltFlower;

decompileProcyon[color = pink];
mapNamedJar -> decompileProcyon;

nestJar[color = pink];
mapCalamusJar -> nestJar;
patchNests -> nestJar;

downloadNests[color = lightblue, shape = rect];

patchNests[color = lightblue];
downloadNests, downloadCalamus -> patchNests;

separateMappings[color = lightblue];
patchNests -> separateMappings;

checkMappings[color = lightblue];
mapCalamusJar, separateMappingsForBuild -> checkMappings;

buildTinyWithEnum[color = lightblue];
mergeTiny -> buildTinyWithEnum;

subgraph cluster_decompile {
label = "decompile";
color = blue;

decompileProcyon, decompileCFR, decompileQuiltFlower;
}

subgraph cluster_operations {
color = blue;

propagateMappings, propagateMappingsUp, propagateMappingsDown,
insertMappings, feather, nestJar, importMappingsOfficial,
exportMappingsOfficial, patchCalamus;
}
//*/

insertAutoGeneratedEnumMappings[color = lightblue];
buildFeatherTiny, mapCalamusJar -> insertAutoGeneratedEnumMappings;

downloadVersionsManifest[color = lightblue, shape = rect];

v2UnmergedFeatherJar[color = lightblue];
insertAutoGeneratedEnumMappings -> v2UnmergedFeatherJar;

v2MergedFeatherJar[color = lightblue];
mergeV2 -> v2MergedFeatherJar;

mergeV2[color = lightblue];
v2UnmergedFeatherJar, invertCalamusV2 -> mergeV2;

invertCalamusV2[color = lightblue];
downloadCalamusV2 -> invertCalamusV2;

downloadCalamusV2[color = lightblue, shape = rect];
downloadMcJars -> downloadCalamusV2;

mergeJars[color = lightblue];
downloadMcJars -> mergeJars;

downloadVersionDetails[color = lightblue, shape = rect];
downloadVersionsManifest -> downloadVersionDetails;

downloadMcJars[color = lightblue, shape = rect];
downloadVersionDetails -> downloadMcJars;

downloadCalamus[color = lightblue, shape = rect];
downloadMcJars -> downloadCalamus;

downloadWantedVersionManifest[color = lightblue, shape = rect];
downloadVersionsManifest -> downloadWantedVersionManifest;

downloadMcLibs[color = lightblue, shape = rect];
downloadWantedVersionManifest -> downloadMcLibs;

mapCalamusJar[color = lightblue];
downloadMcLibs, downloadCalamus, mergeJars -> mapCalamusJar;

buildFeatherTiny[color = lightblue];
mapCalamusJar, separateMappingsForBuild -> buildFeatherTiny;

// COMMENT OUT

invertCalamus[color = lightblue];
downloadCalamus -> invertCalamus;

mergeTiny[color = lightblue];
buildFeatherTiny, invertCalamus -> mergeTiny;

tinyJar[color = lightblue];
mergeTiny -> tinyJar;

compressTiny[color = lightblue];
tinyJar, mergeTiny -> compressTiny;

compressTiny, tinyJar -> build;
//*/

separateMappingsForBuild[color = lightblue];

build[color = pink];
v2UnmergedFeatherJar, v2MergedFeatherJar -> build;

// COMMENT OUT

subgraph cluster_javadocs {
label = "javadocs"
color = blue;

mapNamedJar, genFakeSource, javadoc, javadocJar;
}

mapNamedJar[color = lightblue];
mergeV2, mapCalamusJar -> mapNamedJar;

genFakeSource[color = lightblue];
mergeV2, mapNamedJar -> genFakeSource;

javadoc[color = lightblue];
genFakeSource, downloadMcLibs -> javadoc;

javadocJar[color = lightblue];
javadoc -> javadocJar;

javadocJar -> publish;
//*/

publish[color = pink];
build -> publish;
}
Binary file added tasks.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a2a202d

Please sign in to comment.