rework dsl, add mod configurations (remapped), add support for other mappings #3

Merged
Ecorous merged 11 commits from owlsys/other-mappings into mistress 2024-07-04 14:39:40 -04:00
Showing only changes of commit 47b6d93b18 - Show all commits

View file

@ -21,6 +21,7 @@ import org.gradle.api.Project
import org.gradle.api.model.ObjectFactory import org.gradle.api.model.ObjectFactory
import org.gradle.api.plugins.JavaBasePlugin import org.gradle.api.plugins.JavaBasePlugin
import org.gradle.api.plugins.JavaPlugin import org.gradle.api.plugins.JavaPlugin
import org.gradle.api.tasks.Delete
import org.gradle.configurationcache.extensions.capitalized import org.gradle.configurationcache.extensions.capitalized
import org.jetbrains.java.decompiler.main.Fernflower import org.jetbrains.java.decompiler.main.Fernflower
import org.jetbrains.java.decompiler.main.decompiler.PrintStreamLogger import org.jetbrains.java.decompiler.main.decompiler.PrintStreamLogger
@ -173,18 +174,14 @@ abstract class PhytotelmaGradleExtensionImpl @Inject constructor(
} }
} }
project.tasks.register(Constants.CLEAR_LOCAL_CACHE_TASK) { task -> project.tasks.register(Constants.CLEAR_LOCAL_CACHE_TASK, Delete::class.java) { task ->
task.group = Constants.TASK_GROUP task.group = Constants.TASK_GROUP
task.actions.add { task.delete = setOf(ProjectStorage.get(project).localCacheDir)
clearLocalCache()
}
} }
project.tasks.register(Constants.CLEAR_GLOBAL_CACHE_TASK) { task -> project.tasks.register(Constants.CLEAR_GLOBAL_CACHE_TASK, Delete::class.java) { task ->
task.group = Constants.TASK_GROUP task.group = Constants.TASK_GROUP
task.actions.add { task.delete = setOf(PhytotelmaPlugin.globalCacheDir)
clearGlobalCache()
}
} }
project.afterEvaluate { project.afterEvaluate {
@ -192,16 +189,6 @@ abstract class PhytotelmaGradleExtensionImpl @Inject constructor(
} }
} }
@OptIn(ExperimentalPathApi::class)
private fun clearLocalCache() {
ProjectStorage.get(project).localCacheDir?.deleteRecursively()
}
@OptIn(ExperimentalPathApi::class)
private fun clearGlobalCache() {
PhytotelmaPlugin.globalCacheDir.deleteRecursively()
}
private fun remapModDependencies() { private fun remapModDependencies() {
ModConfigurations.configurations.forEach { conf -> ModConfigurations.configurations.forEach { conf ->
val artifacts = project.configurations.getByName("mod" + conf.name.capitalized()) val artifacts = project.configurations.getByName("mod" + conf.name.capitalized())
@ -231,7 +218,8 @@ abstract class PhytotelmaGradleExtensionImpl @Inject constructor(
val groupname = (group + "_" + name).replace(".", "_") val groupname = (group + "_" + name).replace(".", "_")
val version = artifact.moduleVersion.id.version val version = artifact.moduleVersion.id.version
val classifier = artifact.classifier val classifier = artifact.classifier
val remappedPath = targetPath.resolve(groupname).resolve(version).resolve(groupname+"-"+version+(classifier?.let { "-$it" }?:"")+".jar") val remappedPath = targetPath.resolve(groupname).resolve(version)
.resolve(groupname + "-" + version + (classifier?.let { "-$it" } ?: "") + ".jar")
remappedPath.createParentDirectories() remappedPath.createParentDirectories()
remappedPaths.add(remappedPath) remappedPaths.add(remappedPath)
@ -250,7 +238,10 @@ abstract class PhytotelmaGradleExtensionImpl @Inject constructor(
Thyroxine.remap(mappings, artifact.file.toPath(), remappedPath, false, false) Thyroxine.remap(mappings, artifact.file.toPath(), remappedPath, false, false)
project.dependencies.add(target.name, "dev.frogmc.phytotelma.remapped_mods:$groupname:$version"+(classifier?.let { ":$it" }?:"")) project.dependencies.add(
target.name,
"dev.frogmc.phytotelma.remapped_mods:$groupname:$version" + (classifier?.let { ":$it" } ?: "")
)
} }
} }
} }