Skip to content

Commit

Permalink
ResolveModpack task
Browse files Browse the repository at this point in the history
  • Loading branch information
liplum committed Dec 21, 2023
1 parent a1f6c9f commit 898dc94
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion main/src/SharedCache.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import org.gradle.api.logging.Logger
import kotlin.math.absoluteValue


internal
private
const val lockFileEx = "lock.json"

data class GihHubDownloadTrack(
Expand Down
5 changes: 0 additions & 5 deletions main/src/plugin/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,4 @@ inline fun safeRun(func: () -> Unit) {
}
}

/**
* Provides the existing [resolveMods][ResolveMods] task.
*/
val TaskContainer.`resolveMods`: TaskProvider<ResolveMods>
get() = named<ResolveMods>(R.task.resolveMods)

2 changes: 1 addition & 1 deletion main/src/plugin/Run.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class MindustryRunPlugin : Plugin<Project> {
private fun addResolveModpacks(proj: Project, x: RunMindustryExtension) {
for (modpack in x.modpacks) {
val name = modpack.name
proj.tasks.register<ResolveMods>("resolveModpack$name") {
proj.tasks.register<ResolveModpack>("resolveModpack$name") {
group = R.taskGroup.mindustryStuff
dependsOn(*modpack.fromTaskPath.toArray())
mods.addAll(modpack.mods)
Expand Down
12 changes: 11 additions & 1 deletion main/src/task/ResolveMods.kt → main/src/task/ResolveModpack.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ import org.gradle.api.tasks.OutputFiles
import org.gradle.api.tasks.TaskAction
import java.io.File

open class ResolveMods : DefaultTask() {
private
const val lockFile = "lock.json"

open class ResolveModpack : DefaultTask() {
val mods = project.listProp<IMod>()
@Input get
val downloadedMods = project.listProp<File>()
Expand Down Expand Up @@ -55,6 +58,10 @@ open class ResolveMods : DefaultTask() {
}
}

fun lock() {
temporaryDir.resolve(lockFile)
}

fun IDownloadableMod.download(cacheFile: File) {
logger.lifecycle("Downloading $this -> $cacheFile...")
try {
Expand All @@ -66,3 +73,6 @@ open class ResolveMods : DefaultTask() {
}
}

data class ModLock(
val path: String,
)

0 comments on commit 898dc94

Please sign in to comment.