mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-01-10 01:10:30 +00:00
Update NF and NG
- Rename ToolActions to ItemAbilities. Closes #1881. - Remove our source set helper, as NG has built-in support for this now. - Remove our code to generate new JavaExec tasks from runs, as NG now generates JavaExec tasks normally.
This commit is contained in:
parent
aca1d43550
commit
0e4710a956
@ -9,6 +9,7 @@ import org.gradle.api.file.FileSystemLocation
|
||||
import org.gradle.api.provider.Property
|
||||
import org.gradle.api.provider.Provider
|
||||
import org.gradle.api.tasks.JavaExec
|
||||
import org.gradle.kotlin.dsl.getByName
|
||||
import org.gradle.process.BaseExecSpec
|
||||
import org.gradle.process.JavaExecSpec
|
||||
import org.gradle.process.ProcessForkOptions
|
||||
@ -46,6 +47,21 @@ fun JavaExec.copyToFull(spec: JavaExec) {
|
||||
copyToExec(spec)
|
||||
}
|
||||
|
||||
/**
|
||||
* Base this [JavaExec] task on an existing task.
|
||||
*/
|
||||
fun JavaExec.copyFromTask(task: JavaExec) {
|
||||
for (dep in task.dependsOn) dependsOn(dep)
|
||||
task.copyToFull(this)
|
||||
}
|
||||
|
||||
/**
|
||||
* Base this [JavaExec] task on an existing task.
|
||||
*/
|
||||
fun JavaExec.copyFromTask(task: String) {
|
||||
copyFromTask(project.tasks.getByName<JavaExec>(task))
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy additional [BaseExecSpec] options which aren't handled by [ProcessForkOptions.copyTo].
|
||||
*/
|
||||
|
@ -1,62 +0,0 @@
|
||||
// SPDX-FileCopyrightText: 2023 The CC: Tweaked Developers
|
||||
//
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
package cc.tweaked.gradle
|
||||
|
||||
import net.neoforged.gradle.common.runs.run.RunImpl
|
||||
import net.neoforged.gradle.common.runs.tasks.RunExec
|
||||
import net.neoforged.gradle.dsl.common.extensions.RunnableSourceSet
|
||||
import net.neoforged.gradle.dsl.common.runs.run.Run
|
||||
import org.gradle.api.plugins.JavaPluginExtension
|
||||
import org.gradle.api.tasks.JavaExec
|
||||
import org.gradle.api.tasks.SourceSet
|
||||
import org.gradle.jvm.toolchain.JavaToolchainService
|
||||
import org.gradle.kotlin.dsl.assign
|
||||
import org.gradle.kotlin.dsl.create
|
||||
import org.gradle.kotlin.dsl.findByType
|
||||
import java.nio.file.Files
|
||||
|
||||
/**
|
||||
* Set [JavaExec] task to run a given [RunConfig].
|
||||
*
|
||||
* See also [RunExec].
|
||||
*/
|
||||
fun JavaExec.setRunConfig(config: Run) {
|
||||
mainClass.set(config.mainClass)
|
||||
workingDir = config.workingDirectory.get().asFile
|
||||
argumentProviders.add { config.programArguments.get() }
|
||||
jvmArgumentProviders.add { config.jvmArguments.get() }
|
||||
|
||||
environment(config.environmentVariables.get())
|
||||
systemProperties(config.systemProperties.get())
|
||||
|
||||
config.modSources.all().get().values().forEach { classpath(it.runtimeClasspath) }
|
||||
classpath(config.classpath)
|
||||
classpath(config.dependencies.get().runtimeConfiguration)
|
||||
|
||||
(config as RunImpl).taskDependencies.forEach { dependsOn(it) }
|
||||
|
||||
javaLauncher.set(
|
||||
project.extensions.getByType(JavaToolchainService::class.java)
|
||||
.launcherFor(project.extensions.getByType(JavaPluginExtension::class.java).toolchain),
|
||||
)
|
||||
|
||||
doFirst("Create working directory") { Files.createDirectories(workingDir.toPath()) }
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new [Run.modSource] with a specific mod id.
|
||||
*/
|
||||
fun Run.modSourceAs(sourceSet: SourceSet, mod: String) {
|
||||
// NeoGradle requires a RunnableSourceSet to be present, so we inject it into other project's source sets.
|
||||
val runnable = sourceSet.extensions.findByType<RunnableSourceSet>() ?: run {
|
||||
val extension = sourceSet.extensions.create<RunnableSourceSet>(RunnableSourceSet.NAME, project)
|
||||
extension.modIdentifier = mod
|
||||
extension.modIdentifier.finalizeValueOnRead()
|
||||
extension
|
||||
}
|
||||
if (runnable.modIdentifier.get() != mod) throw IllegalArgumentException("Multiple mod identifiers")
|
||||
|
||||
modSource(sourceSet)
|
||||
}
|
@ -9,7 +9,7 @@
|
||||
# Remember to update corresponding versions in fabric.mod.json/neoforge.mods.toml
|
||||
fabric-api = "0.100.3+1.21"
|
||||
fabric-loader = "0.15.11"
|
||||
neoForge = "21.0.21-beta"
|
||||
neoForge = "21.0.42-beta"
|
||||
neoForgeSpi = "8.0.1"
|
||||
mixin = "0.8.5"
|
||||
parchment = "2024.06.16"
|
||||
@ -67,7 +67,7 @@ ideaExt = "1.1.7"
|
||||
illuaminate = "0.1.0-73-g43ee16c"
|
||||
lwjgl = "3.3.3"
|
||||
minotaur = "2.8.7"
|
||||
neoGradle = "7.0.145"
|
||||
neoGradle = "7.0.152"
|
||||
nullAway = "0.10.25"
|
||||
spotless = "6.23.3"
|
||||
taskTree = "2.1.1"
|
||||
|
@ -40,7 +40,7 @@ runs {
|
||||
systemProperty("forge.logging.console.level", "debug")
|
||||
|
||||
cct.sourceDirectories.get().forEach {
|
||||
if (it.classes) modSourceAs(it.sourceSet, "computercraft")
|
||||
if (it.classes) modSources.add("computercraft", it.sourceSet)
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@ -74,7 +74,7 @@ runs {
|
||||
|
||||
modSource(sourceSets.testMod.get())
|
||||
modSource(sourceSets.testFixtures.get())
|
||||
modSourceAs(project(":core").sourceSets.testFixtures.get(), "cctest")
|
||||
modSources.add("cctest", project(":core").sourceSets.testFixtures.get())
|
||||
|
||||
jvmArgument("-ea")
|
||||
|
||||
@ -199,7 +199,7 @@ val runGametest by tasks.registering(JavaExec::class) {
|
||||
dependsOn("cleanRunGametest")
|
||||
usesService(MinecraftRunnerService.get(gradle))
|
||||
|
||||
setRunConfig(runs["gameTestServer"])
|
||||
copyFromTask("runGameTestServer")
|
||||
|
||||
systemProperty("forge.logging.console.level", "info")
|
||||
systemProperty("cctest.gametest-report", layout.buildDirectory.dir("test-results/$name.xml").getAbsolutePath())
|
||||
|
@ -54,8 +54,8 @@ import net.neoforged.neoforge.capabilities.BlockCapability;
|
||||
import net.neoforged.neoforge.capabilities.BlockCapabilityCache;
|
||||
import net.neoforged.neoforge.capabilities.Capabilities;
|
||||
import net.neoforged.neoforge.common.CommonHooks;
|
||||
import net.neoforged.neoforge.common.ItemAbilities;
|
||||
import net.neoforged.neoforge.common.Tags;
|
||||
import net.neoforged.neoforge.common.ToolActions;
|
||||
import net.neoforged.neoforge.common.extensions.IMenuTypeExtension;
|
||||
import net.neoforged.neoforge.event.EventHooks;
|
||||
import net.neoforged.neoforge.items.wrapper.InvWrapper;
|
||||
@ -211,7 +211,7 @@ public class PlatformHelperImpl implements PlatformHelper {
|
||||
|
||||
@Override
|
||||
public boolean hasToolUsage(ItemStack stack) {
|
||||
return stack.canPerformAction(ToolActions.SHOVEL_FLATTEN) || stack.canPerformAction(ToolActions.HOE_TILL);
|
||||
return stack.canPerformAction(ItemAbilities.SHOVEL_FLATTEN) || stack.canPerformAction(ItemAbilities.HOE_TILL);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user