Compare commits
7 Commits
01407544c9
...
cd9840d1c1
Author | SHA1 | Date |
---|---|---|
Jonathan Coates | cd9840d1c1 | |
Jonathan Coates | b9a002586c | |
Jonathan Coates | a3b07909b0 | |
Jonathan Coates | d7786ee4b9 | |
Jonathan Coates | 4e90240922 | |
Jonathan Coates | 1a87d1bf45 | |
Jonathan Coates | 188806e8b0 |
|
@ -8,8 +8,7 @@ Files:
|
||||||
projects/common/src/main/resources/assets/computercraft/sounds/empty.ogg
|
projects/common/src/main/resources/assets/computercraft/sounds/empty.ogg
|
||||||
projects/common/src/testMod/resources/data/cctest/computercraft/turtle_upgrades/*
|
projects/common/src/testMod/resources/data/cctest/computercraft/turtle_upgrades/*
|
||||||
projects/common/src/testMod/resources/data/cctest/structures/*
|
projects/common/src/testMod/resources/data/cctest/structures/*
|
||||||
projects/fabric/src/generated/*
|
projects/*/src/generated/*
|
||||||
projects/forge/src/generated/*
|
|
||||||
projects/web/src/htmlTransform/export/index.json
|
projects/web/src/htmlTransform/export/index.json
|
||||||
projects/web/src/htmlTransform/export/items/minecraft/*
|
projects/web/src/htmlTransform/export/items/minecraft/*
|
||||||
Comment: Generated/data files are CC0.
|
Comment: Generated/data files are CC0.
|
||||||
|
@ -37,6 +36,7 @@ Files:
|
||||||
projects/fabric/src/testMod/resources/computercraft-gametest.fabric.mixins.json
|
projects/fabric/src/testMod/resources/computercraft-gametest.fabric.mixins.json
|
||||||
projects/fabric/src/testMod/resources/fabric.mod.json
|
projects/fabric/src/testMod/resources/fabric.mod.json
|
||||||
projects/forge/src/client/resources/computercraft-client.forge.mixins.json
|
projects/forge/src/client/resources/computercraft-client.forge.mixins.json
|
||||||
|
projects/forge/src/main/resources/computercraft.forge.mixins.json
|
||||||
projects/web/src/frontend/mount/.settings
|
projects/web/src/frontend/mount/.settings
|
||||||
projects/web/src/frontend/mount/example.nfp
|
projects/web/src/frontend/mount/example.nfp
|
||||||
projects/web/src/frontend/mount/example.nft
|
projects/web/src/frontend/mount/example.nft
|
||||||
|
|
|
@ -0,0 +1,121 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 The CC: Tweaked Developers
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: MPL-2.0
|
||||||
|
|
||||||
|
package cc.tweaked.gradle
|
||||||
|
|
||||||
|
import cc.tweaked.vanillaextract.core.util.MoreFiles
|
||||||
|
import org.gradle.api.Action
|
||||||
|
import org.gradle.api.DefaultTask
|
||||||
|
import org.gradle.api.GradleException
|
||||||
|
import org.gradle.api.file.*
|
||||||
|
import org.gradle.api.model.ObjectFactory
|
||||||
|
import org.gradle.api.provider.ListProperty
|
||||||
|
import org.gradle.api.tasks.*
|
||||||
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Merge common files across multiple directories into one destination directory.
|
||||||
|
*
|
||||||
|
* This is intended for merging the generated resources from the Forge and Fabric projects. Files common between the two
|
||||||
|
* are written to the global [output] directory, while distinct files are written to the per-source
|
||||||
|
* [MergeTrees.Source.output] directory.
|
||||||
|
*/
|
||||||
|
abstract class MergeTrees : DefaultTask() {
|
||||||
|
/**
|
||||||
|
* A source directory to read from.
|
||||||
|
*/
|
||||||
|
interface Source {
|
||||||
|
/**
|
||||||
|
* The folder contianing all input files.
|
||||||
|
*/
|
||||||
|
@get:InputFiles
|
||||||
|
@get:PathSensitive(PathSensitivity.RELATIVE)
|
||||||
|
val input: ConfigurableFileTree
|
||||||
|
|
||||||
|
fun input(configure: Action<ConfigurableFileTree>) {
|
||||||
|
configure.execute(input)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The folder to write files unique to this folder to.
|
||||||
|
*/
|
||||||
|
@get:OutputDirectory
|
||||||
|
val output: DirectoryProperty
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The list of sources.
|
||||||
|
*/
|
||||||
|
@get:Nested
|
||||||
|
abstract val sources: ListProperty<Source>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add and configure a new source.
|
||||||
|
*/
|
||||||
|
fun source(configure: Action<Source>) {
|
||||||
|
val instance = objectFactory.newInstance(Source::class.java)
|
||||||
|
configure.execute(instance)
|
||||||
|
instance.output.disallowChanges()
|
||||||
|
sources.add(instance)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The directory to write common files to.
|
||||||
|
*/
|
||||||
|
@get:OutputDirectory
|
||||||
|
abstract val output: DirectoryProperty
|
||||||
|
|
||||||
|
@get:Inject
|
||||||
|
protected abstract val objectFactory: ObjectFactory
|
||||||
|
|
||||||
|
@get:Inject
|
||||||
|
protected abstract val fsOperations: FileSystemOperations
|
||||||
|
|
||||||
|
@TaskAction
|
||||||
|
fun run() {
|
||||||
|
val sources = this.sources.get()
|
||||||
|
if (sources.isEmpty()) throw GradleException("Cannot have an empty list of sources")
|
||||||
|
|
||||||
|
val files = mutableMapOf<String, SharedFile>()
|
||||||
|
for (source in sources) {
|
||||||
|
source.input.visit(
|
||||||
|
object : FileVisitor {
|
||||||
|
override fun visitDir(dirDetails: FileVisitDetails) = Unit
|
||||||
|
override fun visitFile(fileDetails: FileVisitDetails) {
|
||||||
|
val path = fileDetails.file.toRelativeString(source.input.dir)
|
||||||
|
val hash = MoreFiles.computeSha1(fileDetails.file.toPath())
|
||||||
|
|
||||||
|
val existing = files[path]
|
||||||
|
if (existing == null) {
|
||||||
|
files[path] = SharedFile(hash, 1)
|
||||||
|
} else if (existing.hash == hash) {
|
||||||
|
existing.found++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
val sharedFiles = files.entries.asSequence().filter { (_, v) -> v.found == sources.size }.map { (k, _) -> k }.toList()
|
||||||
|
println(sharedFiles)
|
||||||
|
|
||||||
|
// Copy shared files to the common directory
|
||||||
|
fsOperations.sync {
|
||||||
|
from(sources[0].input)
|
||||||
|
into(output)
|
||||||
|
include(sharedFiles)
|
||||||
|
}
|
||||||
|
|
||||||
|
// And all other files to their per-source directory
|
||||||
|
for (source in sources) {
|
||||||
|
fsOperations.sync {
|
||||||
|
from(source.input)
|
||||||
|
into(source.output)
|
||||||
|
exclude(sharedFiles)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class SharedFile(val hash: String, var found: Int)
|
||||||
|
}
|
|
@ -10,7 +10,7 @@ kotlin.jvm.target.validation.mode=error
|
||||||
|
|
||||||
# Mod properties
|
# Mod properties
|
||||||
isUnstable=true
|
isUnstable=true
|
||||||
modVersion=1.110.2
|
modVersion=1.110.3
|
||||||
|
|
||||||
# Minecraft properties: We want to configure this here so we can read it in settings.gradle
|
# Minecraft properties: We want to configure this here so we can read it in settings.gradle
|
||||||
mcVersion=1.20.5
|
mcVersion=1.20.5
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
# Minecraft
|
# Minecraft
|
||||||
# MC version is specified in gradle.properties, as we need that in settings.gradle.
|
# MC version is specified in gradle.properties, as we need that in settings.gradle.
|
||||||
# Remember to update corresponding versions in fabric.mod.json/mods.toml
|
# Remember to update corresponding versions in fabric.mod.json/neoforge.mods.toml
|
||||||
fabric-api = "0.97.6+1.20.5"
|
fabric-api = "0.97.6+1.20.5"
|
||||||
fabric-loader = "0.15.10"
|
fabric-loader = "0.15.10"
|
||||||
neoForge = "20.5.0-beta"
|
neoForge = "20.5.0-beta"
|
||||||
|
|
|
@ -11,6 +11,12 @@ plugins {
|
||||||
id("cc-tweaked.publishing")
|
id("cc-tweaked.publishing")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
main {
|
||||||
|
resources.srcDir("src/generated/resources")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
minecraft {
|
minecraft {
|
||||||
accessWideners(
|
accessWideners(
|
||||||
"src/main/resources/computercraft.accesswidener",
|
"src/main/resources/computercraft.accesswidener",
|
||||||
|
@ -107,3 +113,19 @@ val lintLua by tasks.registering(IlluaminateExec::class) {
|
||||||
doFirst { if (System.getenv("GITHUB_ACTIONS") != null) println("::add-matcher::.github/matchers/illuaminate.json") }
|
doFirst { if (System.getenv("GITHUB_ACTIONS") != null) println("::add-matcher::.github/matchers/illuaminate.json") }
|
||||||
doLast { if (System.getenv("GITHUB_ACTIONS") != null) println("::remove-matcher owner=illuaminate::") }
|
doLast { if (System.getenv("GITHUB_ACTIONS") != null) println("::remove-matcher owner=illuaminate::") }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val runData by tasks.registering(MergeTrees::class) {
|
||||||
|
output = layout.projectDirectory.dir("src/generated/resources")
|
||||||
|
|
||||||
|
for (loader in listOf("forge", "fabric")) {
|
||||||
|
mustRunAfter(":$loader:runData")
|
||||||
|
source {
|
||||||
|
input {
|
||||||
|
from(project(":$loader").layout.buildDirectory.dir("generatedResources"))
|
||||||
|
exclude(".cache")
|
||||||
|
}
|
||||||
|
|
||||||
|
output = project(":$loader").layout.projectDirectory.dir("src/generated/resources")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue